From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750926AbbJMERE (ORCPT ); Tue, 13 Oct 2015 00:17:04 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:33333 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750880AbbJMERC (ORCPT ); Tue, 13 Oct 2015 00:17:02 -0400 Subject: Re: [RFC PATCH 2/2] bpf: Implement bpf_perf_event_sample_enable/disable() helpers To: "Wangnan (F)" , Kaixu Xia , 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 References: <1444640563-159175-1-git-send-email-xiakaixu@huawei.com> <1444640563-159175-3-git-send-email-xiakaixu@huawei.com> <561C0A1E.2080500@plumgrid.com> <561C7A1F.6040702@huawei.com> <561C7CDA.8050004@plumgrid.com> <561C7FBE.4000104@huawei.com> Cc: linux-kernel@vger.kernel.org, pi3orama@163.com, hekuang@huawei.com, netdev@vger.kernel.org From: Alexei Starovoitov Message-ID: <561C85BB.3000505@plumgrid.com> Date: Mon, 12 Oct 2015 21:16:59 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <561C7FBE.4000104@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/12/15 8:51 PM, Wangnan (F) wrote: >> why 'set disable' is needed ? >> the example given in cover letter shows the use case where you want >> to receive samples only within sys_write() syscall. >> The example makes sense, but sys_write() is running on this cpu, so just >> disabling it on the current one is enough. >> > > Our real use case is control of the system-wide sampling. For example, > we need sampling all CPUs when smartphone start refershing its display. > We need all CPUs because in Android system there are plenty of threads > get involed into this behavior. We can't achieve this by controling > sampling on only one CPU. This is the reason we need 'set enable' > and 'set disable'. ok, but that use case may have different enable/disable pattern. In sys_write example ultra-fast enable/disable is must have, since the whole syscall is fast and overhead should be minimal. but for display refresh? we're talking milliseconds, no? Can you just ioctl() it from user space? If cost of enable/disable is high or the time range between toggling is long, then doing it from the bpf program doesn't make sense. Instead the program can do bpf_perf_event_output() to send a notification to user space that condition is met and the user space can ioctl() events.