From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751301AbdGQILS (ORCPT ); Mon, 17 Jul 2017 04:11:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54489 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751257AbdGQILQ (ORCPT ); Mon, 17 Jul 2017 04:11:16 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E3B237CB80 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jolsa@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E3B237CB80 Date: Mon, 17 Jul 2017 10:11:12 +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, mpe@ellerman.id.au, Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com Subject: Re: [PATCH v9 2/7] perf/x86/intel: Record branch type Message-ID: <20170717081112.GC22046@krava> References: <1500289603-4352-1-git-send-email-yao.jin@linux.intel.com> <1500289603-4352-3-git-send-email-yao.jin@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1500289603-4352-3-git-send-email-yao.jin@linux.intel.com> User-Agent: Mutt/1.8.3 (2017-05-23) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 17 Jul 2017 08:11:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 17, 2017 at 07:06:38PM +0800, Jin Yao wrote: SNIP > +#define X86_BR_TYPE_MAP_MAX 16 > + > +static int > +common_branch_type(int type) > +{ > + int i; > + const int branch_map[X86_BR_TYPE_MAP_MAX] = { > + PERF_BR_CALL, /* X86_BR_CALL */ > + PERF_BR_RET, /* X86_BR_RET */ > + PERF_BR_SYSCALL, /* X86_BR_SYSCALL */ > + PERF_BR_SYSRET, /* X86_BR_SYSRET */ > + PERF_BR_UNKNOWN, /* X86_BR_INT */ > + PERF_BR_UNKNOWN, /* X86_BR_IRET */ > + PERF_BR_COND, /* X86_BR_JCC */ > + PERF_BR_UNCOND, /* X86_BR_JMP */ > + PERF_BR_UNKNOWN, /* X86_BR_IRQ */ > + PERF_BR_IND_CALL, /* X86_BR_IND_CALL */ > + PERF_BR_UNKNOWN, /* X86_BR_ABORT */ > + PERF_BR_UNKNOWN, /* X86_BR_IN_TX */ > + PERF_BR_UNKNOWN, /* X86_BR_NO_TX */ > + PERF_BR_CALL, /* X86_BR_ZERO_CALL */ > + PERF_BR_UNKNOWN, /* X86_BR_CALL_STACK */ > + PERF_BR_IND, /* X86_BR_IND_JMP */ > + }; should the branch_map array be static? having it on stack makes the compiler to create it every time we call the function jirka > + > + type >>= 2; /* skip X86_BR_USER and X86_BR_KERNEL */ > + > + if (type) { > + i = __ffs(type); > + if (i < X86_BR_TYPE_MAP_MAX) > + return branch_map[i]; > + } > + > + return PERF_BR_UNKNOWN; > +} > + > /* > * implement actual branch filter based on user demand. > * Hardware may not exactly satisfy that request, thus > @@ -942,7 +987,8 @@ intel_pmu_lbr_filter(struct cpu_hw_events *cpuc) > bool compress = false; > > /* if sampling all branches, then nothing to filter */ > - if ((br_sel & X86_BR_ALL) == X86_BR_ALL) > + if (((br_sel & X86_BR_ALL) == X86_BR_ALL) && > + ((br_sel & X86_BR_TYPE_SAVE) != X86_BR_TYPE_SAVE)) > return; > > for (i = 0; i < cpuc->lbr_stack.nr; i++) { > @@ -963,6 +1009,9 @@ intel_pmu_lbr_filter(struct cpu_hw_events *cpuc) > cpuc->lbr_entries[i].from = 0; > compress = true; > } > + > + if ((br_sel & X86_BR_TYPE_SAVE) == X86_BR_TYPE_SAVE) > + cpuc->lbr_entries[i].type = common_branch_type(type); > } > > if (!compress) > -- > 2.7.4 >