From: Mao Han <han_mao@c-sky.com>
To: linux-kernel@vger.kernel.org
Cc: Mao Han <han_mao@c-sky.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Guo Ren <guoren@kernel.org>
Subject: [PATCH v2 1/1] perf: use hweight64 instead of hweight_long
Date: Tue, 2 Apr 2019 14:35:42 +0800 [thread overview]
Message-ID: <29ad7947dc8fd1ff0abd2093a72cc27a2446be9f.1554186265.git.han_mao@c-sky.com> (raw)
In-Reply-To: <cover.1554186270.git.han_mao@c-sky.com>
On 32-bits platform with more than 32 registers, the 64 bits mask is
truncate to the lower 32 bits and the return value of hweight_long will
always smaller than 32. When kernel outputs more than 32 registers, but
the user perf program only counts 32, there will be a data mismatch
result to overflow check fail.
CC: Peter Zijlstra <peterz@infradead.org>
CC: Ingo Molnar <mingo@redhat.com>
CC: Arnaldo Carvalho de Melo <acme@kernel.org>
CC: Alexander Shishkin <alexander.shishkin@linux.intel.com>
CC: Jiri Olsa <jolsa@redhat.com>
CC: Namhyung Kim <namhyung@kernel.org>
CC: Guo Ren <guoren@kernel.org>
Signed-off-by: Mao Han <han_mao@c-sky.com>
---
tools/perf/util/evsel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 7835e05..73c78be 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2322,7 +2322,7 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
if (data->user_regs.abi) {
u64 mask = evsel->attr.sample_regs_user;
- sz = hweight_long(mask) * sizeof(u64);
+ sz = hweight64(mask) * sizeof(u64);
OVERFLOW_CHECK(array, sz, max_size);
data->user_regs.mask = mask;
data->user_regs.regs = (u64 *)array;
--
2.7.4
next prev parent reply other threads:[~2019-04-02 6:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-02 6:35 [PATCH v2 0/2] csky: perf callchain dwarf support Mao Han
2019-04-02 6:35 ` [PATCH v2 1/2] csky: Add support for perf registers sampling Mao Han
2019-04-02 6:35 ` Mao Han [this message]
2019-04-02 6:35 ` [PATCH v2 2/2] csky: add support for libdw Mao Han
2019-04-02 9:04 ` Guo Ren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=29ad7947dc8fd1ff0abd2093a72cc27a2446be9f.1554186265.git.han_mao@c-sky.com \
--to=han_mao@c-sky.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=guoren@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).