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


Groups > linux.kernel > #1251331 > unrolled thread

[PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

Started byKaixu Xia <xiakaixu@huawei.com>
First post2015-10-20 09:30 +0200
Last post2015-10-21 14:10 +0200
Articles 11 on this page of 31 — 7 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.


Contents

  [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling Kaixu Xia <xiakaixu@huawei.com> - 2015-10-20 09:30 +0200
    Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Alexei Starovoitov <ast@plumgrid.com> - 2015-10-21 01:00 +0200
      Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Peter Zijlstra <peterz@infradead.org> - 2015-10-21 11:20 +0200
        Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling xiakaixu <xiakaixu@huawei.com> - 2015-10-21 12:40 +0200
          Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Peter Zijlstra <peterz@infradead.org> - 2015-10-21 13:40 +0200
            Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling "Wangnan (F)" <wangnan0@huawei.com> - 2015-10-21 14:00 +0200
              Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Peter Zijlstra <peterz@infradead.org> - 2015-10-21 14:20 +0200
                Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling "Wangnan (F)" <wangnan0@huawei.com> - 2015-10-21 15:50 +0200
                  Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Peter Zijlstra <peterz@infradead.org> - 2015-10-21 16:00 +0200
                    Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling pi3orama <pi3orama@163.com> - 2015-10-21 16:10 +0200
                      Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Peter Zijlstra <peterz@infradead.org> - 2015-10-21 16:10 +0200
                        Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling pi3orama <pi3orama@163.com> - 2015-10-21 17:20 +0200
                          Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Peter Zijlstra <peterz@infradead.org> - 2015-10-21 19:00 +0200
                            Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Alexei Starovoitov <ast@plumgrid.com> - 2015-10-21 23:30 +0200
                              Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Peter Zijlstra <peterz@infradead.org> - 2015-10-22 11:10 +0200
                                Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling "Wangnan (F)" <wangnan0@huawei.com> - 2015-10-22 12:40 +0200
                                  Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Peter Zijlstra <peterz@infradead.org> - 2015-10-23 15:00 +0200
                                    Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Peter Zijlstra <peterz@infradead.org> - 2015-10-23 17:20 +0200
                                      Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling xiakaixu <xiakaixu@huawei.com> - 2015-10-27 07:50 +0100
                            Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling "Wangnan (F)" <wangnan0@huawei.com> - 2015-10-22 05:00 +0200
                              Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Ingo Molnar <mingo@kernel.org> - 2015-10-22 09:50 +0200
                                Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling "Wangnan (F)" <wangnan0@huawei.com> - 2015-10-22 10:00 +0200
                                  Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Peter Zijlstra <peterz@infradead.org> - 2015-10-22 11:30 +0200
                  Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling "Wangnan (F)" <wangnan0@huawei.com> - 2015-10-22 04:10 +0200
                    Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Alexei Starovoitov <ast@plumgrid.com> - 2015-10-22 05:10 +0200
                      Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling "Wangnan (F)" <wangnan0@huawei.com> - 2015-10-22 05:20 +0200
                        Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Alexei Starovoitov <ast@plumgrid.com> - 2015-10-22 05:30 +0200
                        Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Peter Zijlstra <peterz@infradead.org> - 2015-10-22 11:50 +0200
        Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling "Wangnan (F)" <wangnan0@huawei.com> - 2015-10-21 13:40 +0200
          Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling Peter Zijlstra <peterz@infradead.org> - 2015-10-21 14:00 +0200
            Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY  maps trace data output when perf sampling "Wangnan (F)" <wangnan0@huawei.com> - 2015-10-21 14:10 +0200

Page 2 of 2 — ← Prev page 1 [2]


#1253552 — Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

FromIngo Molnar <mingo@kernel.org>
Date2015-10-22 09:50 +0200
SubjectRe: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling
Message-ID<qmiNj-4az-17@gated-at.bofh.it>
In reply to#1253443
* Wangnan (F) <wangnan0@huawei.com> wrote:

> 
> 
> On 2015/10/22 0:57, Peter Zijlstra wrote:
> >On Wed, Oct 21, 2015 at 11:06:47PM +0800, pi3orama wrote:
> >>>So explain; how does this eBPF stuff work.
> >>I think I get your point this time, and let me explain the eBPF stuff to you.
> >>
> >>You are aware that BPF programmer can break the system in this way:
> >>
> >>A=get_non_local_perf_event()
> >>perf_event_read_local(A)
> >>BOOM!
> >>
> >>However the above logic is impossible because BPF program can't work this
> >>way.
> >>
> >>First of all, it is impossible for a BPF program directly invoke a
> >>kernel function.  Doesn't like kernel module, BPF program can only
> >>invoke functions designed for them, like what this patch does. So the
> >>ability of BPF programs is strictly restricted by kernel. If we don't
> >>allow BPF program call perf_event_read_local() across core, we can
> >>check this and return error in function we provide for them.
> >>
> >>Second: there's no way for a BPF program directly access a perf event.
> >>All perf events have to be wrapped by a map and be accessed by BPF
> >>functions described above. We don't allow BPF program fetch array
> >>element from that map. So pointers of perf event is safely protected
> >>from BPF program.
> >>
> >>In summary, your either-or logic doesn't hold in BPF world. A BPF
> >>program can only access perf event in a highly restricted way. We
> >>don't allow it calling perf_event_read_local() across core, so it
> >>can't.
> >Urgh, that's still horridly inconsistent. Can we please come up with a
> >consistent interface to perf?
> 
> BPF program and kernel module are two different worlds as I said before.
> 
> I don't think making them to share a common interface is a good idea because 
> such sharing will give BPF programs too much freedom than it really need, then 
> it will be hard prevent them to do something bad. If we really need kernel 
> interface, I think what we need is kernel module, not BPF program.

What do you mean, as this does not parse for me.

We obviously can (and very likely should) make certain perf functionality 
available to BPF programs.

It should still be a well defined yet flexible iterface, with safe behavior, 
obviously - all in line with existing BPF sandboxing principles.

'Kernel modules' don't enter this consideration at all, not sure why you mention 
them - all this functionality is also available if CONFIG_MODULES is turned off 
completely.

Thanks,

	Ingo

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1253554 — Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

From"Wangnan (F)" <wangnan0@huawei.com>
Date2015-10-22 10:00 +0200
SubjectRe: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling
Message-ID<qmiWZ-4m5-3@gated-at.bofh.it>
In reply to#1253552

On 2015/10/22 15:39, Ingo Molnar wrote:
> * Wangnan (F) <wangnan0@huawei.com> wrote:
>
[SNIP]
>>
>> In summary, your either-or logic doesn't hold in BPF world. A BPF
>> program can only access perf event in a highly restricted way. We
>> don't allow it calling perf_event_read_local() across core, so it
>> can't.
>>> Urgh, that's still horridly inconsistent. Can we please come up with a
>>> consistent interface to perf?
>> BPF program and kernel module are two different worlds as I said before.
>>
>> I don't think making them to share a common interface is a good idea because
>> such sharing will give BPF programs too much freedom than it really need, then
>> it will be hard prevent them to do something bad. If we really need kernel
>> interface, I think what we need is kernel module, not BPF program.
> What do you mean, as this does not parse for me.

Because I'm not very sure what the meaning of "inconsistent" in
Peter's words...

I think what Peter want us to do is to provide similar (consistent) 
interface
between kernel and eBPF that, if kernel reads from a perf_event through
perf_event_read_local(struct perf_event *), BPF program should
do this work with similar code, or at least similar logic, so
we need to create handler for a perf event, and provide a BPF function
called BPF_FUNC_perf_event_read_local then pass such handler to it.

I don't think like this because if we want kernel interface we'd
better use kernel module, not eBPF so I mentioned kernel module here.

Ingo, do you think BPF inerface should be *consistent* with anything?

Thank you.

> We obviously can (and very likely should) make certain perf functionality
> available to BPF programs.
>
> It should still be a well defined yet flexible iterface, with safe behavior,
> obviously - all in line with existing BPF sandboxing principles.
>
> 'Kernel modules' don't enter this consideration at all, not sure why you mention
> them - all this functionality is also available if CONFIG_MODULES is turned off
> completely.
>
> Thanks,
>
> 	Ingo
>


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1253642 — Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

FromPeter Zijlstra <peterz@infradead.org>
Date2015-10-22 11:30 +0200
SubjectRe: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling
Message-ID<qmkm6-6x6-9@gated-at.bofh.it>
In reply to#1253554
On Thu, Oct 22, 2015 at 03:51:37PM +0800, Wangnan (F) wrote:
> Because I'm not very sure what the meaning of "inconsistent" in
> Peter's words...

What's inconsistent is that some perf actions can be done only on local
events while others can be done on !local.

And I can't say I particularly like having to pass in events from
userspace, but I think that Alexei convinced me that it made some sense
at some point in time.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1253420 — Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

From"Wangnan (F)" <wangnan0@huawei.com>
Date2015-10-22 04:10 +0200
SubjectRe: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling
Message-ID<qmdui-4Se-13@gated-at.bofh.it>
In reply to#1252832
Hi Alexei,

On 2015/10/21 21:42, Wangnan (F) wrote:
>
>
> One alternative solution I can image is to attach a BPF program
> at sampling like kprobe, and return 0 if we don't want sampling
> take action. Thought?

Do you think attaching BPF programs to sampling is an acceptable idea?

Thank you.

> Actually speaking I don't like it very much
> because the principle of soft-disable is much simpler and safe, but
> if you really like it I think we can try.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1253450 — Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

FromAlexei Starovoitov <ast@plumgrid.com>
Date2015-10-22 05:10 +0200
SubjectRe: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling
Message-ID<qmeqm-6lm-11@gated-at.bofh.it>
In reply to#1253420
On 10/21/15 6:56 PM, Wangnan (F) wrote:
>> One alternative solution I can image is to attach a BPF program
>> at sampling like kprobe, and return 0 if we don't want sampling
>> take action. Thought?
>
> Do you think attaching BPF programs to sampling is an acceptable idea?

If you mean to extend 'filter' concept to sampling events?
So instead of soft_disable of non-local events, you'll attach bpf
program to sampling events and use map lookup to decide whether
to filter out or not such sampling event?
What pt_regs would be in such case?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1253451 — Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

From"Wangnan (F)" <wangnan0@huawei.com>
Date2015-10-22 05:20 +0200
SubjectRe: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling
Message-ID<qmeA2-6wC-1@gated-at.bofh.it>
In reply to#1253450

On 2015/10/22 11:09, Alexei Starovoitov wrote:
> On 10/21/15 6:56 PM, Wangnan (F) wrote:
>>> One alternative solution I can image is to attach a BPF program
>>> at sampling like kprobe, and return 0 if we don't want sampling
>>> take action. Thought?
>>
>> Do you think attaching BPF programs to sampling is an acceptable idea?
>
> If you mean to extend 'filter' concept to sampling events?
> So instead of soft_disable of non-local events, you'll attach bpf
> program to sampling events and use map lookup to decide whether
> to filter out or not such sampling event?

Yes.

> What pt_regs would be in such case?
>

Sampling is based on interruption. We can use pt_reg captured by the IRQ 
handler,
or we can simply pass NULL to those BPF program.

Thank you.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1253454 — Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

FromAlexei Starovoitov <ast@plumgrid.com>
Date2015-10-22 05:30 +0200
SubjectRe: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling
Message-ID<qmeJH-6HD-5@gated-at.bofh.it>
In reply to#1253451
On 10/21/15 8:12 PM, Wangnan (F) wrote:
>
>
> On 2015/10/22 11:09, Alexei Starovoitov wrote:
>> On 10/21/15 6:56 PM, Wangnan (F) wrote:
>>>> One alternative solution I can image is to attach a BPF program
>>>> at sampling like kprobe, and return 0 if we don't want sampling
>>>> take action. Thought?
>>>
>>> Do you think attaching BPF programs to sampling is an acceptable idea?
>>
>> If you mean to extend 'filter' concept to sampling events?
>> So instead of soft_disable of non-local events, you'll attach bpf
>> program to sampling events and use map lookup to decide whether
>> to filter out or not such sampling event?
>
> Yes.
>
>> What pt_regs would be in such case?
>>
>
> Sampling is based on interruption. We can use pt_reg captured by the IRQ
> handler,
> or we can simply pass NULL to those BPF program.

NULL is obviously not ok. Try to answer yourself 'why it's not'.
Clean implementation should add single 'if (..->prog)' to event sampling
critical path. Please don't rush it and think it through.
but the first thing first, please see my fix for bpf_perf_event_read:
http://patchwork.ozlabs.org/patch/534120/
and ack it if it makes sense.
we need to make sure existing stuff is solid, before going further.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1253684 — Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

FromPeter Zijlstra <peterz@infradead.org>
Date2015-10-22 11:50 +0200
SubjectRe: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling
Message-ID<qmkFu-6UJ-53@gated-at.bofh.it>
In reply to#1253451
On Thu, Oct 22, 2015 at 11:12:16AM +0800, Wangnan (F) wrote:
> On 2015/10/22 11:09, Alexei Starovoitov wrote:
> >On 10/21/15 6:56 PM, Wangnan (F) wrote:
> >>>One alternative solution I can image is to attach a BPF program
> >>>at sampling like kprobe, and return 0 if we don't want sampling
> >>>take action. Thought?
> >>
> >>Do you think attaching BPF programs to sampling is an acceptable idea?
> >
> >If you mean to extend 'filter' concept to sampling events?
> >So instead of soft_disable of non-local events, you'll attach bpf
> >program to sampling events and use map lookup to decide whether
> >to filter out or not such sampling event?
> 
> Yes.

One could overload or stack the overflow handler I suppose. But this
would be in line with the software/tracepoint events calling eBPF muck
on trigger, right?

> >What pt_regs would be in such case?

> Sampling is based on interruption. We can use pt_reg captured by the IRQ
> handler,

s/IRQ/NMI/

Also, we 'edit' the pt_regs on the way down to the overflow handler as
sometimes 'better' information can be had from PMU state. But a pt_regs
is available there.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1252740 — Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

From"Wangnan (F)" <wangnan0@huawei.com>
Date2015-10-21 13:40 +0200
SubjectRe: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling
Message-ID<qlZUm-1FU-23@gated-at.bofh.it>
In reply to#1252606

On 2015/10/21 17:12, Peter Zijlstra wrote:
> On Tue, Oct 20, 2015 at 03:53:02PM -0700, Alexei Starovoitov wrote:
>> On 10/20/15 12:22 AM, Kaixu Xia wrote:
>>> diff --git a/kernel/events/core.c b/kernel/events/core.c
>>> index b11756f..5219635 100644
>>> --- a/kernel/events/core.c
>>> +++ b/kernel/events/core.c
>>> @@ -6337,6 +6337,9 @@ static int __perf_event_overflow(struct perf_event *event,
>>>   		irq_work_queue(&event->pending);
>>>   	}
>>>
>>> +	if (unlikely(!atomic_read(&event->soft_enable)))
>>> +		return 0;
>>> +
>>>   	if (event->overflow_handler)
>>>   		event->overflow_handler(event, data, regs);
>>>   	else
>> Peter,
>> does this part look right or it should be moved right after
>> if (unlikely(!is_sampling_event(event)))
>>                  return 0;
>> or even to other function?
>>
>> It feels to me that it should be moved, since we probably don't
>> want to active throttling, period adjust and event_limit for events
>> that are in soft_disabled state.
> Depends on what its meant to do. As long as you let the interrupt
> happen, I think we should in fact do those things (maybe not the
> event_limit), but period adjustment and esp. throttling are important
> when the event is enabled.
>
> If you want to actually disable the event: pmu->stop() will make it
> stop, and you can restart using pmu->start().xiezuo

I also prefer totally disabling event because our goal is to reduce
sampling overhead as mush as possible. However, events in perf is
CPU bounded, one event in perf cmdline becomes multiple 'perf_event'
in kernel in multi-core system. Disabling/enabling events on all CPUs
by a BPF program a hard task due to racing, NMI, ...

Think about an example scenario: we want to sample cycles in a system
width way to see what the whole system does during a smart phone
refreshing its display, and don't want other samples when display
freezing. We probe at the entry and exit points of Display.refresh() (a
fictional user function), then let two BPF programs to enable 'cycle'
sampling PMU at the entry point and disable it at the exit point.

In this task, we need to start all 'cycles' perf_events when display
start refreshing, and disable all of those events when refreshing is
finished. Only enable the event on the core which executes the entry
point of Display.refresh() is not enough because real workers are
running on other cores, we need them to do the computation cooperativly.
Also, scheduler is possible to schedule the exit point of Display.refresh()
on another core, so we can't simply disable the perf_event on that core and
let other core keel sampling after refreshing finishes.

I have thought a method which can disable sampling in a safe way:
we can call pmu->stop() inside the PMU IRQ handler, so we can ensure
that pmu->stop() always be called by core its event resides.
However, I don't know how to reenable them when safely. Maybe need
something in scheduler?

Thank you.

> And I suppose you can wrap that with a counter if you need nesting.
>
> I'm not sure if any of that is a viable solution, because the patch
> description is somewhat short on the problem statement.
>
> As is, I'm not too charmed with the patch, but lacking a better
> understanding of what exactly we're trying to achieve I'm struggling
> with proposing alternatives.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1252761 — Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

FromPeter Zijlstra <peterz@infradead.org>
Date2015-10-21 14:00 +0200
SubjectRe: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling
Message-ID<qm0dI-22V-19@gated-at.bofh.it>
In reply to#1252740
On Wed, Oct 21, 2015 at 07:34:28PM +0800, Wangnan (F) wrote:
> >If you want to actually disable the event: pmu->stop() will make it
> >stop, and you can restart using pmu->start().xiezuo
> 
> I also prefer totally disabling event because our goal is to reduce
> sampling overhead as mush as possible. However, events in perf is
> CPU bounded, one event in perf cmdline becomes multiple 'perf_event'
> in kernel in multi-core system. Disabling/enabling events on all CPUs
> by a BPF program a hard task due to racing, NMI, ...

But eBPF perf events must already be local afaik. Look at the
constraints perf_event_read_local() places on the events.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1252765 — Re: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling

From"Wangnan (F)" <wangnan0@huawei.com>
Date2015-10-21 14:10 +0200
SubjectRe: [PATCH V5 1/1] bpf: control events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling
Message-ID<qm0no-2tz-11@gated-at.bofh.it>
In reply to#1252761

On 2015/10/21 19:56, Peter Zijlstra wrote:
> On Wed, Oct 21, 2015 at 07:34:28PM +0800, Wangnan (F) wrote:
>>> If you want to actually disable the event: pmu->stop() will make it
>>> stop, and you can restart using pmu->start().xiezuo
>> I also prefer totally disabling event because our goal is to reduce
>> sampling overhead as mush as possible. However, events in perf is
>> CPU bounded, one event in perf cmdline becomes multiple 'perf_event'
>> in kernel in multi-core system. Disabling/enabling events on all CPUs
>> by a BPF program a hard task due to racing, NMI, ...
> But eBPF perf events must already be local afaik. Look at the
> constraints perf_event_read_local() places on the events.

I think soft disabling/enabling is free of this constraint,
because technically speaking a soft-disabled perf event is still
running.

What we want to disable is only sampling action to avoid
being overwhelming by sampling and reduce the overhead which
output those unneeded sampling data to perf.data. I don't
care whether the PMU counter is stopped or still running
too much. Even if it still generate interrupts I think it
should be acceptable because interruption handling can be fast.

Thank you.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | linux.kernel


csiph-web