Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1637966 > unrolled thread
| Started by | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| First post | 2017-05-09 10:30 +0200 |
| Last post | 2017-05-10 02:20 +0200 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v6 2/7] perf/x86/intel: Record branch type Jiri Olsa <jolsa@redhat.com> - 2017-05-09 10:30 +0200
Re: [PATCH v6 2/7] perf/x86/intel: Record branch type "Jin, Yao" <yao.jin@linux.intel.com> - 2017-05-09 14:00 +0200
Re: [PATCH v6 2/7] perf/x86/intel: Record branch type Jiri Olsa <jolsa@redhat.com> - 2017-05-09 14:40 +0200
Re: [PATCH v6 2/7] perf/x86/intel: Record branch type "Jin, Yao" <yao.jin@linux.intel.com> - 2017-05-10 02:20 +0200
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2017-05-09 10:30 +0200 |
| Subject | Re: [PATCH v6 2/7] perf/x86/intel: Record branch type |
| Message-ID | <tF8GR-7BJ-1@gated-at.bofh.it> |
On Mon, Apr 24, 2017 at 08:47:14AM +0800, Jin, Yao wrote:
>
>
> On 4/23/2017 9:55 PM, Jiri Olsa wrote:
> > On Thu, Apr 20, 2017 at 08:07:50PM +0800, Jin Yao wrote:
> >
> > SNIP
> >
> > > +#define X86_BR_TYPE_MAP_MAX 16
> > > +
> > > +static int
> > > +common_branch_type(int type)
> > > +{
> > > + int i, mask;
> > > + 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_INT, /* X86_BR_INT */
> > > + PERF_BR_IRET, /* X86_BR_IRET */
> > > + PERF_BR_JCC, /* X86_BR_JCC */
> > > + PERF_BR_JMP, /* X86_BR_JMP */
> > > + PERF_BR_IRQ, /* X86_BR_IRQ */
> > > + PERF_BR_IND_CALL, /* X86_BR_IND_CALL */
> > > + PERF_BR_NONE, /* X86_BR_ABORT */
> > > + PERF_BR_NONE, /* X86_BR_IN_TX */
> > > + PERF_BR_NONE, /* X86_BR_NO_TX */
> > > + PERF_BR_CALL, /* X86_BR_ZERO_CALL */
> > > + PERF_BR_NONE, /* X86_BR_CALL_STACK */
> > > + PERF_BR_IND_JMP, /* X86_BR_IND_JMP */
> > > + };
> > > +
> > > + 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
> >
> > > +
> > > + 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
[toc] | [next] | [standalone]
| From | "Jin, Yao" <yao.jin@linux.intel.com> |
|---|---|
| Date | 2017-05-09 14:00 +0200 |
| Message-ID | <tFbY5-1dU-17@gated-at.bofh.it> |
| In reply to | #1637966 |
On 5/9/2017 4:26 PM, Jiri Olsa wrote:
> On Mon, Apr 24, 2017 at 08:47:14AM +0800, Jin, Yao wrote:
>>
>> On 4/23/2017 9:55 PM, Jiri Olsa wrote:
>>> On Thu, Apr 20, 2017 at 08:07:50PM +0800, Jin Yao wrote:
>>>
>>> SNIP
>>>
>>>> +#define X86_BR_TYPE_MAP_MAX 16
>>>> +
>>>> +static int
>>>> +common_branch_type(int type)
>>>> +{
>>>> + int i, mask;
>>>> + 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_INT, /* X86_BR_INT */
>>>> + PERF_BR_IRET, /* X86_BR_IRET */
>>>> + PERF_BR_JCC, /* X86_BR_JCC */
>>>> + PERF_BR_JMP, /* X86_BR_JMP */
>>>> + PERF_BR_IRQ, /* X86_BR_IRQ */
>>>> + PERF_BR_IND_CALL, /* X86_BR_IND_CALL */
>>>> + PERF_BR_NONE, /* X86_BR_ABORT */
>>>> + PERF_BR_NONE, /* X86_BR_IN_TX */
>>>> + PERF_BR_NONE, /* X86_BR_NO_TX */
>>>> + PERF_BR_CALL, /* X86_BR_ZERO_CALL */
>>>> + PERF_BR_NONE, /* X86_BR_CALL_STACK */
>>>> + PERF_BR_IND_JMP, /* X86_BR_IND_JMP */
>>>> + };
>>>> +
>>>> + 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 :)
>>>> +
>>>> + 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"?
Thanks
Jin Yao
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2017-05-09 14:40 +0200 |
| Message-ID | <tFcAO-1J6-17@gated-at.bofh.it> |
| In reply to | #1638066 |
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
[toc] | [prev] | [next] | [standalone]
| From | "Jin, Yao" <yao.jin@linux.intel.com> |
|---|---|
| Date | 2017-05-10 02:20 +0200 |
| Message-ID | <tFnwd-Jl-5@gated-at.bofh.it> |
| In reply to | #1638093 |
On 5/9/2017 8:39 PM, Jiri Olsa wrote:
> 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
I think so. The compiler should be clever enough for this optimization.
>>>>>> +
>>>>>> + 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
Thanks so much!
Jin Yao
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web