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

perf: cs-etm: Optimize option setup for CPU-wide sessions

Call function cs_etm_set_option() once with all relevant options set
rather than multiple times to avoid going through the list of CPU more
than once.

Suggested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/20190611204528.20093-1-mathieu.poirier@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Mathieu Poirier and committed by
Arnaldo Carvalho de Melo
374d910f 010e3e8f

+8 -12
+8 -12
tools/perf/arch/arm/util/cs-etm.c
··· 162 162 !cpu_map__has(online_cpus, i)) 163 163 continue; 164 164 165 - switch (option) { 166 - case ETM_OPT_CTXTID: 165 + if (option & ETM_OPT_CTXTID) { 167 166 err = cs_etm_set_context_id(itr, evsel, i); 168 167 if (err) 169 168 goto out; 170 - break; 171 - case ETM_OPT_TS: 169 + } 170 + if (option & ETM_OPT_TS) { 172 171 err = cs_etm_set_timestamp(itr, evsel, i); 173 172 if (err) 174 173 goto out; 175 - break; 176 - default: 177 - goto out; 178 174 } 175 + if (option & ~(ETM_OPT_CTXTID | ETM_OPT_TS)) 176 + /* Nothing else is currently supported */ 177 + goto out; 179 178 } 180 179 181 180 err = 0; ··· 397 398 if (!cpu_map__empty(cpus)) { 398 399 perf_evsel__set_sample_bit(cs_etm_evsel, CPU); 399 400 400 - err = cs_etm_set_option(itr, cs_etm_evsel, ETM_OPT_CTXTID); 401 - if (err) 402 - goto out; 403 - 404 - err = cs_etm_set_option(itr, cs_etm_evsel, ETM_OPT_TS); 401 + err = cs_etm_set_option(itr, cs_etm_evsel, 402 + ETM_OPT_CTXTID | ETM_OPT_TS); 405 403 if (err) 406 404 goto out; 407 405 }