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

perf target: Move the checking of which map function to call into function.

Check for cpu_map__dummy_new() or cpu_map__new() to be called in
perf_evlist__create_maps() is more complicated.

This patch moves the checking work into target.h, combining two
conditions and making perf_evlist__create_maps() more readable.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/b8c41f1fd2c4f0df71eb7b19aea74fb64d46cdda.1386197481.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Dongsheng Yang and committed by
Arnaldo Carvalho de Melo
9c105fbc 2f375735

+14 -7
+1 -7
tools/perf/util/evlist.c
··· 819 819 if (evlist->threads == NULL) 820 820 return -1; 821 821 822 - if (target->default_per_cpu) 823 - evlist->cpus = target->per_thread ? 824 - cpu_map__dummy_new() : 825 - cpu_map__new(target->cpu_list); 826 - else if (target__has_task(target)) 827 - evlist->cpus = cpu_map__dummy_new(); 828 - else if (!target__has_cpu(target) && !target->uses_mmap) 822 + if (target__uses_dummy_map(target)) 829 823 evlist->cpus = cpu_map__dummy_new(); 830 824 else 831 825 evlist->cpus = cpu_map__new(target->cpu_list);
+13
tools/perf/util/target.h
··· 63 63 return !target__has_task(target) && !target__has_cpu(target); 64 64 } 65 65 66 + static inline bool target__uses_dummy_map(struct target *target) 67 + { 68 + bool use_dummy = false; 69 + 70 + if (target->default_per_cpu) 71 + use_dummy = target->per_thread ? true : false; 72 + else if (target__has_task(target) || 73 + (!target__has_cpu(target) && !target->uses_mmap)) 74 + use_dummy = true; 75 + 76 + return use_dummy; 77 + } 78 + 66 79 #endif /* _PERF_TARGET_H */