From mboxrd@z Thu Jan 1 00:00:00 1970 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 4210EC3DA5D for ; Mon, 22 Jul 2024 16:00:50 +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: Content-Type:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XFgqAHpNCihuVSA9Ok4TH/FUqAMjI93jdr7OFAGWMtc=; b=Rmh3hjvgIhCbEHqLV8zBVNFtqQ RMoouoiXHx9lb1pjUAz0MGPb5vi6iPb5Grjl+99a9BJkTn1xM2q26lGEPkHK+UW/NZ64eG4hwHd/q eLB6p3NUayPw6wYcEY4z87kOLcUsHY+ffQy1Yw0eieHMgH9A5qPaMl2nLtdKYD0ieYPMNIVBNOFnE 54TzcFGMOz+vJA8D9NcirR12IzH31c6sQseYjUVF6Zk/PdZpCrVOAQAszWHDRyAHKfbSc5730BI1Y 0Azl7imhODyn3xFuCXCfggrXrzjqgurxCihJc9iSEgoVGMmND9Dc8/NC22YjkP0L6DWmWICi3eb7u jQawBdxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVvSo-0000000A19y-49D7; Mon, 22 Jul 2024 16:00:38 +0000 Received: from mgamail.intel.com ([192.198.163.7]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVvS9-0000000A0xT-0cfx for linux-arm-kernel@lists.infradead.org; Mon, 22 Jul 2024 15:59:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721663997; x=1753199997; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=nUgCygFc78VrkghKhjaJzXj8pZRWehGzELrz5XopRSk=; b=mwrY7G8FYAmtE7QgK1z+8nfF3jBTjVcOsmBsHdyRfrNEIF9eqgYGatnE ArCSsivVIqyv+fpQuHpVxvaHeBcvc6yh+VF/S57vtglwsMlhA1a8P5kjP 3C6Fyt/G+cpUqxYtu6gBOu3wUCTAFANfid44iem/Go/w12TO14kti41Qi pMPktq7PWYgzbYtWOemp42ge3/jzXJ7tSaVjrUie8zv2cvlyE+D7H7w1n bN/sS9NM1ZIdLyCQiqwyVCjj3v/AWa2QbL/qKc0QZw+mDl5Gzzp7cvRoU /+XNgY5e02/R/HSty75KmstOE22Fk+YjD8dARqEuqA34Uph2Z/466wQRf w==; X-CSE-ConnectionGUID: 3vJGrmLlTG2VKs7bzItL4g== X-CSE-MsgGUID: zD290/KVRKeg4bki9HlPAw== X-IronPort-AV: E=McAfee;i="6700,10204,11141"; a="44665730" X-IronPort-AV: E=Sophos;i="6.09,228,1716274800"; d="scan'208";a="44665730" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2024 08:59:53 -0700 X-CSE-ConnectionGUID: +N2Ol+KqQ/KE/35ZNVG4kA== X-CSE-MsgGUID: L8pt9t2zRvKaXl2hd6Yj6Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,228,1716274800"; d="scan'208";a="51931537" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.246.41.28]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2024 08:59:47 -0700 Message-ID: <1cb6fdfc-0405-4bfb-acd4-ed3b24744c8b@intel.com> Date: Mon, 22 Jul 2024 18:59:42 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 4/6] perf auxtrace: Iterate all AUX events when finish reading To: Leo Yan , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , 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 References: <20240721202113.380750-1-leo.yan@arm.com> <20240721202113.380750-5-leo.yan@arm.com> <9f08c5cb-fb4b-4994-9128-0484aa6c06d7@intel.com> <9f301b09-e040-456c-9bd3-6d5e96ebc8f4@arm.com> Content-Language: en-US From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: <9f301b09-e040-456c-9bd3-6d5e96ebc8f4@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240722_085957_231306_B3764186 X-CRM114-Status: GOOD ( 33.00 ) 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 On 22/07/24 18:09, Leo Yan wrote: > On 7/22/24 12:13, Adrian Hunter wrote: > > [...] > >> On 21/07/24 23:21, Leo Yan wrote: >>> 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 the type is the same, then there is no need to >> change the logic here? > > No, the type is not same for AUX events. Every event has its own type > value, this is likely related to recent refactoring. > > As a result, 'itr->pmu' only maintains the first registered AUX event, > comparing to it the tool will find _only_ one AUX event. This is why here > changes to use the evsel__is_aux_event() to detect AUX event. > >> Otherwise, maybe that should be a separate patch > > Could you explain what is a separate patch for? No need. > > After this change, the field 'itr->pmu' will be redundant (at least this > is the case for Arm SPE). I am preparing a refactoring patches for cleaning up > and see if can totally remove the field 'itr->pmu' (if all AUX events > have no issue. For this function, 'itr->pmu' could be removed in this patch since it is not used anymore. > >> >>>                        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) >> >> Should this be: >> >>                          if (ret < 0) > > Here the logic is to iterate all AUX events, even if an AUX event fails to > find the buffer index, it will continue to next AUX event. > > So it directly bails out for success (as we have found the matched AUX > event and enabled it). For the failure cause, it will continue for checking > next event - until all events have been checked and no event is matched > for buffer index, the failure will be handled at the end of the function. Thanks for the explanation. Could probably use a small comment. > > Thanks, > Leo > >> >>> +                             return ret; >> >> And will need a common error path for the pr_err() below. >> >>>                } >>>        } >>> -     return -EINVAL; >>> + >>> +     if (ret < 0) >>> +             pr_err("Failed to event enable event (idx=%d): %d\n", idx, ret); >>> + >>> +     return ret; >>>   } >>> >>>   /* >>