Message ID | 20230127001951.3432374-1-namhyung@kernel.org |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp563705wrn; Thu, 26 Jan 2023 16:28:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXtG0G5shJwRrLm4aZcCXrqqn1eDvj8pym1zv5sAiRozZtUEy+XdJpg5DF+R9zYBY7EusBYp X-Received: by 2002:a05:6a20:d90d:b0:b5:dc64:87c with SMTP id jd13-20020a056a20d90d00b000b5dc64087cmr37676955pzb.26.1674779287118; Thu, 26 Jan 2023 16:28:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674779287; cv=none; d=google.com; s=arc-20160816; b=TmrFlq+lB0mBpU59D1lLJQ/sDrKBIIGtTn7gEtUUKOUMO9cKyglGwxef6+ZPDb3tnq ZU6hG0mFo/pyOzHNOXyAdG1Apdo5S63UdKK8lBjrWrVoFqom9BcF38xgsQdIUr+yWbfI g0wmAXbjK3OXrY4sT8rFlExlva5sfliE4VPckCYwCHARfOkvTxpW6HvtWcfYZK/t5QJR aiS7hF1eanE0+tBJDA3gAcJ8ngqat485FXI3+aARtNYKzSET0ZNvpw5h4+iEzlpvql9S LJecdcBmIWMewi5d1byOJinlrUC9TaLKGccC43+nUJP9IwVjExXyOn6e0j885z1HWaxI 6HQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=9ypUj7POs4xLGtv/nfXnLdHLn8gFaHVzUgoNscw+Tec=; b=e6bhKtX1mVG8OUKaUie6ip4/0XoH0Zo6HhmjvdYJCaxUdJ9RVRSUJ2RNQc6e71oPEZ 7vLhjFmTUp8GAM4ny1flg5ljqOBJg75QgZyNHcgo6/Sw/KzLYla3o7+TKH9hkX8BzNl4 WI5QiSfz+nlU1s3bU4au0YG2qmNW9l3XtDMt+o5yRcoj2457v2dbXoUAw0EKg0e3W6rW a8vwfAYAPgG87majcknUnOb9E/PlSTBWJBSYx7T6ClUWuvfh5IN0rd+jjx0f51xJt474 K7rwTm2N4LkDyEA/XRuNsYvKIr/8FrHdA7xLLWRycAYo8xsENWOg2LtX2N+QO4iMsV8X yBJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RIlkHk2a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g62-20020a636b41000000b0049bef470e05si2394184pgc.528.2023.01.26.16.27.53; Thu, 26 Jan 2023 16:28:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RIlkHk2a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229607AbjA0AUg (ORCPT <rfc822;lekhanya01809@gmail.com> + 99 others); Thu, 26 Jan 2023 19:20:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229976AbjA0AUe (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 26 Jan 2023 19:20:34 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB6CD1EFC7; Thu, 26 Jan 2023 16:19:55 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id b10so3082460pjo.1; Thu, 26 Jan 2023 16:19:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=9ypUj7POs4xLGtv/nfXnLdHLn8gFaHVzUgoNscw+Tec=; b=RIlkHk2aXkP/O3krmxrSzlACAjpJhRCK2ToAy+db7cSN/JHAwdNVLnFrUkEMlyzJvy NQ4Fwm52DTCWFcTlEvh77GcPXBcrhGiVEJnsBHhMgXMM8MYK7ZbIZ9a+/1un62a3dUQw WAjFEKjWtGzlH42ev4GzudmOffwZq4GB+YJk7mF2VPW9yRwTDDVg4F/r6+vV7F+49E7c Jqzg9aqaR1y+OTsTD72Qotu+QgaO4Ps44vFQ8poJf8pB7tLC2NXVZRYD1nB1stLG7RjO Xu+iQ/n225Mc7DB5Gz+bfRh2Lw/MC8xy+BtLZ12Ic7mAFYBVSabtBEnnxb2xHyTs//2D ZRmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9ypUj7POs4xLGtv/nfXnLdHLn8gFaHVzUgoNscw+Tec=; b=xqjxrmZ6y9SL5f6Dv1otIde0UdweODWE8lFhkBazEFdSSYjoUJ2n/Khjvqnc7KfqiI iH+w8KyCaS8fCwLE84RSGMpDN1AzaA5yWAPi0Sq6BLhgmVQZLcDcO7HGarIeEPpTSfa3 l2ZhDHVye1DjPiXcSMH8O5nBgpRIGp86tRmlQQgQ+xUIefF6EXiaCHLAZk6KApDLWeZt UKp59gtRqyItHChkfh8UkysHgf3Zm/AjxSQMQq++ctnOjsQ8tBjDZvgePEqoURlTQ4fS bbCopzo4fSE+xFaE3RvQfIHUIw1cdL6Ws9iFXM5hus+vI8O1mw6xzLArjg2m+X8PwQgB HXcg== X-Gm-Message-State: AO0yUKU/Zh4mzP+sdWjG1awmGXsQR8Z6hV7ubd97+Hp84ho22p863UqP brpL6bTY6/cbh132M2JJ6WwAkWuptVg= X-Received: by 2002:a17:90a:1a10:b0:22c:23b5:4977 with SMTP id 16-20020a17090a1a1000b0022c23b54977mr4448751pjk.14.1674778795102; Thu, 26 Jan 2023 16:19:55 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:1f5d:eee8:d409:8a17]) by smtp.gmail.com with ESMTPSA id v15-20020a17090a088f00b00229f7376247sm1567270pjc.57.2023.01.26.16.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 16:19:54 -0800 (PST) Sender: Namhyung Kim <namhyung@gmail.com> From: Namhyung Kim <namhyung@kernel.org> To: Arnaldo Carvalho de Melo <acme@kernel.org>, Jiri Olsa <jolsa@kernel.org>, Adrian Hunter <adrian.hunter@intel.com> Cc: Ingo Molnar <mingo@kernel.org>, Peter Zijlstra <peterz@infradead.org>, LKML <linux-kernel@vger.kernel.org>, Ian Rogers <irogers@google.com>, linux-perf-users@vger.kernel.org, Leo Yan <leo.yan@linaro.org>, James Clark <james.clark@arm.com>, Stephane Eranian <eranian@google.com> Subject: [PATCH 0/4] perf intel-pt: Fix the pipe mode (v1) Date: Thu, 26 Jan 2023 16:19:47 -0800 Message-Id: <20230127001951.3432374-1-namhyung@kernel.org> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756133365872382631?= X-GMAIL-MSGID: =?utf-8?q?1756133365872382631?= |
Series | perf intel-pt: Fix the pipe mode (v1) | |
Message
Namhyung Kim
Jan. 27, 2023, 12:19 a.m. UTC
Hello, I found some problems in Intel-PT and auxtrace in general with pipe. In the past it used to work with pipe, but recent code fails. As it also touches the generic code, other auxtrace users like ARM SPE will be affected too. I added a test case to verify it works with pipes. At last, I can run this command without a problem. $ perf record -o- -e intel_pt// true | perf inject -b | perf report -i- --itrace=i1000 The code is available at 'perf/auxtrace-pipe-v1' branch in git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git Thanks, Namhyung Namhyung Kim (4): perf inject: Use perf_data__read() for auxtrace perf intel-pt: Do not try to queue auxtrace data on pipe perf session: Avoid calling lseek(2) for pipe perf test: Add pipe mode test to the Intel PT test suite tools/perf/builtin-inject.c | 6 +++--- tools/perf/tests/shell/test_intel_pt.sh | 17 +++++++++++++++++ tools/perf/util/auxtrace.c | 3 +++ tools/perf/util/session.c | 9 +++++++-- 4 files changed, 30 insertions(+), 5 deletions(-) base-commit: 5670ebf54bd26482f57a094c53bdc562c106e0a9 prerequisite-patch-id: 4ccdf9c974a3909075051f4ffe498faecab7567b
Comments
On 27/01/23 02:19, Namhyung Kim wrote: > Hello, > > I found some problems in Intel-PT and auxtrace in general with pipe. > In the past it used to work with pipe, but recent code fails. Pipe mode is a problem for Intel PT and possibly other auxtrace users. Essentially the auxtrace buffers do not behave like the regular perf event buffers. That is because the head and tail are updated by software, but in the auxtrace case the data is written by hardware. So the head and tail do not get updated as data is written. In the Intel PT case, the head and tail are updated only when the trace is disabled by software, for example: - full-trace, system wide : when buffer passes watermark - full-trace, not system-wide : when buffer passes watermark or context switches - snapshot mode : as above but also when a snapshot is made - sample mode : as above but also when a sample is made That means finished-round ordering doesn't work. An auxtrace buffer can turn up that has data that extends back in time, possibly to the very beginning of tracing. For a perf.data file, that problem is solved by going through the trace and queuing up the auxtrace buffers in advance. For pipe mode, the order of events and timestamps can presumably be messed up. For Intel PT, it is a bit of a surprise that there is not validation to error out in pipe mode. At the least, a warning is needed, and the above explanation needs to be added to the documentation. > As it > also touches the generic code, other auxtrace users like ARM SPE will > be affected too. I added a test case to verify it works with pipes. > > At last, I can run this command without a problem. > > $ perf record -o- -e intel_pt// true | perf inject -b | perf report -i- --itrace=i1000 > > The code is available at 'perf/auxtrace-pipe-v1' branch in > > git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git > > Thanks, > Namhyung > > Namhyung Kim (4): > perf inject: Use perf_data__read() for auxtrace > perf intel-pt: Do not try to queue auxtrace data on pipe > perf session: Avoid calling lseek(2) for pipe > perf test: Add pipe mode test to the Intel PT test suite > > tools/perf/builtin-inject.c | 6 +++--- > tools/perf/tests/shell/test_intel_pt.sh | 17 +++++++++++++++++ > tools/perf/util/auxtrace.c | 3 +++ > tools/perf/util/session.c | 9 +++++++-- > 4 files changed, 30 insertions(+), 5 deletions(-) > > > base-commit: 5670ebf54bd26482f57a094c53bdc562c106e0a9 > prerequisite-patch-id: 4ccdf9c974a3909075051f4ffe498faecab7567b
On 27/01/2023 07:22, Adrian Hunter wrote: > On 27/01/23 02:19, Namhyung Kim wrote: >> Hello, >> >> I found some problems in Intel-PT and auxtrace in general with pipe. >> In the past it used to work with pipe, but recent code fails. > > Pipe mode is a problem for Intel PT and possibly other auxtrace users. Just some info from my side: For Arm Coresight we ended up deprecating pipe mode, then not supporting it altogether. First was when we added an optional step to peek through all of the data to help with an edge case. Then we added a requirement to receive a HW_ID packet before decoding which necessitated the peek. You can't peek in pipe mode because you need to be able to seek, so it's not supported at all anymore. For Arm SPE I never tested it with piped data. I suppose I could add a test at some point, but I don't really see the usecase. James > Essentially the auxtrace buffers do not behave like the regular perf > event buffers. That is because the head and tail are updated by > software, but in the auxtrace case the data is written by hardware. > So the head and tail do not get updated as data is written. In the > Intel PT case, the head and tail are updated only when the trace is > disabled by software, for example: > - full-trace, system wide : when buffer passes watermark > - full-trace, not system-wide : when buffer passes watermark or > context switches > - snapshot mode : as above but also when a snapshot is made > - sample mode : as above but also when a sample is made > > That means finished-round ordering doesn't work. An auxtrace buffer > can turn up that has data that extends back in time, possibly to the > very beginning of tracing. > > For a perf.data file, that problem is solved by going through the trace > and queuing up the auxtrace buffers in advance. > > For pipe mode, the order of events and timestamps can presumably > be messed up. > > For Intel PT, it is a bit of a surprise that there is not > validation to error out in pipe mode. > > At the least, a warning is needed, and the above explanation needs > to be added to the documentation. > >> As it >> also touches the generic code, other auxtrace users like ARM SPE will >> be affected too. I added a test case to verify it works with pipes. >> >> At last, I can run this command without a problem. >> >> $ perf record -o- -e intel_pt// true | perf inject -b | perf report -i- --itrace=i1000 >> >> The code is available at 'perf/auxtrace-pipe-v1' branch in >> >> git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git >> >> Thanks, >> Namhyung >> >> Namhyung Kim (4): >> perf inject: Use perf_data__read() for auxtrace >> perf intel-pt: Do not try to queue auxtrace data on pipe >> perf session: Avoid calling lseek(2) for pipe >> perf test: Add pipe mode test to the Intel PT test suite >> >> tools/perf/builtin-inject.c | 6 +++--- >> tools/perf/tests/shell/test_intel_pt.sh | 17 +++++++++++++++++ >> tools/perf/util/auxtrace.c | 3 +++ >> tools/perf/util/session.c | 9 +++++++-- >> 4 files changed, 30 insertions(+), 5 deletions(-) >> >> >> base-commit: 5670ebf54bd26482f57a094c53bdc562c106e0a9 >> prerequisite-patch-id: 4ccdf9c974a3909075051f4ffe498faecab7567b >
On 27/01/2023 00:19, Namhyung Kim wrote: > Hello, > > I found some problems in Intel-PT and auxtrace in general with pipe. > In the past it used to work with pipe, but recent code fails. As it > also touches the generic code, other auxtrace users like ARM SPE will > be affected too. I added a test case to verify it works with pipes. > > At last, I can run this command without a problem. > > $ perf record -o- -e intel_pt// true | perf inject -b | perf report -i- --itrace=i1000 > > The code is available at 'perf/auxtrace-pipe-v1' branch in > > git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git > > Thanks, > Namhyung > > Namhyung Kim (4): > perf inject: Use perf_data__read() for auxtrace > perf intel-pt: Do not try to queue auxtrace data on pipe > perf session: Avoid calling lseek(2) for pipe > perf test: Add pipe mode test to the Intel PT test suite > > tools/perf/builtin-inject.c | 6 +++--- > tools/perf/tests/shell/test_intel_pt.sh | 17 +++++++++++++++++ > tools/perf/util/auxtrace.c | 3 +++ > tools/perf/util/session.c | 9 +++++++-- > 4 files changed, 30 insertions(+), 5 deletions(-) > > For the whole set: Reviewed-by: James Clark <james.clark@arm.com> > base-commit: 5670ebf54bd26482f57a094c53bdc562c106e0a9 > prerequisite-patch-id: 4ccdf9c974a3909075051f4ffe498faecab7567b
Hi Adrian, On Thu, Jan 26, 2023 at 11:22 PM Adrian Hunter <adrian.hunter@intel.com> wrote: > > On 27/01/23 02:19, Namhyung Kim wrote: > > Hello, > > > > I found some problems in Intel-PT and auxtrace in general with pipe. > > In the past it used to work with pipe, but recent code fails. > > Pipe mode is a problem for Intel PT and possibly other auxtrace users. > Essentially the auxtrace buffers do not behave like the regular perf > event buffers. That is because the head and tail are updated by > software, but in the auxtrace case the data is written by hardware. > So the head and tail do not get updated as data is written. In the > Intel PT case, the head and tail are updated only when the trace is > disabled by software, for example: > - full-trace, system wide : when buffer passes watermark > - full-trace, not system-wide : when buffer passes watermark or > context switches > - snapshot mode : as above but also when a snapshot is made > - sample mode : as above but also when a sample is made > > That means finished-round ordering doesn't work. An auxtrace buffer > can turn up that has data that extends back in time, possibly to the > very beginning of tracing. Ok, IIUC we want to process the main buffer and auxtrace buffer together in time order but there's no guarantee to get the auxtrace data in time, right? I wonder if it's possible to use 2 pass processing for pipe mode. We may keep the events in the ordered queue and auxtrace queue in the first pass, and process together from the beginning in the second pass. But I guess the data size would be a problem. Or, assuming that the auxtrace buffer comes later than (or equal to) the main buffer, we may start processing the main buffer as soon as every auxtrace queue gets some data. Thoughts? > > For a perf.data file, that problem is solved by going through the trace > and queuing up the auxtrace buffers in advance. > > For pipe mode, the order of events and timestamps can presumably > be messed up. > > For Intel PT, it is a bit of a surprise that there is not > validation to error out in pipe mode. What kind of validation do you have in mind? Checking pid/tid? > > At the least, a warning is needed, and the above explanation needs > to be added to the documentation. Thanks, I'll add it to the documentation. How about showing something like this for pipe mode? WARNING: Intel-PT with pipe mode may not work correctly. Thanks, Namhyung > > > As it > > also touches the generic code, other auxtrace users like ARM SPE will > > be affected too. I added a test case to verify it works with pipes. > > > > At last, I can run this command without a problem. > > > > $ perf record -o- -e intel_pt// true | perf inject -b | perf report -i- --itrace=i1000 > > > > The code is available at 'perf/auxtrace-pipe-v1' branch in > > > > git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git > > > > Thanks, > > Namhyung > > > > Namhyung Kim (4): > > perf inject: Use perf_data__read() for auxtrace > > perf intel-pt: Do not try to queue auxtrace data on pipe > > perf session: Avoid calling lseek(2) for pipe > > perf test: Add pipe mode test to the Intel PT test suite > > > > tools/perf/builtin-inject.c | 6 +++--- > > tools/perf/tests/shell/test_intel_pt.sh | 17 +++++++++++++++++ > > tools/perf/util/auxtrace.c | 3 +++ > > tools/perf/util/session.c | 9 +++++++-- > > 4 files changed, 30 insertions(+), 5 deletions(-) > > > > > > base-commit: 5670ebf54bd26482f57a094c53bdc562c106e0a9 > > prerequisite-patch-id: 4ccdf9c974a3909075051f4ffe498faecab7567b >
Hi James, On Fri, Jan 27, 2023 at 6:42 AM James Clark <james.clark@arm.com> wrote: > > > > On 27/01/2023 07:22, Adrian Hunter wrote: > > On 27/01/23 02:19, Namhyung Kim wrote: > >> Hello, > >> > >> I found some problems in Intel-PT and auxtrace in general with pipe. > >> In the past it used to work with pipe, but recent code fails. > > > > Pipe mode is a problem for Intel PT and possibly other auxtrace users. > > Just some info from my side: For Arm Coresight we ended up deprecating > pipe mode, then not supporting it altogether. First was when we added an > optional step to peek through all of the data to help with an edge case. > Then we added a requirement to receive a HW_ID packet before decoding > which necessitated the peek. You can't peek in pipe mode because you > need to be able to seek, so it's not supported at all anymore. > > For Arm SPE I never tested it with piped data. I suppose I could add a > test at some point, but I don't really see the usecase. Yeah, it'd be great if we can have a test for Arm SPE. Anyway, my work env (Google) requires the pipe mode due to the restriction in disk usage. Without the pipe support, it's not possible to run `perf record` in production. Thanks, Namhyung
On 27/01/2023 23:08, Namhyung Kim wrote: > Hi James, > > On Fri, Jan 27, 2023 at 6:42 AM James Clark <james.clark@arm.com> wrote: >> >> >> >> On 27/01/2023 07:22, Adrian Hunter wrote: >>> On 27/01/23 02:19, Namhyung Kim wrote: >>>> Hello, >>>> >>>> I found some problems in Intel-PT and auxtrace in general with pipe. >>>> In the past it used to work with pipe, but recent code fails. >>> >>> Pipe mode is a problem for Intel PT and possibly other auxtrace users. >> >> Just some info from my side: For Arm Coresight we ended up deprecating >> pipe mode, then not supporting it altogether. First was when we added an >> optional step to peek through all of the data to help with an edge case. >> Then we added a requirement to receive a HW_ID packet before decoding >> which necessitated the peek. You can't peek in pipe mode because you >> need to be able to seek, so it's not supported at all anymore. >> >> For Arm SPE I never tested it with piped data. I suppose I could add a >> test at some point, but I don't really see the usecase. > > Yeah, it'd be great if we can have a test for Arm SPE. > Ok thanks I will put it on the list of things to do. > Anyway, my work env (Google) requires the pipe mode due to the > restriction in disk usage. Without the pipe support, it's not possible > to run `perf record` in production. > Makes sense. Unfortunately at the moment with Coresight, because of the lack of appropriate timestamps we're waiting for the end of the file before starting decoding. So you're not really any better off using piped mode, unless you have a lot more memory than disk space? Since this commit [1] and Arm v8.4 we can actually start making use of the timestamps and do a streaming decode again. So I will also add it to the list to look into that for Coresight again. Are you using an old version of Perf or not using Coresight at all? I know Denis at Google is using Coresight, but only with files rather than pipes. One other thing, have you used the --switch-output mode to perf record before? I would have said it would give you some of the benefits of piped mode, but is more likely to work with Coresight. But last time I checked it's not working either. Not very helpful I know, but something to keep in mind. James [1]: https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/commit/?h=perf/core&id=a7fe9a443b6064c68f86a2ee09bdfa7736660ef3
Em Fri, Jan 27, 2023 at 02:54:36PM -0800, Namhyung Kim escreveu: > Hi Adrian, > > On Thu, Jan 26, 2023 at 11:22 PM Adrian Hunter <adrian.hunter@intel.com> wrote: > > > > On 27/01/23 02:19, Namhyung Kim wrote: > > > Hello, > > > > > > I found some problems in Intel-PT and auxtrace in general with pipe. > > > In the past it used to work with pipe, but recent code fails. > > > > Pipe mode is a problem for Intel PT and possibly other auxtrace users. > > Essentially the auxtrace buffers do not behave like the regular perf > > event buffers. That is because the head and tail are updated by > > software, but in the auxtrace case the data is written by hardware. > > So the head and tail do not get updated as data is written. In the > > Intel PT case, the head and tail are updated only when the trace is > > disabled by software, for example: > > - full-trace, system wide : when buffer passes watermark > > - full-trace, not system-wide : when buffer passes watermark or > > context switches > > - snapshot mode : as above but also when a snapshot is made > > - sample mode : as above but also when a sample is made > > > > That means finished-round ordering doesn't work. An auxtrace buffer > > can turn up that has data that extends back in time, possibly to the > > very beginning of tracing. > > Ok, IIUC we want to process the main buffer and auxtrace buffer > together in time order but there's no guarantee to get the auxtrace > data in time, right? > > I wonder if it's possible to use 2 pass processing for pipe mode. > We may keep the events in the ordered queue and auxtrace queue > in the first pass, and process together from the beginning in the > second pass. But I guess the data size would be a problem. > > Or, assuming that the auxtrace buffer comes later than (or equal to) > the main buffer, we may start processing the main buffer as soon as > every auxtrace queue gets some data. Thoughts? > > > > > For a perf.data file, that problem is solved by going through the trace > > and queuing up the auxtrace buffers in advance. > > > > For pipe mode, the order of events and timestamps can presumably > > be messed up. > > > > For Intel PT, it is a bit of a surprise that there is not > > validation to error out in pipe mode. > > What kind of validation do you have in mind? Checking pid/tid? > > > > > At the least, a warning is needed, and the above explanation needs > > to be added to the documentation. > > Thanks, I'll add it to the documentation. Ok, so I'll wait for v2 of this patch series, Adrian, apart from what you mentioned, are you ok with the patches, or a subset of them? The first ones looks ok, right? - Arnaldo > How about showing something like this for pipe mode? > > WARNING: Intel-PT with pipe mode may not work correctly. > > Thanks, > Namhyung > > > > > > > As it > > > also touches the generic code, other auxtrace users like ARM SPE will > > > be affected too. I added a test case to verify it works with pipes. > > > > > > At last, I can run this command without a problem. > > > > > > $ perf record -o- -e intel_pt// true | perf inject -b | perf report -i- --itrace=i1000 > > > > > > The code is available at 'perf/auxtrace-pipe-v1' branch in > > > > > > git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git > > > > > > Thanks, > > > Namhyung > > > > > > Namhyung Kim (4): > > > perf inject: Use perf_data__read() for auxtrace > > > perf intel-pt: Do not try to queue auxtrace data on pipe > > > perf session: Avoid calling lseek(2) for pipe > > > perf test: Add pipe mode test to the Intel PT test suite > > > > > > tools/perf/builtin-inject.c | 6 +++--- > > > tools/perf/tests/shell/test_intel_pt.sh | 17 +++++++++++++++++ > > > tools/perf/util/auxtrace.c | 3 +++ > > > tools/perf/util/session.c | 9 +++++++-- > > > 4 files changed, 30 insertions(+), 5 deletions(-) > > > > > > > > > base-commit: 5670ebf54bd26482f57a094c53bdc562c106e0a9 > > > prerequisite-patch-id: 4ccdf9c974a3909075051f4ffe498faecab7567b > >
On 30/01/23 16:15, Arnaldo Carvalho de Melo wrote: > Em Fri, Jan 27, 2023 at 02:54:36PM -0800, Namhyung Kim escreveu: >> Hi Adrian, >> >> On Thu, Jan 26, 2023 at 11:22 PM Adrian Hunter <adrian.hunter@intel.com> wrote: >>> >>> On 27/01/23 02:19, Namhyung Kim wrote: >>>> Hello, >>>> >>>> I found some problems in Intel-PT and auxtrace in general with pipe. >>>> In the past it used to work with pipe, but recent code fails. >>> >>> Pipe mode is a problem for Intel PT and possibly other auxtrace users. >>> Essentially the auxtrace buffers do not behave like the regular perf >>> event buffers. That is because the head and tail are updated by >>> software, but in the auxtrace case the data is written by hardware. >>> So the head and tail do not get updated as data is written. In the >>> Intel PT case, the head and tail are updated only when the trace is >>> disabled by software, for example: >>> - full-trace, system wide : when buffer passes watermark >>> - full-trace, not system-wide : when buffer passes watermark or >>> context switches >>> - snapshot mode : as above but also when a snapshot is made >>> - sample mode : as above but also when a sample is made >>> >>> That means finished-round ordering doesn't work. An auxtrace buffer >>> can turn up that has data that extends back in time, possibly to the >>> very beginning of tracing. >> >> Ok, IIUC we want to process the main buffer and auxtrace buffer >> together in time order but there's no guarantee to get the auxtrace >> data in time, right? Yes >> >> I wonder if it's possible to use 2 pass processing for pipe mode. >> We may keep the events in the ordered queue and auxtrace queue >> in the first pass, and process together from the beginning in the >> second pass. But I guess the data size would be a problem. >> >> Or, assuming that the auxtrace buffer comes later than (or equal to) >> the main buffer, we may start processing the main buffer as soon as >> every auxtrace queue gets some data. Thoughts? That sounds like it would require figuring out a timestamp up to which there is Intel PT trace data in all queues. That would be very complicated. >> >>> >>> For a perf.data file, that problem is solved by going through the trace >>> and queuing up the auxtrace buffers in advance. >>> >>> For pipe mode, the order of events and timestamps can presumably >>> be messed up. >>> >>> For Intel PT, it is a bit of a surprise that there is not >>> validation to error out in pipe mode. >> >> What kind of validation do you have in mind? Checking pid/tid? Validation to kill pipe mode for Intel PT entirely. But a warning is ok. >> >>> >>> At the least, a warning is needed, and the above explanation needs >>> to be added to the documentation. >> >> Thanks, I'll add it to the documentation. > > Ok, so I'll wait for v2 of this patch series, Adrian, apart from what > you mentioned, are you ok with the patches, or a subset of them? The > first ones looks ok, right? Yes they are ok. > > - Arnaldo > >> How about showing something like this for pipe mode? >> >> WARNING: Intel-PT with pipe mode may not work correctly. Perhaps: WARNING: Intel PT with pipe mode is not recommended. The output cannot be relied upon. In particular, time stamps and the order of events may be incorrect. >> >> Thanks, >> Namhyung >> >> >>> >>>> As it >>>> also touches the generic code, other auxtrace users like ARM SPE will >>>> be affected too. I added a test case to verify it works with pipes. >>>> >>>> At last, I can run this command without a problem. >>>> >>>> $ perf record -o- -e intel_pt// true | perf inject -b | perf report -i- --itrace=i1000 >>>> >>>> The code is available at 'perf/auxtrace-pipe-v1' branch in >>>> >>>> git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git >>>> >>>> Thanks, >>>> Namhyung >>>> >>>> Namhyung Kim (4): >>>> perf inject: Use perf_data__read() for auxtrace >>>> perf intel-pt: Do not try to queue auxtrace data on pipe >>>> perf session: Avoid calling lseek(2) for pipe >>>> perf test: Add pipe mode test to the Intel PT test suite >>>> >>>> tools/perf/builtin-inject.c | 6 +++--- >>>> tools/perf/tests/shell/test_intel_pt.sh | 17 +++++++++++++++++ >>>> tools/perf/util/auxtrace.c | 3 +++ >>>> tools/perf/util/session.c | 9 +++++++-- >>>> 4 files changed, 30 insertions(+), 5 deletions(-) >>>> >>>> >>>> base-commit: 5670ebf54bd26482f57a094c53bdc562c106e0a9 >>>> prerequisite-patch-id: 4ccdf9c974a3909075051f4ffe498faecab7567b >>> >
On Mon, Jan 30, 2023 at 2:56 AM James Clark <james.clark@arm.com> wrote: > > > > On 27/01/2023 23:08, Namhyung Kim wrote: > > Hi James, > > > > On Fri, Jan 27, 2023 at 6:42 AM James Clark <james.clark@arm.com> wrote: > >> > >> > >> > >> On 27/01/2023 07:22, Adrian Hunter wrote: > >>> On 27/01/23 02:19, Namhyung Kim wrote: > >>>> Hello, > >>>> > >>>> I found some problems in Intel-PT and auxtrace in general with pipe. > >>>> In the past it used to work with pipe, but recent code fails. > >>> > >>> Pipe mode is a problem for Intel PT and possibly other auxtrace users. > >> > >> Just some info from my side: For Arm Coresight we ended up deprecating > >> pipe mode, then not supporting it altogether. First was when we added an > >> optional step to peek through all of the data to help with an edge case. > >> Then we added a requirement to receive a HW_ID packet before decoding > >> which necessitated the peek. You can't peek in pipe mode because you > >> need to be able to seek, so it's not supported at all anymore. > >> > >> For Arm SPE I never tested it with piped data. I suppose I could add a > >> test at some point, but I don't really see the usecase. > > > > Yeah, it'd be great if we can have a test for Arm SPE. > > > > Ok thanks I will put it on the list of things to do. > > > Anyway, my work env (Google) requires the pipe mode due to the > > restriction in disk usage. Without the pipe support, it's not possible > > to run `perf record` in production. > > > > Makes sense. Unfortunately at the moment with Coresight, because of the > lack of appropriate timestamps we're waiting for the end of the file > before starting decoding. So you're not really any better off using > piped mode, unless you have a lot more memory than disk space? > > Since this commit [1] and Arm v8.4 we can actually start making use of > the timestamps and do a streaming decode again. So I will also add it to > the list to look into that for Coresight again. Are you using an old > version of Perf or not using Coresight at all? I know Denis at Google is > using Coresight, but only with files rather than pipes. I'm not aware of usage of Coresight yet in my boundary, but others may be using it. > > One other thing, have you used the --switch-output mode to perf record > before? I would have said it would give you some of the benefits of > piped mode, but is more likely to work with Coresight. But last time I > checked it's not working either. Not very helpful I know, but something > to keep in mind. I don't think it'd work because it still occupies the same space. So far, the pipe mode worked well but I think it needs some more improvements. Anyway, thanks for your suggestion and review! Thanks, Namhyung
On Mon, Jan 30, 2023 at 9:36 AM Adrian Hunter <adrian.hunter@intel.com> wrote: > > On 30/01/23 16:15, Arnaldo Carvalho de Melo wrote: > > Em Fri, Jan 27, 2023 at 02:54:36PM -0800, Namhyung Kim escreveu: > >> Hi Adrian, > >> > >> On Thu, Jan 26, 2023 at 11:22 PM Adrian Hunter <adrian.hunter@intel.com> wrote: > >>> > >>> On 27/01/23 02:19, Namhyung Kim wrote: > >>>> Hello, > >>>> > >>>> I found some problems in Intel-PT and auxtrace in general with pipe. > >>>> In the past it used to work with pipe, but recent code fails. > >>> > >>> Pipe mode is a problem for Intel PT and possibly other auxtrace users. > >>> Essentially the auxtrace buffers do not behave like the regular perf > >>> event buffers. That is because the head and tail are updated by > >>> software, but in the auxtrace case the data is written by hardware. > >>> So the head and tail do not get updated as data is written. In the > >>> Intel PT case, the head and tail are updated only when the trace is > >>> disabled by software, for example: > >>> - full-trace, system wide : when buffer passes watermark > >>> - full-trace, not system-wide : when buffer passes watermark or > >>> context switches > >>> - snapshot mode : as above but also when a snapshot is made > >>> - sample mode : as above but also when a sample is made > >>> > >>> That means finished-round ordering doesn't work. An auxtrace buffer > >>> can turn up that has data that extends back in time, possibly to the > >>> very beginning of tracing. > >> > >> Ok, IIUC we want to process the main buffer and auxtrace buffer > >> together in time order but there's no guarantee to get the auxtrace > >> data in time, right? > > Yes > > >> > >> I wonder if it's possible to use 2 pass processing for pipe mode. > >> We may keep the events in the ordered queue and auxtrace queue > >> in the first pass, and process together from the beginning in the > >> second pass. But I guess the data size would be a problem. > >> > >> Or, assuming that the auxtrace buffer comes later than (or equal to) > >> the main buffer, we may start processing the main buffer as soon as > >> every auxtrace queue gets some data. Thoughts? > > That sounds like it would require figuring out a timestamp up to > which there is Intel PT trace data in all queues. That would > be very complicated. Yeah, I don't think it's a simple change. Just think out loud how we can handle it. I'll think about it more.. > > >> > >>> > >>> For a perf.data file, that problem is solved by going through the trace > >>> and queuing up the auxtrace buffers in advance. > >>> > >>> For pipe mode, the order of events and timestamps can presumably > >>> be messed up. > >>> > >>> For Intel PT, it is a bit of a surprise that there is not > >>> validation to error out in pipe mode. > >> > >> What kind of validation do you have in mind? Checking pid/tid? > > Validation to kill pipe mode for Intel PT entirely. But a warning > is ok. I see. > > >> > >>> > >>> At the least, a warning is needed, and the above explanation needs > >>> to be added to the documentation. > >> > >> Thanks, I'll add it to the documentation. > > > > Ok, so I'll wait for v2 of this patch series, Adrian, apart from what > > you mentioned, are you ok with the patches, or a subset of them? The > > first ones looks ok, right? > > Yes they are ok. > > > > > - Arnaldo > > > >> How about showing something like this for pipe mode? > >> > >> WARNING: Intel-PT with pipe mode may not work correctly. > > Perhaps: > > WARNING: Intel PT with pipe mode is not recommended. The output cannot be relied upon. In particular, time stamps and the order of events may be incorrect. Ok, will add this. Thanks, Namhyung