From patchwork Sun Jul 21 20:21:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13738097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98C05C3DA5D for ; Sun, 21 Jul 2024 20:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=P8AxCup+qi1rBagPvvcQUgFVS03u9/5ZoMRnfXwa1WQ=; b=gF7AITblXmPwYs0sF9+s2blcBH 7Mvg39U2YjzMV84l4i6DmQmsHbxI1Sdcu9+Jq2AXc+Mo2wyJEQDrsK/LKq78atExxyXGTYiPERC7P UMdDsJhmZoE6498ULamKizvQM5yHLoWwjHYx5AisgGcw7VVQii/jVtIrfBx8/7hMqncHnuvZrQbmH Nt9tR2q/GXz4TOHiYfvc7CWssXxuuv1oJWgenV75zbCTmNFwt3vRNo+PSUIvbIrsg7zhZ1r0qRsYG +sjdFEAzcFV52RVBuBnaqUIcDva+DxnvlhJg/71xYqW5WvIWmwUa1Sk3/OZbcW9lJpb1iAfZ+Upxq GYTGdphw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVd5S-00000007VFo-0ls5; Sun, 21 Jul 2024 20:23:18 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVd3v-00000007Ugl-08zH for linux-arm-kernel@lists.infradead.org; Sun, 21 Jul 2024 20:21:44 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A51D6FEC; Sun, 21 Jul 2024 13:22:06 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B51033F73F; Sun, 21 Jul 2024 13:21:38 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Adrian Hunter , James Clark , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Jiri Olsa , Mark Rutland , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 4/6] perf auxtrace: Iterate all AUX events when finish reading Date: Sun, 21 Jul 2024 21:21:11 +0100 Message-Id: <20240721202113.380750-5-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240721202113.380750-1-leo.yan@arm.com> References: <20240721202113.380750-1-leo.yan@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240721_132143_144106_42A9DE21 X-CRM114-Status: GOOD ( 14.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When finished to read AUX trace data from mmaped buffer, based on the AUX buffer index the core layer needs to search the corresponding PMU event and re-enable it to continue tracing. However, current code only searches the first AUX event. It misses to search other enabled AUX events, thus, it returns failure if the buffer index does not belong to the first AUX event. This patch extends the auxtrace_record__read_finish() function to search for every enabled AUX events, so all the mmaped buffer indexes can be covered. Signed-off-by: Leo Yan --- tools/perf/util/auxtrace.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index e2f317063eec..95be330d7e10 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -670,18 +670,25 @@ static int evlist__enable_event_idx(struct evlist *evlist, struct evsel *evsel, int auxtrace_record__read_finish(struct auxtrace_record *itr, int idx) { struct evsel *evsel; + int ret = -EINVAL; if (!itr->evlist || !itr->pmu) return -EINVAL; evlist__for_each_entry(itr->evlist, evsel) { - if (evsel->core.attr.type == itr->pmu->type) { + if (evsel__is_aux_event(evsel)) { if (evsel->disabled) - return 0; - return evlist__enable_event_idx(itr->evlist, evsel, idx); + continue; + ret = evlist__enable_event_idx(itr->evlist, evsel, idx); + if (ret >= 0) + return ret; } } - return -EINVAL; + + if (ret < 0) + pr_err("Failed to event enable event (idx=%d): %d\n", idx, ret); + + return ret; } /*