From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753828AbdEIMjS (ORCPT ); Tue, 9 May 2017 08:39:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33022 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753727AbdEIMjR (ORCPT ); Tue, 9 May 2017 08:39:17 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B91D4C057FA9 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jolsa@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B91D4C057FA9 Date: Tue, 9 May 2017 14:39:13 +0200 From: Jiri Olsa To: "Jin, Yao" Cc: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v6 2/7] perf/x86/intel: Record branch type Message-ID: <20170509123913.GC9983@krava> References: <1492690075-17243-1-git-send-email-yao.jin@linux.intel.com> <1492690075-17243-3-git-send-email-yao.jin@linux.intel.com> <20170423135559.GA23073@krava> <20170509082644.GB22125@krava> <0e0b5c46-23ee-64dc-7ab3-2e8016d6a160@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0e0b5c46-23ee-64dc-7ab3-2e8016d6a160@linux.intel.com> User-Agent: Mutt/1.8.0 (2017-02-23) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 09 May 2017 12:39:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 09, 2017 at 07:57:11PM +0800, Jin, Yao wrote: SNIP > > > > > + > > > > > + type >>= 2; /* skip X86_BR_USER and X86_BR_KERNEL */ > > > > > + mask = ~(~0 << 1); > > > > is that a fancy way to get 1 into the mask? what do I miss? > > you did not comment on this one > > Sorry, I misunderstood that this comment and the next comment had the same > meaning. > > In the previous version, I used the switch/case to convert from X86_BR to > PERF_BR. I got a comment from community that it'd better use a lookup table > for conversion. > > Since each bit in type represents a X86_BR type so I use a mask (0x1) to > filter the bit. Yes, it looks I can also directly set 0x1 to mask. > > I write the code "mask = ~(~0 << 1)" according to my coding habits. If you > think I should change the code to "mask = 0x1", that's OK :) im ok with that.. was just wondering for the reason I guess compiler will make it single constant assignment anyway > > > > > > + > > > > > + for (i = 0; i < X86_BR_TYPE_MAP_MAX; i++) { > > > > > + if (type & mask) > > > > > + return branch_map[i]; > > > > I wonder some bit search would be faster in here, but maybe not big deal > > > > > > > > jirka > > > I just think the branch_map[] doesn't contain many entries (16 entries > > > here), so maybe checking 1 bit one time should be acceptable. I just want to > > > keep the code simple. > > > > > > But if the number of entries is more (e.g. 64), maybe it'd better check 2 or > > > 4 bits one time. > > ook > > > > jirka > Sorry, what's the meaning of ook? Does it mean "OK"? just means ok ;-) thanks, jirka