Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1688759

Re: [PATCH v9 2/7] perf/x86/intel: Record branch type

From "Jin, Yao" <yao.jin@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH v9 2/7] perf/x86/intel: Record branch type
Date 2017-07-17 10:30 +0200
Message-ID <u49zH-2z2-11@gated-at.bofh.it> (permalink)
References <u44A2-7UE-15@gated-at.bofh.it> <u44JH-7XV-15@gated-at.bofh.it> <u49q2-2vC-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 7/17/2017 4:11 PM, Jiri Olsa wrote:
> 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

OK, agree to let branch_map array be static. I will add this in v10.

I'm also waiting for Peter's review comments for this patch update.

Thanks
Jin Yao

>
>> +
>> +	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
>>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v9 0/7] perf report: Show branch type Jin Yao <yao.jin@linux.intel.com> - 2017-07-17 05:10 +0200
  [PATCH v9 6/7] perf report: Show branch type statistics for stdio mode Jin Yao <yao.jin@linux.intel.com> - 2017-07-17 05:20 +0200
  [PATCH v9 5/7] perf util: Create branch.c/.h for common branch functions Jin Yao <yao.jin@linux.intel.com> - 2017-07-17 05:20 +0200
  [PATCH v9 7/7] perf report: Show branch type in callchain entry Jin Yao <yao.jin@linux.intel.com> - 2017-07-17 05:20 +0200
  [PATCH v9 2/7] perf/x86/intel: Record branch type Jin Yao <yao.jin@linux.intel.com> - 2017-07-17 05:20 +0200
    Re: [PATCH v9 2/7] perf/x86/intel: Record branch type Jiri Olsa <jolsa@redhat.com> - 2017-07-17 10:20 +0200
      Re: [PATCH v9 2/7] perf/x86/intel: Record branch type "Jin, Yao" <yao.jin@linux.intel.com> - 2017-07-17 10:30 +0200
        Re: [PATCH v9 2/7] perf/x86/intel: Record branch type Peter Zijlstra <peterz@infradead.org> - 2017-07-18 11:30 +0200
  [PATCH v9 4/7] perf report: Refactor the branch info printing code Jin Yao <yao.jin@linux.intel.com> - 2017-07-17 05:20 +0200
  [PATCH v9 3/7] perf record: Create a new option save_type in --branch-filter Jin Yao <yao.jin@linux.intel.com> - 2017-07-17 05:20 +0200
  [PATCH v9 1/7] perf/core: Define the common branch type classification Jin Yao <yao.jin@linux.intel.com> - 2017-07-17 05:20 +0200
  Re: [PATCH v9 0/7] perf report: Show branch type Jiri Olsa <jolsa@redhat.com> - 2017-07-17 10:20 +0200

csiph-web