From patchwork Tue Jan 31 02:33: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: 50575 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2516967wrn; Mon, 30 Jan 2023 18:36:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXur+oH3lWwV4pm4tfpvolS9Pg/MmHgW3fqAOYPu0DPC97fwmEsfvOmomQtuTFIZfl/qMvkV X-Received: by 2002:a17:907:3e18:b0:84d:3403:f4f2 with SMTP id hp24-20020a1709073e1800b0084d3403f4f2mr69076463ejc.62.1675132561743; Mon, 30 Jan 2023 18:36:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675132561; cv=none; d=google.com; s=arc-20160816; b=FywhvFyBaDmWA/PCno4yKZXR/PhYjaYrJ/vMarXbZgfTnkuxIDh+vCDE3H6Nam7wkd FhxmtAJwWu/+YDkQOwZWJ7CZ86AYurSmexMC+TNk0o45jUVdNlnufzYBfbZkvVQNLB7Q 0cJPHHLEXKyhE5tvuNqZ4WUiEM+MCk4IQ8ZLDApQ2F+ftgqb65I5zLQm3VcHV0alPE0M iSUeBRn9gkKeLTC/B+FrhjmsDkmuDXmK33cIray4VcNERuwJlZjOcuw80lyt7+1rNnEV XV7r5WBpKHUQxcH2TFF5eaasWd4zpRxehyH9Wb1uB0UPSZAw2NlUqBMtauah2VXWJxBT /Esg== 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=yCu/OJvZgrHmpfb4wOiCy+fL/exx0kcJ6xVqf60vg6E=; b=BBlEWPxBazIDHgXSj18kSRw3AzyjlTbU8Let85dr5IPe7YvnwV4HZqf18vixD7hU+q Aud8ue6P2lfL04JqmMwrluppJNrp2UvPp6x2vCFE3SWZqr+r4pLGHDqSaxIEoqcw9dpV QtyRkYjfoErsZskDAguEJjfEjzLvtOQtAaXyaASZ8MoMvBgwIPrOU5iTNVGwppCUgE1Z MDC/W0FX7gWJFESfVhNPwxcSNihZPB0UXXNf6+xi0v1jatd4u3qWA+roDnyJhbnrocV/ ezp8R2mRGnNTnA6vOSPfaKr09wEL0vOKgW2t650ANk/LhKsqXl/T4030xIvqDSMmjn0I +B9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EgbWRsq6; 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 h22-20020a17090791d600b00878529e9d49si8548078ejz.573.2023.01.30.18.35.38; Mon, 30 Jan 2023 18:36:01 -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=EgbWRsq6; 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 S230138AbjAaCeN (ORCPT + 99 others); Mon, 30 Jan 2023 21:34:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbjAaCeF (ORCPT ); Mon, 30 Jan 2023 21:34:05 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 933243346C; Mon, 30 Jan 2023 18:33:58 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id d3so13625801plr.10; Mon, 30 Jan 2023 18:33: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=yCu/OJvZgrHmpfb4wOiCy+fL/exx0kcJ6xVqf60vg6E=; b=EgbWRsq6rbwJbO0WuPuCoYZ6aLWhZ5pnB//zXVtrgvkkPl5AU4kylWRecsWuSayikh sF7B8CjKhpu3E6Fg3kMqGQH+4b99eBmtl02mvKwRxOd9dEOEnY+4RZ3qwVbQf/pNJIzq S38ioAC+VkrzSvXCWh7C6hwDlVe6yC2N5INJ+oJn94dx4seBVmafKJPRSaQ68tM9dWIC C/vi5ctj8pM7Z0drawFJ2Spz07IMbTpePPZc9QKq/lyn9a708OcAmbzsp+YSqPY+qrQz 7VFWkpaWCsYwargAbQJPBbx/ZsSgDFrm/byUV/VUysoh4Yn8fy7Aw3EKkuYRDXseq9T5 FbJg== 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=yCu/OJvZgrHmpfb4wOiCy+fL/exx0kcJ6xVqf60vg6E=; b=zXJ5ElRb5S5c0EpKzh5U6YOFmsfF9vpVsLAFKmYiLFJafgXs2b0DEv20jJSwOSJb+/ 4gVstBAd+gTFJ0kRer7laUf2GDzHwgoebm0ivieZrwVFcvtXX20eIPgi323ecOBzZ0d2 rMLVkoO6OBhdTlfhy50xmBR48RPVB2OHofqg37wkm6dsl874quqOu79otLNUK8ZGj/Wu 4JhpOS3WrQapTx639FUg+SGHXb8ZKEK67jw/gXk1ac42KUXzkywMwf6v5qwcBUkNuZcZ YbtkiLLPhWEQxRcfQYkD/fv4QgukN/Kum9g8GD6GgCQSt7nKqmgQGEHmCvpcTu6eAReb Vy4A== X-Gm-Message-State: AFqh2kqW/YcSB20P64YxbLeBnvAlbm6bAkT823U5COnDUC1RlGxQI+Qc fnulQi3XwHM7Im1I/fh1ruk= X-Received: by 2002:a17:90b:1e0f:b0:22b:bcb7:610c with SMTP id pg15-20020a17090b1e0f00b0022bbcb7610cmr39986773pjb.44.1675132437475; Mon, 30 Jan 2023 18:33:57 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:ff0:3f41:4035:c56c:92cc]) by smtp.gmail.com with ESMTPSA id u13-20020a17090a6a8d00b00228f45d589fsm7640582pjj.29.2023.01.30.18.33.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 18:33:56 -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, James Clark , Leo Yan , Stephane Eranian Subject: [PATCH 3/4] perf session: Avoid calling lseek(2) for pipe Date: Mon, 30 Jan 2023 18:33:49 -0800 Message-Id: <20230131023350.1903992-4-namhyung@kernel.org> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog In-Reply-To: <20230131023350.1903992-1-namhyung@kernel.org> References: <20230131023350.1903992-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1756503800754567823?= X-GMAIL-MSGID: =?utf-8?q?1756503800754567823?= 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. Reviewed-by: James Clark 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);