From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757936AbbGHBpO (ORCPT ); Tue, 7 Jul 2015 21:45:14 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:33552 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753684AbbGHBpH (ORCPT ); Tue, 7 Jul 2015 21:45:07 -0400 Message-ID: <559C80A0.5080407@plumgrid.com> Date: Tue, 07 Jul 2015 18:45:04 -0700 From: Alexei Starovoitov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: He Kuang , rostedt@goodmis.org, masami.hiramatsu.pt@hitachi.com, acme@kernel.org, a.p.zijlstra@chello.nl, mingo@redhat.com, namhyung@kernel.org, jolsa@kernel.org CC: wangnan0@huawei.com, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v3 2/2] bpf: Introduce function for outputing data to perf event References: <1436269386-72037-1-git-send-email-hekuang@huawei.com> <1436269386-72037-3-git-send-email-hekuang@huawei.com> In-Reply-To: <1436269386-72037-3-git-send-email-hekuang@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 On 7/7/15 4:43 AM, He Kuang wrote: > --- a/include/uapi/linux/bpf.h > +++ b/include/uapi/linux/bpf.h > @@ -210,6 +210,9 @@ enum bpf_func_id { > * Return: 0 on success > */ > BPF_FUNC_l4_csum_replace, > + > + /* int bpf_output_data(void *src, int size, void *regs) */ bpf_output_trace_data(struct pt_regs *ctx, void *data, int data_size) > + BPF_FUNC_output_data, > __BPF_FUNC_MAX_ID, > }; > > +static u64 bpf_output_data(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) > +{ > + void *src = (void *) (long) r1; > + int dsize = (int) r2, __size, size; > + void *regs = (void *) (long) r3; please cast to 'struct pt_regs *', since that's what it is. > + __size = sizeof(*entry) + dsize; > + size = ALIGN(__size + sizeof(u32), sizeof(u64)); > + size -= sizeof(u32); > + > + entry = perf_trace_buf_prepare(size, TRACE_BPF, NULL, &rctx); > + if (!entry) > + return -ENOMEM; > + > + entry->size = dsize; something wrong here. Either 'size' from bpf_trace_entry_head should be used or from trace_bpf. > (void *) BPF_FUNC_l4_csum_replace; > +static int (*bpf_output_data)(void *src, int size, void *regs) = > + (void *) BPF_FUNC_output_data; 'struct pt_regs *ctx' here as well.