From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751635AbcFVGv3 (ORCPT ); Wed, 22 Jun 2016 02:51:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51408 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750896AbcFVGv0 (ORCPT ); Wed, 22 Jun 2016 02:51:26 -0400 Date: Wed, 22 Jun 2016 08:50:30 +0200 From: Jiri Olsa To: Yury Norov Cc: Madhavan Srinivasan , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Wang Nan , Michael Ellerman Subject: Re: [PATCH v3] tools/perf: Fix the mask in regs_dump__printf and print_sample_iregs Message-ID: <20160622065030.GA2042@krava> References: <1466521000-11329-1-git-send-email-maddy@linux.vnet.ibm.com> <20160621153531.GA32361@yury-N73SV> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160621153531.GA32361@yury-N73SV> User-Agent: Mutt/1.6.1 (2016-04-27) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 22 Jun 2016 06:50:34 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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