[PATCH v3] tools/perf: Fix the mask in regs_dump__printf and print_sample_iregs

Jiri Olsa jolsa at redhat.com
Wed Jun 22 16:50:30 AEST 2016


On Tue, Jun 21, 2016 at 06:35:31PM +0300, Yury Norov wrote:

SNIP

> > index 5214974e841a..1337b1c73f82 100644
> > --- a/tools/perf/util/session.c
> > +++ b/tools/perf/util/session.c
> > @@ -940,8 +940,22 @@ static void branch_stack__printf(struct perf_sample *sample)
> >  static void regs_dump__printf(u64 mask, u64 *regs)
> >  {
> >  	unsigned rid, i = 0;
> > +	unsigned long _mask[sizeof(mask)/sizeof(unsigned long)];
> >  
> > -	for_each_set_bit(rid, (unsigned long *) &mask, sizeof(mask) * 8) {
> > +	/*
> > +	 * Since u64 is passed as 'unsigned long *', check
> > +	 * to see whether we need to swap words within u64.
> > +	 * Reason being, in 32 bit big endian userspace on a
> > +	 * 64bit kernel, 'unsigned long' is 32 bits.
> > +	 * When reading u64 using (u32 *)(&val)[0] and (u32 *)(&val)[1],
> > +	 * we will get wrong value for the mask. This is what
> > +	 * find_first_bit() and find_next_bit() is doing.
> > +	 * Issue here is "(u32 *)(&val)[0]" gets upper 32 bits of u64,
> > +	 * but perf assumes it gets lower 32bits of u64. Hence the check
> > +	 * and swap.
> > +	 */
> 
> Identical comments... I'd prefer to see it in commit message, or
> better in function description. For me it's pretty straightforward in
> understanding what happens here in-place without comments.

yep, please use this just once as the fucntion description

thanks,
jirka


More information about the Linuxppc-dev mailing list