public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexei Starovoitov <ast@plumgrid.com>
To: He Kuang <hekuang@huawei.com>,
	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
Date: Tue, 07 Jul 2015 18:45:04 -0700	[thread overview]
Message-ID: <559C80A0.5080407@plumgrid.com> (raw)
In-Reply-To: <1436269386-72037-3-git-send-email-hekuang@huawei.com>

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.


  reply	other threads:[~2015-07-08  1:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07 11:43 [RFC PATCH v3 0/2] Make eBPF programs output data to perf event He Kuang
2015-07-07 11:43 ` [RFC PATCH v3 1/2] tracing: Add new trace type for bpf data output He Kuang
2015-07-07 22:47   ` Peter Zijlstra
2015-07-08  1:35   ` Alexei Starovoitov
2015-07-07 11:43 ` [RFC PATCH v3 2/2] bpf: Introduce function for outputing data to perf event He Kuang
2015-07-08  1:45   ` Alexei Starovoitov [this message]
2015-07-08  1:31 ` [RFC PATCH v3 0/2] Make eBPF programs output " 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=559C80A0.5080407@plumgrid.com \
    --to=ast@plumgrid.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --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=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    --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