Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf affinity: Allow passing a NULL arg to affinity__cleanup()

Just like with free(), NULL is checked to avoid having all callers do
it.

Its convenient for when not using affinity setup/cleanup for dummy CPU
maps, i.e. CPU maps for pid targets.

Acked-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20220117160931.1191712-2-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+7 -1
+7 -1
tools/perf/util/affinity.c
··· 62 62 clear_bit(cpu, a->sched_cpus); 63 63 } 64 64 65 - void affinity__cleanup(struct affinity *a) 65 + static void __affinity__cleanup(struct affinity *a) 66 66 { 67 67 int cpu_set_size = get_cpu_set_size(); 68 68 ··· 70 70 sched_setaffinity(0, cpu_set_size, (cpu_set_t *)a->orig_cpus); 71 71 zfree(&a->sched_cpus); 72 72 zfree(&a->orig_cpus); 73 + } 74 + 75 + void affinity__cleanup(struct affinity *a) 76 + { 77 + if (a != NULL) 78 + __affinity__cleanup(a); 73 79 }