From patchwork Fri Jan 27 00:19:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 48996 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp563787wrn; Thu, 26 Jan 2023 16:28:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXshzRGgAfP7LwWAYDucV7V9t/9w7fLc3sV0lMwjpBAlkyIzOg2HpZP63/6FNr/0No1rJjJD X-Received: by 2002:a17:902:c94b:b0:194:acd1:6624 with SMTP id i11-20020a170902c94b00b00194acd16624mr50939728pla.61.1674779303856; Thu, 26 Jan 2023 16:28:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674779303; cv=none; d=google.com; s=arc-20160816; b=ZMeoRypAud3CJuzHlYVjeVyeCuW/jueMyoksGzg54ux1FWhYZFoFuA9gzAuq6uiX2W wJmzfvi/MQDWaGmZPohbBNzNkyn8+Jh4C3xHTA4Zgeyio+nL7FYYajYtnXpexs67bXtj /qhNgPYPpzQLGC9iQciXmgxux88fvQbqRoj0uZThF4f9R2VaR9+BNSraHQTeawiUbkuN XoGxoT+DvGpxHnFT9Lx0RL9vuwjPrp6k7debhvhdARfu7Wsb/Jl9DdwLYQbGR+V6cjro F9XReWlH9+KFm7UWmk4Fgc44ZWBZ6DjJG7MMKHoJXh9/PbNIN8/vfbOogT7+2O2AQrDU vsSA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=egmLJ0P+nkdiEwtD39Tt2932c4Qbx1PdrWuvIbe74LM=; b=lc6BfIYCe8WDTqlhR9tilzPwHHifkgn2pZT79jGB+jlRFOpaf5vfJOHcFRICYmKB+5 RaZGE0+Ae9VwcNWIgI8clu8/1yZTX14fREHW9lJVZibZdf42s5Ipt78CdMBZhIjgrqgk 3ZvQN6upUEPcFqEBS/kB+3I11zSYpDCXpk+8C3fjf2RmA0S1uwxEp2nYMm78ugTrhW1Y blr1z7mviku2nDyVEAVjls4oeNx1ALOwGiWm5fVlCw4dNIKQ/JB+OFVG1N2dd2S2wByF pAi6y+5wc+fVVYEq48mMSoJ91uDQ53POoHOHB9Z1o7mxE5YLhXVJz0h1UrBI0Tk/HL7r Xuxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ie0A8zcK; 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 j15-20020a170903024f00b00189b92d9921si3196048plh.313.2023.01.26.16.28.12; Thu, 26 Jan 2023 16:28:23 -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=ie0A8zcK; 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 S232867AbjA0AUi (ORCPT + 99 others); Thu, 26 Jan 2023 19:20:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232512AbjA0AUg (ORCPT ); Thu, 26 Jan 2023 19:20:36 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9460638661; Thu, 26 Jan 2023 16:19:57 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id m7-20020a17090a71c700b0022c0c070f2eso6313847pjs.4; Thu, 26 Jan 2023 16:19:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=egmLJ0P+nkdiEwtD39Tt2932c4Qbx1PdrWuvIbe74LM=; b=ie0A8zcKF9j7TIX3g9qM+PTdY7uRmKhAZxVglnX5CBztBqYSwewEz/OYuEi4robx5R 1p1Pnm24h61+vaD8Hlpx4BzxToI05Abkb1Di3rnKD24EUlL5hzTrr7Ehl8qp2buU+OJc MA7qCpsl2MLSwRuFoRBdwxQaRtMzJsEWd9GljRL/xGL0nZ2ymNi6/y77nKyhrM1uf6uP e8AP+KVsYP4Myop9q6Ver4WM5TuJGpRedpH1iBjaXQcUvIsk36+l1jE6PyVU0zLIMOr9 AlGnEgwlARX9JN1qnUQCOjMK+Z0NGQIR3zYuZCOVpMffkw536QFyKgcw64bRU9gv8QtW oZIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=egmLJ0P+nkdiEwtD39Tt2932c4Qbx1PdrWuvIbe74LM=; b=ZPcM6/go/9sGsYOMz9hPUA0AQ/6NQL9F4B67/U6gzQuMLyEqVT6hW9MYOadLIeaORp HDmSLoH/atRbLo9xClVfEalkRJPNne00xqhFV+X3vMRvitkiH3GE+oe2Ki1FPG5GgTe+ qC6bMNUQ4bKT8443mmj7tA5HW+wLS+a0sCjTh0sT1b21yFkbwHwjE7VhAVAcDA/WZfBz 9NgTLPDJMgJkAh3jFxYg0lTZfUuxtCZLuziSFORiBAVr5DddDNCL/nGKr92sfgjxipCx lgt58nd6Fof1Ny9Og8TuGJAlhSgSmElWMfDBS7u1pEsDYSEAgqyU94rWGaV2prWePBSb QXsg== X-Gm-Message-State: AFqh2kosUeg/Yv591aM1kTyIvJbrzAOsAv+L5kSwVKqKAYdzoMpXpu9I AOTLSrzCGVluQ12+Teuyg5E= X-Received: by 2002:a17:90a:aa83:b0:226:102:2dc9 with SMTP id l3-20020a17090aaa8300b0022601022dc9mr39248610pjq.14.1674778796351; Thu, 26 Jan 2023 16:19:56 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 16:19:55 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa , Adrian Hunter Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , linux-perf-users@vger.kernel.org, Leo Yan , James Clark , Stephane Eranian Subject: [PATCH 1/4] perf inject: Use perf_data__read() for auxtrace Date: Thu, 26 Jan 2023 16:19:48 -0800 Message-Id: <20230127001951.3432374-2-namhyung@kernel.org> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog In-Reply-To: <20230127001951.3432374-1-namhyung@kernel.org> References: <20230127001951.3432374-1-namhyung@kernel.org> MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756133383208903246?= X-GMAIL-MSGID: =?utf-8?q?1756133383208903246?= In copy_bytes(), it reads the data from the (input) fd and writes it to the output file. But it does with the read(2) unconditionally which caused a problem of mixing buffered vs unbuffered I/O together. You can see the problem when using pipes. $ perf record -e intel_pt// -o- true | perf inject -b > /dev/null [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.000 MB - ] 0x45c0 [0x30]: failed to process type: 71 It should use perf_data__read() to honor the 'use_stdio' setting. Fixes: 601366678c93 ("perf data: Allow to use stdio functions for pipe mode") Signed-off-by: Namhyung Kim --- tools/perf/builtin-inject.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 3f4e4dd5abf3..f8182417b734 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -215,14 +215,14 @@ static int perf_event__repipe_event_update(struct perf_tool *tool, #ifdef HAVE_AUXTRACE_SUPPORT -static int copy_bytes(struct perf_inject *inject, int fd, off_t size) +static int copy_bytes(struct perf_inject *inject, struct perf_data *data, off_t size) { char buf[4096]; ssize_t ssz; int ret; while (size > 0) { - ssz = read(fd, buf, min(size, (off_t)sizeof(buf))); + ssz = perf_data__read(data, buf, min(size, (off_t)sizeof(buf))); if (ssz < 0) return -errno; ret = output_bytes(inject, buf, ssz); @@ -260,7 +260,7 @@ static s64 perf_event__repipe_auxtrace(struct perf_session *session, ret = output_bytes(inject, event, event->header.size); if (ret < 0) return ret; - ret = copy_bytes(inject, perf_data__fd(session->data), + ret = copy_bytes(inject, session->data, event->auxtrace.size); } else { ret = output_bytes(inject, event, From patchwork Fri Jan 27 00:19:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 48997 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp564021wrn; Thu, 26 Jan 2023 16:29:09 -0800 (PST) X-Google-Smtp-Source: AK7set+ZhIaMifY+Mc/xnPQucCotgRPfKQfRazOtl8vS4I8KnI57VPEv88GHHjxMuFyX/8/8qhky X-Received: by 2002:a17:90b:388e:b0:22c:2f80:9b8b with SMTP id mu14-20020a17090b388e00b0022c2f809b8bmr3598087pjb.20.1674779349687; Thu, 26 Jan 2023 16:29:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674779349; cv=none; d=google.com; s=arc-20160816; b=sNmklMXSvBgNOA/Soy8c30Ay6kNjwth9j+YKxD78t+yPxt0xgeGghmBJUu21k45Obu WMUFnscHZZ2ZZw91bfCug8Jl0v3jevtT3jyDAqBlbrJp13Sg/lJqF0iL68AXqkqftKFz FKofnBSOu+reAFMt9ZW3CVxZKi+wuL9XljvwNHnzIXXQotM+EmJapGNfkzUAxXUoJwT+ 9y7/BJedUMLI/LTc1CtZst70y8nCPqfFKNz+ZPUvAK9QLeUYhWsecG4B+7mv+wSxZxe1 Kuvlxu8cSlmyC2k47Y53zOYSDLeyo72k4JSLLI4jSy5OHrPDTqW3AeCUV1m/5aUrzD+G a2ow== 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 :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=l7c2k3JxwqHMLdDHaXxYBGINQa6xWp1S+b3x47KyaT4=; b=V5ZEzZ2ekF/Y0F7kEI7LWcjP7Za3XrBSw0xGkF6nhutuEV9rsweqZaN0cWSp6PfCGL 6jqbw91e0fesMlV7f45y1bzpln2Flz4qN5Aqb1CAia9eFwObEbBLWbM4NQOy9rBvzNwi HIS1W9JLww6kwSP0hOhViHTH0VadSW3uW9HE1/6XzQeGBUQ/EKfAjiFSeeHlcpv1/omz D1Pnd8yuIxMEAZU20BUXDy7UCnvSO7MaGC7PNqOGFJSDm3/Ak82len5+L6y5wOA3Ty+U V9Yrx6oILcaD50uI+9G9y+IWagfRYF9r39hJuf1CYU0QqlSfJMZJzqGkUc4UlO5nefdu USsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cLcixg53; 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 v4-20020a17090a458400b0022618cab553si6464425pjg.73.2023.01.26.16.28.57; Thu, 26 Jan 2023 16:29:09 -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=cLcixg53; 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 S232930AbjA0AUl (ORCPT + 99 others); Thu, 26 Jan 2023 19:20:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbjA0AUg (ORCPT ); Thu, 26 Jan 2023 19:20:36 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF01214496; Thu, 26 Jan 2023 16:19:58 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id jm10so3386705plb.13; Thu, 26 Jan 2023 16:19:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=l7c2k3JxwqHMLdDHaXxYBGINQa6xWp1S+b3x47KyaT4=; b=cLcixg53FrGqCZqahgbnaolNOkBAznVNgsgxBHrcm79QRm3mpWoYXfT3kM+6YfFd4o v9giZWvcrCVZlqcUCzBDv7xLXsZWBtq9RjcRotaic1QfAoo4gO7L0yeCDJLrIDca+AiJ uXsiQ3C3MKlY7JAMHh71O6x5XN5YgAwbo3geqdiE8GTfW8WvLfs/E6Vb4sEJ5m5DolIy LmKjZygNcmGn2ylmsot4kBqjfdbXO1yvjCCUoJKYx5k7fZNbcl2Ifr5p6VpHalkGy9Ul d931pvRMHlY3URQTdg2Xh8GkmTbKMfnubK1vevbZTHC/9BNs4s0F9UnqiBS4jqEyZYWa c2Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=l7c2k3JxwqHMLdDHaXxYBGINQa6xWp1S+b3x47KyaT4=; b=OFLqVa4WuKx9w8o0hc9xRcaDLlif43k8noQCDyjPevP6IJh8owO6XrsPqpT9LworF9 PH0UQF7vgztKPijGtMN8EUBKYnZ3C6ptauCvQeD5ipgFsfADiLDt9VX/x7zk1nZsxsXD KbozIrs9TfOt5BiH4M5Y3U5GO4DxMYWGn3W+FHwLiHxxecfvDahdLz3Td/C/4lyI2lX8 QNq0HQxlWc+llWWcB1MGuw3lNPh8lql3abi04cw4Xgvt/P732wdYtL75Te7H0DrjLpPl 7Xfc1sqo9ECL41TX2SZ9dXRf0dN8nKy+7DHypd2WNGVk0xLX29Y1rLrs5H42YcGLS0Bq Rlww== X-Gm-Message-State: AO0yUKVNDx6wvys7zQ+tO5h6jfUhQ5xOsyvkcpXTCOJaOmIDxznjowJo A+549oOiRA53MYIQEEa5lUw= X-Received: by 2002:a17:90b:3b52:b0:22c:b32:4806 with SMTP id ot18-20020a17090b3b5200b0022c0b324806mr4628545pjb.27.1674778797587; Thu, 26 Jan 2023 16:19:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 16:19:57 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa , Adrian Hunter Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , linux-perf-users@vger.kernel.org, Leo Yan , James Clark , Stephane Eranian Subject: [PATCH 2/4] perf intel-pt: Do not try to queue auxtrace data on pipe Date: Thu, 26 Jan 2023 16:19:49 -0800 Message-Id: <20230127001951.3432374-3-namhyung@kernel.org> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog In-Reply-To: <20230127001951.3432374-1-namhyung@kernel.org> References: <20230127001951.3432374-1-namhyung@kernel.org> MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756133431528686343?= X-GMAIL-MSGID: =?utf-8?q?1756133431528686343?= When it processes AUXTRACE_INFO, it calls to auxtrace_queue_data() to collect AUXTRACE data first. That won't work with pipe since it needs lseek() to read the scattered aux data. $ perf record -o- -e intel_pt// true | perf report -i- --itrace=i100 # To display the perf.data header info, please use --header/--header-only options. # 0x4118 [0xa0]: failed to process type: 70 Error: failed to process sample For the pipe mode, it can handle the aux data as it gets. Fixes: dbd134322e74 ("perf intel-pt: Add support for decoding AUX area samples") Signed-off-by: Namhyung Kim --- tools/perf/util/auxtrace.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index c2e323cd7d49..d4b04fa07a11 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -1133,6 +1133,9 @@ int auxtrace_queue_data(struct perf_session *session, bool samples, bool events) if (auxtrace__dont_decode(session)) return 0; + if (perf_data__is_pipe(session->data)) + return 0; + if (!session->auxtrace || !session->auxtrace->queue_data) return -EINVAL; From patchwork Fri Jan 27 00:19:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 48999 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp566317wrn; Thu, 26 Jan 2023 16:35:11 -0800 (PST) X-Google-Smtp-Source: AK7set+S36PdbQlbHAd012EDvmpOnnehM8+PeI1vE7kvldLW9KflE0KAV5XGnwWZN5d/SSYZq6lw X-Received: by 2002:a05:6402:5114:b0:4a0:a850:176c with SMTP id m20-20020a056402511400b004a0a850176cmr11636308edd.11.1674779711111; Thu, 26 Jan 2023 16:35:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674779711; cv=none; d=google.com; s=arc-20160816; b=orbzYmKB6Oo6d9KCPEwc743I0gQpa8QKbVvDQC2HHBarJh8RYkgGNt6kSMoJB7cF+y P2qB43VWImF663AVB2p0K2H04xJP+iXuZXVqSrnbKSiV+j5yFcfY6FsX9BinZN18fEUP XRMnIpKKrCFgFJbIChpV4eX3Bob25/35wL+7fPWfiPJhMt9p4QyXMB+EYeNPWMwR3yAD 4oNjGIkfvhuLHU9Cyyzney+vV+iOVJn02o5NMt7kfah0LXBsUJZOFTEwRCG6or5fgZAs eBOxKGAJw5NQeK0gQSV1MXnao4KnnC2EHVQQzk+juYNhELiFTFWHW8YqhYPObQsFj/jI LAhQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=mLtqR2vTJPsyXL+Kk95QTPsvoc9EHhO85tO4NsvnR/s=; b=RXMRQuCphLi6zeImzWxOIJOQc6anOabD9iHCixTbE959SehaL/POWxobo9inPUyCHt NB+K0/OY6nklVr1bUc4me0UQz2zinYs5eb1hjDs+/18t/sCko+KBhilDNVO+rlES8E0o 19/McWzv50BkD5RRzlGtmj4pbmntzALiezIUNR6Y3qltCFOKGpbGy3ktMa0OBkO/4ZNU pyOij1hihh1fC2cWjZ3XDAVrqWFYHlH5NH8ES1nx2F6wnicLjp5b5tTluTLbpjYMRbBV odrCJeLOXIX66t0VQ/y6D/3CUyHX7fwaOwHgdlk4upt+iXvXRR2Zz18dc3Ybs2YBuaCW Nu4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=D4iBm1Ol; 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 e11-20020a170906748b00b0086b5808d6b4si2873059ejl.717.2023.01.26.16.34.46; Thu, 26 Jan 2023 16:35:11 -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=D4iBm1Ol; 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 S233055AbjA0AUp (ORCPT + 99 others); Thu, 26 Jan 2023 19:20:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232760AbjA0AUg (ORCPT ); Thu, 26 Jan 2023 19:20:36 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CB3D2B60F; Thu, 26 Jan 2023 16:19:59 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id jm10so3386744plb.13; Thu, 26 Jan 2023 16:19:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=mLtqR2vTJPsyXL+Kk95QTPsvoc9EHhO85tO4NsvnR/s=; b=D4iBm1OlCFLot8f30ioPALHeV1nPkB9M+r03xCKGGLDWICpvxtoxUhGC8wgbGo5xC4 ZMveWAISnon9BSgXnVGxveZ3krPkz6pOsZYanbW4rB9BDr0c2PbODYapGNewpnxwiRip /fAzDiNktmmGLgQojkqqHPKTJ3reuVA74595ClD6E4vrxAojTM4KHcOrLTz7DDS5W7D2 r3/Ie7MgvXLQUUem4YNRel1ZEQMdJ42UkEpBWJeaFJAN8YT93KJ+/Fq9eMvVaCISTNg7 Qj7WDsa0hPFR/59/wY4Kcp2Gjqngo2rzvawG+q7mMdBPEafKbvWtRn4CUpLkbv/bluVa 3o2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mLtqR2vTJPsyXL+Kk95QTPsvoc9EHhO85tO4NsvnR/s=; b=xdV1rriFLEHKtg+bz7BRQjcf10RL2rMsZNb0T+FRInY3oFeaDPn4IHAWbALirBSENt 2vUs++JMGFiATm4bNaIOTo9qX6BJm/4pYGqM4smFGw4oqxjAfwE+Sg3cG/nWeLFJgF0O +BuwtjUiOG9KVoSG8YscPIGUBJ7fpezCs+leG+ZjsN/l30FoQ1yhSDA7ZZivOakvvxHq 4E4Lbdqo6ASll8QtvYNNIrjufoy48ewHswYBdq63GccxMjkE7qtx84Ze1zaZlArClrUP CnCISzUP8sc8HNyt592y0S71nbPYPDn4MDUwXxiClI5GQX+ZKiCMPTnHsxnf+U6aE2SF 3ixg== X-Gm-Message-State: AFqh2kpbIlxzo9it9etDmFgc0y6wd+zJCPQM2OOBOH04ZCxKSfSvEXXj Voh95dnV/FoHT6pfXbocFOU= X-Received: by 2002:a17:90b:4d8e:b0:229:ade0:d0cf with SMTP id oj14-20020a17090b4d8e00b00229ade0d0cfmr37357783pjb.3.1674778798772; Thu, 26 Jan 2023 16:19:58 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 16:19:58 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa , Adrian Hunter Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , linux-perf-users@vger.kernel.org, Leo Yan , James Clark , Stephane Eranian Subject: [PATCH 3/4] perf session: Avoid calling lseek(2) for pipe Date: Thu, 26 Jan 2023 16:19:50 -0800 Message-Id: <20230127001951.3432374-4-namhyung@kernel.org> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog In-Reply-To: <20230127001951.3432374-1-namhyung@kernel.org> References: <20230127001951.3432374-1-namhyung@kernel.org> MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756133810355983569?= X-GMAIL-MSGID: =?utf-8?q?1756133810355983569?= We should not call lseek(2) for pipes as it won't work. And we already in the proper place to read the data for AUXTRACE. Add the comment like in the PERF_RECORD_HEADER_TRACING_DATA. Signed-off-by: Namhyung Kim --- tools/perf/util/session.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 7c021c6cedb9..fdfe772f2699 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1699,8 +1699,13 @@ static s64 perf_session__process_user_event(struct perf_session *session, case PERF_RECORD_AUXTRACE_INFO: return tool->auxtrace_info(session, event); case PERF_RECORD_AUXTRACE: - /* setup for reading amidst mmap */ - lseek(fd, file_offset + event->header.size, SEEK_SET); + /* + * Setup for reading amidst mmap, but only when we + * are in 'file' mode. The 'pipe' fd is in proper + * place already. + */ + if (!perf_data__is_pipe(session->data)) + lseek(fd, file_offset + event->header.size, SEEK_SET); return tool->auxtrace(session, event); case PERF_RECORD_AUXTRACE_ERROR: perf_session__auxtrace_error_inc(session, event); From patchwork Fri Jan 27 00:19:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 49007 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp571836wrn; Thu, 26 Jan 2023 16:53:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXshsv/4Gp998oY0Cok/X3x/4vxuI77D/ww1QaPSblTR+tTqkANARd+EPTuZ+L/CTGFRzo8J X-Received: by 2002:a05:6402:298e:b0:496:6a20:6b61 with SMTP id eq14-20020a056402298e00b004966a206b61mr41727270edb.22.1674780833452; Thu, 26 Jan 2023 16:53:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674780833; cv=none; d=google.com; s=arc-20160816; b=TfLIWtVh/VrGsDedd0Pm0vqXZCrnCxrJYtC/bejhl1q7ly28qBb4l/VKnO3ww3Bwqd 9NtjHUbLz8ZiogOXqciPP1IhGI8Pd1cbi6cHyRvEaybA3M/fuswZWr+/FR6Mr43sBkN9 onNNsG3UEVaVnYdVWPhWVT5PbICnBNdr1zwQpfkJAJTItOdlF4Z26+zEdAEKAkoAtVcr Ao0D6Idl2XPcnjl1h08QP4Uf8MEcGZnVTncOdfWLBeVJLGuSHoRYzrr1cwm+pqYQQQ0D ANAxoqKF1rRR9B92MMlla10uoMAqdpQO8sD7klCF79yS8iOWxeABcqy0f+sXcHsAaXTp KyXw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=HRrV7TjTlPA/BkPaOPUYQ8wwbHiOpKT0qv7GK3Tslrg=; b=OFPsqK47QzbNiOQiERjYN3YqsDcjsTY66VvzlcHs3OVSVqjmvYO/GSqeAUjEFKZVYS aapyK0wsFCpmcYACj1xQq903PHwvAmJLxY9SzUADdTsCMQJMHIVOgwfL+5Lg1gFlwTFD 9Ir88ShHxw7fMz75e/EwdRKnIOY5UvLE5ZhuUHnsnghge1HK72xojTUQRPOsHYkyn3Xt 6+mRvxCYqQvJeSSv9jY3Y35+lpHIvAk+mypvP6GQYK8IL/fizFLY1BxjZUL231u7Zicd LsRcx8CNZ3qLUO20L3xlTRL+bqdF/QIvaq74oCNOXwuwj4trD0nxAj5ZVO6SP3XmPo9A 4ihQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JPVvykV4; 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 ch14-20020a0564021bce00b0049e07ea3937si3030768edb.492.2023.01.26.16.53.28; Thu, 26 Jan 2023 16:53:53 -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=JPVvykV4; 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 S233111AbjA0AUs (ORCPT + 99 others); Thu, 26 Jan 2023 19:20:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232911AbjA0AUj (ORCPT ); Thu, 26 Jan 2023 19:20:39 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EB0A3B0EC; Thu, 26 Jan 2023 16:20:01 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id z1-20020a17090a66c100b00226f05b9595so3398828pjl.0; Thu, 26 Jan 2023 16:20:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=HRrV7TjTlPA/BkPaOPUYQ8wwbHiOpKT0qv7GK3Tslrg=; b=JPVvykV4MhgTf7Tw6GyypSnxNUhsiEiGHYhsEUqj/dj/oY4wZ6DjIqykUAAQRoi9aM etlaTcQ17oDUiRwR/JpFDZcivnt3IE+Fydm9QJOrqIncAHnAhvNAJ0YFCXzUjLmKGFko SnTKNCgB+gb7avdiA1X8r17hkBzJBoGAsR3ZtaYrADLWrWU2OLYh30c69NfAg7QpvbNB C+5DEdUXbdHap9B0da+1KD03J5KYkgx4EgtR0rkY53+7do8BysYsPzKZBzrqyK64JJn7 O0gXL5ApOoj8XukHkGKGrgrg8YmwkAaNq7ddEWxAXB3UgpR+MSnRzf9i4CO7OzlyELzY RfCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HRrV7TjTlPA/BkPaOPUYQ8wwbHiOpKT0qv7GK3Tslrg=; b=xp5EdG48cM9z/BuIRqcyhZUwxhC2Kg7yU0s81HB2jcvp4Kqp4a9XwutyzicPgpGWUG +QKmB5NSS+lDe7YN2TIUkQb8RGmEQa9Wr0iuOdyA/s0Mo5EKjRi3iHZU56GnxLu+F2Nl /qa8898CMSniDzzs0w1c8In1vaJnFebZVyi52KaVqjoepIUZtl5Bu7PGvpgjBnkQWm6w n/7IK0gwId3Y7GNGExQrd9cV16hkvN7wD3GDlpdDsbMWSxuvr8/LLyBr4pcnBh679RYx J7WXEW7T7VkuXxp61EdfFR0N/il6ocszCBHJ75/X/CWPrnj4bcXkeoPJOGcfrWXu7r9+ Iv4w== X-Gm-Message-State: AFqh2krsrufWwEGXxGATq2YiEjlCZoODNA9ULMFDC5XTnqejZFZWrxaB +vzLRtFPXc615XSnD8rbOow= X-Received: by 2002:a17:90b:1c0e:b0:22b:b5c7:4fc with SMTP id oc14-20020a17090b1c0e00b0022bb5c704fcmr25339679pjb.46.1674778800033; Thu, 26 Jan 2023 16:20:00 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 16:19:59 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa , Adrian Hunter Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , linux-perf-users@vger.kernel.org, Leo Yan , James Clark , Stephane Eranian Subject: [PATCH 4/4] perf test: Add pipe mode test to the Intel PT test suite Date: Thu, 26 Jan 2023 16:19:51 -0800 Message-Id: <20230127001951.3432374-5-namhyung@kernel.org> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog In-Reply-To: <20230127001951.3432374-1-namhyung@kernel.org> References: <20230127001951.3432374-1-namhyung@kernel.org> MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756134987432992625?= X-GMAIL-MSGID: =?utf-8?q?1756134987432992625?= The test_pipe() function will check perf report and perf inject with pipe input. Signed-off-by: Namhyung Kim --- tools/perf/tests/shell/test_intel_pt.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/perf/tests/shell/test_intel_pt.sh b/tools/perf/tests/shell/test_intel_pt.sh index f5ed7b1af419..4ddb17cb83c5 100755 --- a/tools/perf/tests/shell/test_intel_pt.sh +++ b/tools/perf/tests/shell/test_intel_pt.sh @@ -620,6 +620,22 @@ test_event_trace() return 0 } +test_pipe() +{ + echo "--- Test with pipe mode ---" + # Check if it works with pipe + if ! perf_record_no_bpf -o- -e intel_pt//u uname | perf report -q -i- --itrace=i10000 ; then + echo "perf record + report failed with pipe mode" + return 1 + fi + if ! perf_record_no_bpf -o- -e intel_pt//u uname | perf inject -b > /dev/null ; then + echo "perf record + inject failed with pipe mode" + return 1 + fi + echo OK + return 0 +} + count_result() { if [ "$1" -eq 2 ] ; then @@ -647,6 +663,7 @@ test_virtual_lbr || ret=$? ; count_result $ret ; ret=0 test_power_event || ret=$? ; count_result $ret ; ret=0 test_no_tnt || ret=$? ; count_result $ret ; ret=0 test_event_trace || ret=$? ; count_result $ret ; ret=0 +test_pipe || ret=$? ; count_result $ret ; ret=0 cleanup