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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F40EC77B7E for ; Thu, 27 Apr 2023 20:13:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344192AbjD0UNN (ORCPT ); Thu, 27 Apr 2023 16:13:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344185AbjD0UNJ (ORCPT ); Thu, 27 Apr 2023 16:13:09 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1677F46A5; Thu, 27 Apr 2023 13:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682626366; x=1714162366; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=gkgzXX7acwSBnuJ9bdx4m5R1AVWdzJYvB7t1tP5cDvg=; b=ga9laUOlFSTypI2r0ajwWoZ+EaBwaKXXSB2V3UVcMeYZAnNQyqaU/m6/ fOQYMojH1iImLK4ynzJrJkKVEBZNf2WxMFZjMeYkLJT1Mk2rQeuCZXFMH vdvXkCx4tUrI20tFxM2O6+AYnoI6OZxXNhydhP1kgrqCeevg5P1NkSTcJ od4ulSSSm3+E0ChPNJRtCGYhyk0jP6TQBs4iudGXkuqdYdPrKUo4GSwxR ywHLFk/+Z4q7cRl08eddgjC8V7uVUWnrWV0RflQ+XHgo28uvPKmqN6hEo gjTaCkJlK4yCuOScwR6HcVGzweSdDOJP/XR+kGlJ1f1ygilJQEdDZEm5E w==; X-IronPort-AV: E=McAfee;i="6600,9927,10693"; a="410619736" X-IronPort-AV: E=Sophos;i="5.99,232,1677571200"; d="scan'208";a="410619736" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2023 13:12:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10693"; a="671906819" X-IronPort-AV: E=Sophos;i="5.99,232,1677571200"; d="scan'208";a="671906819" Received: from linux.intel.com ([10.54.29.200]) by orsmga006.jf.intel.com with ESMTP; 27 Apr 2023 13:12:45 -0700 Received: from [10.209.41.222] (kliang2-mobl1.ccr.corp.intel.com [10.209.41.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 76609580377; Thu, 27 Apr 2023 13:12:41 -0700 (PDT) Message-ID: Date: Thu, 27 Apr 2023 16:12:40 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v1 17/40] perf evsel: Modify group pmu name for software events Content-Language: en-US To: Ian Rogers , Arnaldo Carvalho de Melo , Ahmad Yasin , Peter Zijlstra , Ingo Molnar , Stephane Eranian , Andi Kleen , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Florian Fischer , Rob Herring , Zhengjun Xing , John Garry , Kajol Jain , Sumanth Korikkar , Thomas Richter , Tiezhu Yang , Ravi Bangoria , Leo Yan , Yang Jihong , James Clark , Suzuki Poulouse , Kang Minchul , Athira Rajeev , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230426070050.1315519-1-irogers@google.com> <20230426070050.1315519-18-irogers@google.com> From: "Liang, Kan" In-Reply-To: <20230426070050.1315519-18-irogers@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org On 2023-04-26 3:00 a.m., Ian Rogers wrote: > If we have a group of {cycles,faults} then we need the faults software > event to appear to be on the same PMU as cycles so that we don't split > the group in parse_events__sort_events_and_fix_groups. This case is > relatively easy as cycles is the leader and will have a PMU name. In > the reverse case, {faults,cycles} we still need faults to appear to > have the PMU name of cycles but the old behavior is just to return > "cpu". For hybrid this fails as cycles will be on "cpu_core" or > "cpu_atom", causing faults to be split into a different group. > > Change the behavior for software events so that the whole group is > searched for the named PMU. > > Signed-off-by: Ian Rogers Reviewed-by: Kan Liang Thanks, Kan > --- > tools/perf/util/evsel.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > index 1cd04b5998d2..63522322e118 100644 > --- a/tools/perf/util/evsel.c > +++ b/tools/perf/util/evsel.c > @@ -829,23 +829,26 @@ bool evsel__name_is(struct evsel *evsel, const char *name) > > const char *evsel__group_pmu_name(const struct evsel *evsel) > { > - const struct evsel *leader; > + struct evsel *leader, *pos; > > /* If the pmu_name is set use it. pmu_name isn't set for CPU and software events. */ > if (evsel->pmu_name) > return evsel->pmu_name; > /* > * Software events may be in a group with other uncore PMU events. Use > - * the pmu_name of the group leader to avoid breaking the software event > - * out of the group. > + * the pmu_name of the first non-software event to avoid breaking the > + * software event out of the group. > * > * Aux event leaders, like intel_pt, expect a group with events from > * other PMUs, so substitute the AUX event's PMU in this case. > */ > leader = evsel__leader(evsel); > - if ((evsel->core.attr.type == PERF_TYPE_SOFTWARE || evsel__is_aux_event(leader)) && > - leader->pmu_name) { > - return leader->pmu_name; > + if (evsel->core.attr.type == PERF_TYPE_SOFTWARE || evsel__is_aux_event(leader)) { > + /* Starting with the leader, find the first event with a named PMU. */ > + for_each_group_evsel(pos, leader) { > + if (pos->pmu_name) > + return pos->pmu_name; > + } > } > > return "cpu";