Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752231AbbEFE5E (ORCPT ); Wed, 6 May 2015 00:57:04 -0400 Received: from mail-ig0-f173.google.com ([209.85.213.173]:35803 "EHLO mail-ig0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751314AbbEFE5C (ORCPT ); Wed, 6 May 2015 00:57:02 -0400 Message-ID: <55499F1B.1020302@plumgrid.com> Date: Tue, 05 May 2015 21:56:59 -0700 From: Alexei Starovoitov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Wang Nan CC: linux-kernel@vger.kernel.org, pi3orama@163.com, Li Zefan Subject: Re: [RFC PATCH 00/22] perf tools: introduce 'perf bpf' command to load eBPF programs. References: <1430391165-30267-1-git-send-email-wangnan0@huawei.com> <554302F0.3070101@plumgrid.com> <55447A7D.4000205@huawei.com> <554832AA.5050503@plumgrid.com> <55484A11.7070603@huawei.com> <554859CD.4090206@plumgrid.com> <55485FBF.20306@huawei.com> <55499CB0.1090400@huawei.com> In-Reply-To: <55499CB0.1090400@huawei.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1874 Lines: 45 On 5/5/15 9:46 PM, Wang Nan wrote: > Hi Alexei Starovoitov, > > Have you ever read this mail? please don't top post. >>> all makes sense and your use case fits quite well into existing >>> bpf+kprobe model. I'm not sure why you're calling a 'problem'. >>> A problem of how to display that call stack from perf? >>> I would say it fits better as a sample than a trace. >>> If you dump it as a trace, it won't easy to decipher, whereas if you >>> treat it a sampling event, perf record/report facility will pick it up and display nicely. Meaning that one sample == lock_page/unlock_page >>> latency > N. Then existing sample_callchain flag should work. >>> >> >> Quite well. Do we have an eBPF function like >> >> static int (*bpf_perf_sample)(const char *fmt, int fmt_size, ...) = BPF_FUNC_perf_sample >> >> so we can use it in the program probed in the body of __unlock_page() like that: >> >> ... >> if (latency > 0.5s) >> bpf_perf_sample("page=%p, latency=%d", sizeof(...), page, latency); No need for extra helper. There is already return value from the program for this purpose. From kernel/trace/bpf_trace.c: * Return: BPF programs always return an integer which is interpreted by * kprobe handler as: * 0 - return from kprobe (event is filtered out) * 1 - store kprobe event into ring buffer in your case the program attached to unlock_page() can return 1 when it needs to store this event into ring buffer, so that perf can process it. If I'm not mistaken, the sample_callchain flag cannot be applied to kprobe events, but that's a general program (not related to bpf) and can be addressed as such. -- 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/