From: Namhyung Kim <namhyung@kernel.org>
To: Feng Tang <feng.tang@intel.com>
Cc: acme@redhat.com, mingo@elte.hu, a.p.zijlstra@chello.nl,
dsahern@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] perf tools: Fix a misuse of for_each_set_bit() in session.c
Date: Mon, 27 Aug 2012 16:59:07 +0900 [thread overview]
Message-ID: <871uisepf8.fsf@sejong.aot.lge.com> (raw)
In-Reply-To: <1346053107-11946-4-git-send-email-feng.tang@intel.com> (Feng Tang's message of "Mon, 27 Aug 2012 15:38:27 +0800")
Hi,
On Mon, 27 Aug 2012 15:38:27 +0800, Feng Tang wrote:
> In regs_dump__printf() it use for_each_set_bit() for bit ops by
> casting a (u64 *) to a (unsigned long *), this works for 64 bits
> machine, but will fail on 32 bits ones.
>
> Fix it by using the raw bit comparing method.
Did it really cause a build failure or a program error? If not, it
looks better to keep using for_each_set_bit() interface. How about
casting the @mask to (void *) ?
Thanks,
Namhyung
>
> Signed-off-by: Feng Tang <feng.tang@intel.com>
> ---
> tools/perf/util/session.c | 9 ++++-----
> 1 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index f7bb7ae..afcea6c 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -904,11 +904,10 @@ static void regs_dump__printf(u64 mask, u64 *regs)
> {
> unsigned rid, i = 0;
>
> - for_each_set_bit(rid, (unsigned long *) &mask, sizeof(mask) * 8) {
> - u64 val = regs[i++];
> -
> - printf(".... %-5s 0x%" PRIx64 "\n",
> - perf_reg_name(rid), val);
> + for (rid = 0; rid < 64; rid++) {
> + if (mask & (1 << rid))
> + printf(".... %-5s 0x%" PRIx64 "\n",
> + perf_reg_name(rid), regs[i++]);
> }
> }
next prev parent reply other threads:[~2012-08-27 8:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-27 7:38 [PATCH 0/3] perf tools: Fixes for some compile errors Feng Tang
2012-08-27 7:38 ` [PATCH 1/3] perf tools: Fix a compiling error in trace-event-perl.c for 32 bits machine Feng Tang
2012-08-27 15:33 ` Arnaldo Carvalho de Melo
2012-08-28 2:17 ` [PATCH v2 " Feng Tang
2012-09-27 4:22 ` [tip:perf/core] " tip-bot for Feng Tang
2012-08-27 7:38 ` [PATCH 2/3] Perf tools: Fix a compiling error in util/map.c Feng Tang
2012-09-27 4:23 ` [tip:perf/core] perf " tip-bot for Feng Tang
2012-08-27 7:38 ` [PATCH 3/3] perf tools: Fix a misuse of for_each_set_bit() in session.c Feng Tang
2012-08-27 7:59 ` Namhyung Kim [this message]
2012-08-27 8:18 ` Feng Tang
2012-12-18 17:39 ` Akemi Yagi
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=871uisepf8.fsf@sejong.aot.lge.com \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=feng.tang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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