stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] perf record: Fix cpu mask bit setting for mixed mmaps" failed to apply to 5.19-stable tree
@ 2022-09-23 17:55 gregkh
  2022-09-29  6:49 ` Adrian Hunter
  0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2022-09-23 17:55 UTC (permalink / raw)
  To: adrian.hunter, acme, atrajeev, irogers, jolsa, namhyung; +Cc: stable


The patch below does not apply to the 5.19-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

Possible dependencies:

ca76d7d2812b ("perf record: Fix cpu mask bit setting for mixed mmaps")
cbd7bfc7fd99 ("tools/perf: Fix out of bound access to cpu mask array")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From ca76d7d2812b46124291f99c9b50aaf63a936f23 Mon Sep 17 00:00:00 2001
From: Adrian Hunter <adrian.hunter@intel.com>
Date: Thu, 15 Sep 2022 15:26:11 +0300
Subject: [PATCH] perf record: Fix cpu mask bit setting for mixed mmaps

With mixed per-thread and (system-wide) per-cpu maps, the "any cpu" value
 -1 must be skipped when setting CPU mask bits.

Prior to commit cbd7bfc7fd99acdd ("tools/perf: Fix out of bound access
to cpu mask array") the invalid setting went unnoticed, but since then
it causes perf record to fail with an error.

Example:

 Before:

   $ perf record -e intel_pt// --per-thread uname
   Failed to initialize parallel data streaming masks

 After:

   $ perf record -e intel_pt// --per-thread uname
   Linux
   [ perf record: Woken up 1 times to write data ]
   [ perf record: Captured and wrote 0.068 MB perf.data ]

Fixes: ae4f8ae16a078964 ("libperf evlist: Allow mixing per-thread and per-cpu mmaps")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220915122612.81738-2-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index f87ef43eb820..0f711f88894c 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -3371,6 +3371,8 @@ static int record__mmap_cpu_mask_init(struct mmap_cpu_mask *mask, struct perf_cp
 		return 0;
 
 	perf_cpu_map__for_each_cpu(cpu, idx, cpus) {
+		if (cpu.cpu == -1)
+			continue;
 		/* Return ENODEV is input cpu is greater than max cpu */
 		if ((unsigned long)cpu.cpu > mask->nbits)
 			return -ENODEV;


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: FAILED: patch "[PATCH] perf record: Fix cpu mask bit setting for mixed mmaps" failed to apply to 5.19-stable tree
  2022-09-23 17:55 FAILED: patch "[PATCH] perf record: Fix cpu mask bit setting for mixed mmaps" failed to apply to 5.19-stable tree gregkh
@ 2022-09-29  6:49 ` Adrian Hunter
  0 siblings, 0 replies; 2+ messages in thread
From: Adrian Hunter @ 2022-09-29  6:49 UTC (permalink / raw)
  To: gregkh, acme, atrajeev, irogers, jolsa, namhyung; +Cc: stable

Please take dependent commit cbd7bfc7fd99 first, then ca76d7d2812b.

On 23/09/22 20:55, gregkh@linuxfoundation.org wrote:
> 
> The patch below does not apply to the 5.19-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
> 
> Possible dependencies:
> 
> ca76d7d2812b ("perf record: Fix cpu mask bit setting for mixed mmaps")
> cbd7bfc7fd99 ("tools/perf: Fix out of bound access to cpu mask array")
> 
> thanks,
> 
> greg k-h
> 
> ------------------ original commit in Linus's tree ------------------
> 
> From ca76d7d2812b46124291f99c9b50aaf63a936f23 Mon Sep 17 00:00:00 2001
> From: Adrian Hunter <adrian.hunter@intel.com>
> Date: Thu, 15 Sep 2022 15:26:11 +0300
> Subject: [PATCH] perf record: Fix cpu mask bit setting for mixed mmaps
> 
> With mixed per-thread and (system-wide) per-cpu maps, the "any cpu" value
>  -1 must be skipped when setting CPU mask bits.
> 
> Prior to commit cbd7bfc7fd99acdd ("tools/perf: Fix out of bound access
> to cpu mask array") the invalid setting went unnoticed, but since then
> it causes perf record to fail with an error.
> 
> Example:
> 
>  Before:
> 
>    $ perf record -e intel_pt// --per-thread uname
>    Failed to initialize parallel data streaming masks
> 
>  After:
> 
>    $ perf record -e intel_pt// --per-thread uname
>    Linux
>    [ perf record: Woken up 1 times to write data ]
>    [ perf record: Captured and wrote 0.068 MB perf.data ]
> 
> Fixes: ae4f8ae16a078964 ("libperf evlist: Allow mixing per-thread and per-cpu mmaps")
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
> Cc: Ian Rogers <irogers@google.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/r/20220915122612.81738-2-adrian.hunter@intel.com
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index f87ef43eb820..0f711f88894c 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -3371,6 +3371,8 @@ static int record__mmap_cpu_mask_init(struct mmap_cpu_mask *mask, struct perf_cp
>  		return 0;
>  
>  	perf_cpu_map__for_each_cpu(cpu, idx, cpus) {
> +		if (cpu.cpu == -1)
> +			continue;
>  		/* Return ENODEV is input cpu is greater than max cpu */
>  		if ((unsigned long)cpu.cpu > mask->nbits)
>  			return -ENODEV;
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-29  6:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 17:55 FAILED: patch "[PATCH] perf record: Fix cpu mask bit setting for mixed mmaps" failed to apply to 5.19-stable tree gregkh
2022-09-29  6:49 ` Adrian Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).