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 26E15C433EF for ; Fri, 6 May 2022 07:19:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389489AbiEFHXB (ORCPT ); Fri, 6 May 2022 03:23:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245542AbiEFHWx (ORCPT ); Fri, 6 May 2022 03:22:53 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24C722E080 for ; Fri, 6 May 2022 00:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651821552; x=1683357552; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=Q5d9HH/sQp+F8Knzv+tCoRI8RdzEpU46UiEcz+bJbD8=; b=CRjWT6z8ZjvOyQNKDSrS2X7/bv8nNwKddU4cRSIqEuDwvBeqEWvJTWVB JlLNvQhbboDJ0cN1eBGeTWd4PScecROcu9fgAbbLCtzbqrl+ga73br8Bx pJwFMxuPqAaKU2SHgwNzG1yk3aAv1UkpzR2ZjJ52zucmOAMbB4KlcR5jr GJBcWn1EKLL/bXQq9iCndm9zuyhvLXmfOWu6RXzyoswKRs6BOJ0bgYsRR Nh6lzLwHT+ZOHSX/7jH/z8TWVIs9JETOLC/jfstNEl8I2f9Gm+AuvaTOe U6vy99GTfKh0XBh/IqrKzENA24sG9dHl851caVioh+90qa0Y0HbN8Z4F5 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10338"; a="267980838" X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="267980838" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2022 00:19:02 -0700 X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="563681480" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.252.62.152]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2022 00:18:59 -0700 Message-ID: Date: Fri, 6 May 2022 10:18:56 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0 Thunderbird/91.8.1 Subject: Re: [PATCH V1 02/23] libperf evsel: Add perf_evsel__enable_thread() Content-Language: en-US To: Ian Rogers Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Alexey Bayduraev , Namhyung Kim , Leo Yan , linux-kernel@vger.kernel.org References: <20220505165639.361733-1-adrian.hunter@intel.com> <20220505165639.361733-3-adrian.hunter@intel.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/05/22 01:48, Ian Rogers wrote: > On Thu, May 5, 2022 at 9:56 AM Adrian Hunter wrote: >> >> Add perf_evsel__enable_thread() as a counterpart to >> perf_evsel__enable_cpu(), to enable all events for a thread. >> >> Signed-off-by: Adrian Hunter >> --- >> tools/lib/perf/evsel.c | 10 ++++++++++ >> tools/lib/perf/include/perf/evsel.h | 1 + >> 2 files changed, 11 insertions(+) >> >> diff --git a/tools/lib/perf/evsel.c b/tools/lib/perf/evsel.c >> index 20ae9f5f8b30..dcc928dd25f8 100644 >> --- a/tools/lib/perf/evsel.c >> +++ b/tools/lib/perf/evsel.c >> @@ -360,6 +360,16 @@ int perf_evsel__enable_cpu(struct perf_evsel *evsel, int cpu_map_idx) >> return perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_ENABLE, NULL, cpu_map_idx); >> } >> >> +int perf_evsel__enable_thread(struct perf_evsel *evsel, int thread) >> +{ >> + int err = 0; >> + int idx; >> + >> + for (idx = 0; idx < xyarray__max_x(evsel->fd) && !err; idx++) >> + err = perf_evsel__ioctl(evsel, PERF_EVENT_IOC_ENABLE, NULL, idx, thread); > > For perf_cpu_map code like this has been replaced with > perf_cpu_map__for_each_cpu, it would be nice here to use a > perf_thread_map__for_each_thread. I understand we don't have that at > the moment. It would be easier to find places to add this if there is > a call to perf_thread_map__nr. Adding an assert of: > > assert(perf_thread_map__nr(evsel->thread_map) == xyarray__max_x(evsel->fd)); Threads go in the y direction. I'll change it to use perf_cpu_map__for_each_cpu > > Would help, or we could add the loop. > > Thanks, > Ian > >> + return err; >> +} >> + >> int perf_evsel__enable(struct perf_evsel *evsel) >> { >> int i; >> diff --git a/tools/lib/perf/include/perf/evsel.h b/tools/lib/perf/include/perf/evsel.h >> index 2a9516b42d15..699c0ed97d34 100644 >> --- a/tools/lib/perf/include/perf/evsel.h >> +++ b/tools/lib/perf/include/perf/evsel.h >> @@ -36,6 +36,7 @@ LIBPERF_API int perf_evsel__read(struct perf_evsel *evsel, int cpu_map_idx, int >> struct perf_counts_values *count); >> LIBPERF_API int perf_evsel__enable(struct perf_evsel *evsel); >> LIBPERF_API int perf_evsel__enable_cpu(struct perf_evsel *evsel, int cpu_map_idx); >> +LIBPERF_API int perf_evsel__enable_thread(struct perf_evsel *evsel, int thread); >> LIBPERF_API int perf_evsel__disable(struct perf_evsel *evsel); >> LIBPERF_API int perf_evsel__disable_cpu(struct perf_evsel *evsel, int cpu_map_idx); >> LIBPERF_API struct perf_cpu_map *perf_evsel__cpus(struct perf_evsel *evsel); >> -- >> 2.25.1 >>