Skip to content

Commit 5411aef

Browse files
He Zhegregkh
authored andcommitted
perf ftrace: Fix failure to set cpumask when only one cpu is present
[ Upstream commit cf30ae7 ] The buffer containing the string used to set cpumask is overwritten at the end of the string later in cpu_map__snprint_mask due to not enough memory space, when there is only one cpu. And thus causes the following failure: $ perf ftrace ls failed to reset ftrace $ This patch fixes the calculation of the cpumask string size. Signed-off-by: He Zhe <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alexey Budankov <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Fixes: dc23103 ("perf ftrace: Add support for -a and -C option") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 93a6504 commit 5411aef

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/perf/builtin-ftrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static int set_tracing_cpumask(struct cpu_map *cpumap)
162162
int last_cpu;
163163

164164
last_cpu = cpu_map__cpu(cpumap, cpumap->nr - 1);
165-
mask_size = (last_cpu + 3) / 4 + 1;
165+
mask_size = last_cpu / 4 + 2; /* one more byte for EOS */
166166
mask_size += last_cpu / 32; /* ',' is needed for every 32th cpus */
167167

168168
cpumask = malloc(mask_size);

0 commit comments

Comments
 (0)