public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org
Cc: stable <stable@kernel.org>, Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf: fix up some comments and code to properly use the event_source bus
Date: Wed, 19 Feb 2025 13:37:40 -0500	[thread overview]
Message-ID: <70aec50b-09a3-45b4-8eb9-138518a8476a@linux.intel.com> (raw)
In-Reply-To: <2025021955-implant-excavator-179d@gregkh>



On 2025-02-19 8:40 a.m., Greg Kroah-Hartman wrote:
> In sysfs, the perf events are all located in
> /sys/bus/event_source/devices/ but some places ended up hard-coding the
> location to be at the root of /sys/devices/ which could be very risky as
> you do not exactly know what type of device you are accessing in sysfs
> at that location.
> 
> So fix this all up by properly pointing everything at the bus device
> list instead of the root of the sysfs devices/ tree.
> 
> Cc: stable <stable@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Ian Rogers <irogers@google.com>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: "Liang, Kan" <kan.liang@linux.intel.com>
> Cc: linux-perf-users@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


Reviewed-by: Kan Liang <kan.liang@linux.intel.com>

Thanks,
Kan

> ---
>  tools/perf/Documentation/intel-hybrid.txt | 12 ++++++------
>  tools/perf/Documentation/perf-list.txt    |  2 +-
>  tools/perf/arch/x86/util/iostat.c         |  2 +-
>  tools/perf/builtin-stat.c                 |  2 +-
>  tools/perf/util/mem-events.c              |  2 +-
>  tools/perf/util/pmu.c                     |  4 ++--
>  6 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/perf/Documentation/intel-hybrid.txt b/tools/perf/Documentation/intel-hybrid.txt
> index e7a776ad25d7..0379903673a4 100644
> --- a/tools/perf/Documentation/intel-hybrid.txt
> +++ b/tools/perf/Documentation/intel-hybrid.txt
> @@ -8,15 +8,15 @@ Part of events are available on core cpu, part of events are available
>  on atom cpu and even part of events are available on both.
>  
>  Kernel exports two new cpu pmus via sysfs:
> -/sys/devices/cpu_core
> -/sys/devices/cpu_atom
> +/sys/bus/event_source/devices/cpu_core
> +/sys/bus/event_source/devices/cpu_atom
>  
>  The 'cpus' files are created under the directories. For example,
>  
> -cat /sys/devices/cpu_core/cpus
> +cat /sys/bus/event_source/devices/cpu_core/cpus
>  0-15
>  
> -cat /sys/devices/cpu_atom/cpus
> +cat /sys/bus/event_source/devices/cpu_atom/cpus
>  16-23
>  
>  It indicates cpu0-cpu15 are core cpus and cpu16-cpu23 are atom cpus.
> @@ -60,8 +60,8 @@ can't carry pmu information. So now this type is extended to be PMU aware
>  type. The PMU type ID is stored at attr.config[63:32].
>  
>  PMU type ID is retrieved from sysfs.
> -/sys/devices/cpu_atom/type
> -/sys/devices/cpu_core/type
> +/sys/bus/event_source/devices/cpu_atom/type
> +/sys/bus/event_source/devices/cpu_core/type
>  
>  The new attr.config layout for PERF_TYPE_HARDWARE:
>  
> diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt
> index d0c65fad419a..c3ffd93f94d7 100644
> --- a/tools/perf/Documentation/perf-list.txt
> +++ b/tools/perf/Documentation/perf-list.txt
> @@ -188,7 +188,7 @@ in the CPU vendor specific documentation.
>  
>  The available PMUs and their raw parameters can be listed with
>  
> -  ls /sys/devices/*/format
> +  ls /sys/bus/event_source/devices/*/format
>  
>  For example the raw event "LSD.UOPS" core pmu event above could
>  be specified as
> diff --git a/tools/perf/arch/x86/util/iostat.c b/tools/perf/arch/x86/util/iostat.c
> index 00f645a0c18a..7442a2cd87ed 100644
> --- a/tools/perf/arch/x86/util/iostat.c
> +++ b/tools/perf/arch/x86/util/iostat.c
> @@ -32,7 +32,7 @@
>  #define MAX_PATH 1024
>  #endif
>  
> -#define UNCORE_IIO_PMU_PATH	"devices/uncore_iio_%d"
> +#define UNCORE_IIO_PMU_PATH	"bus/event_source/devices/uncore_iio_%d"
>  #define SYSFS_UNCORE_PMU_PATH	"%s/"UNCORE_IIO_PMU_PATH
>  #define PLATFORM_MAPPING_PATH	UNCORE_IIO_PMU_PATH"/die%d"
>  
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 77e327d4a9a7..68ea7589c143 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -97,7 +97,7 @@
>  #include <internal/threadmap.h>
>  
>  #define DEFAULT_SEPARATOR	" "
> -#define FREEZE_ON_SMI_PATH	"devices/cpu/freeze_on_smi"
> +#define FREEZE_ON_SMI_PATH	"bus/event_source/devices/cpu/freeze_on_smi"
>  
>  static void print_counters(struct timespec *ts, int argc, const char **argv);
>  
> diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
> index 3692e988c86e..0277d3e1505c 100644
> --- a/tools/perf/util/mem-events.c
> +++ b/tools/perf/util/mem-events.c
> @@ -189,7 +189,7 @@ static bool perf_pmu__mem_events_supported(const char *mnt, struct perf_pmu *pmu
>  	if (!e->event_name)
>  		return true;
>  
> -	scnprintf(path, PATH_MAX, "%s/devices/%s/events/%s", mnt, pmu->name, e->event_name);
> +	scnprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s/events/%s", mnt, pmu->name, e->event_name);
>  
>  	return !stat(path, &st);
>  }
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 6206c8fe2bf9..a8193ac8f2e7 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -36,12 +36,12 @@
>  #define UNIT_MAX_LEN	31 /* max length for event unit name */
>  
>  enum event_source {
> -	/* An event loaded from /sys/devices/<pmu>/events. */
> +	/* An event loaded from /sys/bus/event_source/devices/<pmu>/events. */
>  	EVENT_SRC_SYSFS,
>  	/* An event loaded from a CPUID matched json file. */
>  	EVENT_SRC_CPU_JSON,
>  	/*
> -	 * An event loaded from a /sys/devices/<pmu>/identifier matched json
> +	 * An event loaded from a /sys/bus/event_source/devices/<pmu>/identifier matched json
>  	 * file.
>  	 */
>  	EVENT_SRC_SYS_JSON,


  reply	other threads:[~2025-02-19 18:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-19 13:40 [PATCH] perf: fix up some comments and code to properly use the event_source bus Greg Kroah-Hartman
2025-02-19 18:37 ` Liang, Kan [this message]
2025-02-20 18:26 ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=70aec50b-09a3-45b4-8eb9-138518a8476a@linux.intel.com \
    --to=kan.liang@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox