Netdev List
 help / color / mirror / Atom feed
From: Alexei Starovoitov <ast@fb.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Steven Rostedt <rostedt@goodmis.org>
Cc: David Miller <davem@davemloft.net>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Peter Zijlstra <peterz@infradead.org>,
	Network Development <netdev@vger.kernel.org>,
	kernel-team <kernel-team@fb.com>,
	Linux API <linux-api@vger.kernel.org>
Subject: Re: [PATCH v3 bpf-next 01/10] treewide: remove struct-pass-by-value from tracepoints arguments
Date: Thu, 22 Mar 2018 15:52:44 -0700	[thread overview]
Message-ID: <22c5240e-af3e-fff1-2be0-3c5692d611aa@fb.com> (raw)
In-Reply-To: <CA+55aFzWKE=6N4_0ihV4JbFcAXJaO_E_=V4q9M2npk3CJM0yrQ@mail.gmail.com>

On 3/22/18 1:52 PM, Linus Torvalds wrote:
> On Thu, Mar 22, 2018 at 1:48 PM, Steven Rostedt <rostedt@goodmis.org> wrote:
>>
>> OK, but instead of changing it to pass by reference, why not just pass
>> the value. That is:
>>
>>  static void xen_set_pte_atomic(pte_t *ptep, pte_t pte)
>>  {
>> -       trace_xen_mmu_set_pte_atomic(ptep, pte);
>> +       trace_xen_mmu_set_pte_atomic(ptep, native_pte_val(pte));
>>         set_64bit((u64 *)ptep, native_pte_val(pte));
>>  }
>
> That looks simple and clean, and makes sense since the function itself
> then uses that value anyway.
>
> Certainly simpler than my monster define.

memcpy to avoid warning is a nice trick.
Generate code looks good on variety of compilers and architectures.
It also works with s390 tracepoints that pass this struct:
struct subchannel_id {
         u32 cssid : 8;
         u32 : 4;
         u32 m : 1;
         u32 ssid : 2;
         u32 one : 1;
         u32 sch_no : 16;
} __attribute__ ((packed, aligned(4)));

by value into a bunch of trace_* functions.
So at the end this 'monster define' will reduce patch 1 a lot.

Passing less than 8 byte structs by value is ok.
If we disallow them for tracepoints it would be seen as annoying
programming convention, because one dude (me) couldn't figure out
how to cast them.
Since you found the way to do this cast, let's go with it.
It will be hidden in one file (regardless whether it's ugly or not)
whereas small struct dereferences will be everywhere,
so one hack is better.

  reply	other threads:[~2018-03-22 22:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-22 18:01 [PATCH v3 bpf-next 00/10] bpf, tracing: introduce bpf raw tracepoints Alexei Starovoitov
2018-03-22 18:01 ` [PATCH v3 bpf-next 01/10] treewide: remove struct-pass-by-value from tracepoints arguments Alexei Starovoitov
2018-03-22 18:11   ` Steven Rostedt
2018-03-22 19:31     ` Alexei Starovoitov
2018-03-22 20:19       ` Linus Torvalds
2018-03-22 20:48       ` Steven Rostedt
2018-03-22 20:52         ` Linus Torvalds
2018-03-22 22:52           ` Alexei Starovoitov [this message]
2018-03-22 18:01 ` [PATCH v3 bpf-next 02/10] net/mediatek: disambiguate mt76 vs mt7601u trace events Alexei Starovoitov
2018-03-22 18:01 ` [PATCH v3 bpf-next 03/10] net/mac802154: disambiguate mac80215 vs mac802154 " Alexei Starovoitov
2018-03-22 18:01 ` [PATCH v3 bpf-next 04/10] net/wireless/iwlwifi: fix iwlwifi_dev_ucode_error tracepoint Alexei Starovoitov
2018-03-22 18:01 ` [PATCH v3 bpf-next 05/10] macro: introduce COUNT_ARGS() macro Alexei Starovoitov
2018-03-22 18:01 ` [PATCH v3 bpf-next 06/10] tracepoint: compute num_args at build time Alexei Starovoitov
2018-03-22 18:01 ` [PATCH v3 bpf-next 07/10] bpf: introduce BPF_RAW_TRACEPOINT Alexei Starovoitov
2018-03-22 18:01 ` [PATCH v3 bpf-next 08/10] libbpf: add bpf_raw_tracepoint_open helper Alexei Starovoitov
2018-03-22 18:01 ` [PATCH v3 bpf-next 09/10] samples/bpf: raw tracepoint test Alexei Starovoitov
2018-03-22 18:01 ` [PATCH v3 bpf-next 10/10] selftests/bpf: test for bpf_get_stackid() from raw tracepoints 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=22c5240e-af3e-fff1-2be0-3c5692d611aa@fb.com \
    --to=ast@fb.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kernel-team@fb.com \
    --cc=linux-api@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@linux-foundation.org \
    /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