Skip to content

Commit

Permalink
perf affinity: Allow passing a NULL arg to affinity__cleanup()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnaldo Carvalho de Melo committed Jan 18, 2022
1 parent 4624f19 commit 1855b79
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tools/perf/util/affinity.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void affinity__set(struct affinity *a, int cpu)
clear_bit(cpu, a->sched_cpus);
}

void affinity__cleanup(struct affinity *a)
static void __affinity__cleanup(struct affinity *a)
{
int cpu_set_size = get_cpu_set_size();

Expand All @@ -71,3 +71,9 @@ void affinity__cleanup(struct affinity *a)
zfree(&a->sched_cpus);
zfree(&a->orig_cpus);
}

void affinity__cleanup(struct affinity *a)
{
if (a != NULL)
__affinity__cleanup(a);
}

0 comments on commit 1855b79

Please sign in to comment.