提交 b1c8cdb6 编写于 作者: S Suzuki K Poulose 提交者: Zhong Jinghua

perf cs-etm: Fix bitmap for option

mainline inclusion
from mainline-v5.12
commit 8c559e8d
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I636PS
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8c559e8d68630d64d932bada633705f6551427df

--------------------------------------------------------------------------

When set option with macros ETM_OPT_CTXTID and ETM_OPT_TS, it wrongly
takes these two values (14 and 28 prespectively) as bit masks, but
actually both are the offset for bits.  But this doesn't lead to further
failure due to the AND logic operation will be always true for
ETM_OPT_CTXTID / ETM_OPT_TS.

This patch uses the BIT() macro for option bits, thus it can request the
correct bitmaps for "contextid" and "timestamp" when calling
cs_etm_set_option().
Signed-off-by: NSuzuki K Poulose <suzuki.poulose@arm.com>
Reviewed-by: NMathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: NMike Leach <mike.leach@linaro.org>
Link: https://lore.kernel.org/r/20210213113220.292229-3-leo.yan@linaro.org
Link: https://lore.kernel.org/r/20210224164835.3497311-4-mathieu.poirier@linaro.org
[Extract the change as a separate patch for easier review]
Signed-off-by: NLeo Yan <leo.yan@linaro.org>
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: NJunhao He <hejunhao3@huawei.com>
上级 8363150c
...@@ -169,17 +169,17 @@ static int cs_etm_set_option(struct auxtrace_record *itr, ...@@ -169,17 +169,17 @@ static int cs_etm_set_option(struct auxtrace_record *itr,
!cpu_map__has(online_cpus, i)) !cpu_map__has(online_cpus, i))
continue; continue;
if (option & ETM_OPT_CTXTID) { if (option & BIT(ETM_OPT_CTXTID)) {
err = cs_etm_set_context_id(itr, evsel, i); err = cs_etm_set_context_id(itr, evsel, i);
if (err) if (err)
goto out; goto out;
} }
if (option & ETM_OPT_TS) { if (option & BIT(ETM_OPT_TS)) {
err = cs_etm_set_timestamp(itr, evsel, i); err = cs_etm_set_timestamp(itr, evsel, i);
if (err) if (err)
goto out; goto out;
} }
if (option & ~(ETM_OPT_CTXTID | ETM_OPT_TS)) if (option & ~(BIT(ETM_OPT_CTXTID) | BIT(ETM_OPT_TS)))
/* Nothing else is currently supported */ /* Nothing else is currently supported */
goto out; goto out;
} }
...@@ -406,7 +406,7 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, ...@@ -406,7 +406,7 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
evsel__set_sample_bit(cs_etm_evsel, CPU); evsel__set_sample_bit(cs_etm_evsel, CPU);
err = cs_etm_set_option(itr, cs_etm_evsel, err = cs_etm_set_option(itr, cs_etm_evsel,
ETM_OPT_CTXTID | ETM_OPT_TS); BIT(ETM_OPT_CTXTID) | BIT(ETM_OPT_TS));
if (err) if (err)
goto out; goto out;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册