From: xiakaixu <xiakaixu@huawei.com>
To: Alexei Starovoitov <ast@plumgrid.com>
Cc: <davem@davemloft.net>, <acme@kernel.org>, <mingo@redhat.com>,
<a.p.zijlstra@chello.nl>, <masami.hiramatsu.pt@hitachi.com>,
<jolsa@kernel.org>, <daniel@iogearbox.net>, <wangnan0@huawei.com>,
<linux-kernel@vger.kernel.org>, <pi3orama@163.com>,
<hekuang@huawei.com>, <netdev@vger.kernel.org>
Subject: Re: [RFC PATCH 1/2] perf: Add the flag sample_disable not to output data on samples
Date: Tue, 13 Oct 2015 10:30:06 +0800 [thread overview]
Message-ID: <561C6CAE.7080503@huawei.com> (raw)
In-Reply-To: <561C07E0.6070203@plumgrid.com>
于 2015/10/13 3:20, Alexei Starovoitov 写道:
> On 10/12/15 2:02 AM, Kaixu Xia wrote:
>> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
>> index f57d7fe..25e073d 100644
>> --- a/include/linux/bpf.h
>> +++ b/include/linux/bpf.h
>> @@ -39,6 +39,7 @@ struct bpf_map {
>> u32 max_entries;
>> const struct bpf_map_ops *ops;
>> struct work_struct work;
>> + atomic_t perf_sample_disable;
>> };
>>
>> struct bpf_map_type_list {
>> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
>> index 092a0e8..0606d1d 100644
>> --- a/include/linux/perf_event.h
>> +++ b/include/linux/perf_event.h
>> @@ -483,6 +483,8 @@ struct perf_event {
>> perf_overflow_handler_t overflow_handler;
>> void *overflow_handler_context;
>>
>> + atomic_t *sample_disable;
>
> this looks fragile and unnecessary.
> Why add such field to generic bpf_map and carry its pointer into perf_event?
> Single extra field in perf_event would have been enough.
> Even better is to avoid adding any fields.
> There is already event->state why not to use that?
> The proper perf_event_enable/disable are so heavy that another
> mechanism needed? cpu_function_call is probably too much to do
> from bpf program, but that can be simplified?
> Based on the use case from cover letter, sounds like you want
> something like soft_disable?
> Then extending event->state would make the most sense.
> Also consider the case of re-entrant event enable/disable.
> So inc/dec of a flag may be needed?
Thanks for your comments!
I've tried perf_event_enable/disable, but there is a warning caused
by cpu_function_call. The main reason as follows,
int smp_call_function_single(...)
{
...
WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled()
&& !oops_in_progress);
...
}
So I added the extra atomic flag filed in order to avoid this problem.
>
>
> .
>
next prev parent reply other threads:[~2015-10-13 2:30 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-12 9:02 [RFC PATCH 0/2] bpf: enable/disable events stored in PERF_EVENT_ARRAY maps trace data output when perf sampling Kaixu Xia
2015-10-12 9:02 ` [RFC PATCH 1/2] perf: Add the flag sample_disable not to output data on samples Kaixu Xia
2015-10-12 12:02 ` Peter Zijlstra
2015-10-12 12:05 ` Wangnan (F)
2015-10-12 12:12 ` Peter Zijlstra
2015-10-12 14:14 ` kbuild test robot
2015-10-12 19:20 ` Alexei Starovoitov
2015-10-13 2:30 ` xiakaixu [this message]
2015-10-13 3:10 ` Alexei Starovoitov
2015-10-13 12:00 ` Sergei Shtylyov
2015-10-12 9:02 ` [RFC PATCH 2/2] bpf: Implement bpf_perf_event_sample_enable/disable() helpers Kaixu Xia
2015-10-12 19:29 ` Alexei Starovoitov
2015-10-13 3:27 ` Wangnan (F)
2015-10-13 3:39 ` Alexei Starovoitov
2015-10-13 3:51 ` Wangnan (F)
2015-10-13 4:16 ` Alexei Starovoitov
2015-10-13 4:34 ` Wangnan (F)
2015-10-13 5:15 ` Alexei Starovoitov
2015-10-13 6:57 ` Wangnan (F)
2015-10-13 10:54 ` He Kuang
2015-10-13 11:07 ` Wangnan (F)
2015-10-14 5:14 ` Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=561C6CAE.7080503@huawei.com \
--to=xiakaixu@huawei.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=ast@plumgrid.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=hekuang@huawei.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pi3orama@163.com \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).