Netdev List
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Alexei Starovoitov <ast@fb.com>
Cc: <davem@davemloft.net>, <daniel@iogearbox.net>,
	<torvalds@linux-foundation.org>, <peterz@infradead.org>,
	<netdev@vger.kernel.org>, <kernel-team@fb.com>,
	<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 16:48:31 -0400	[thread overview]
Message-ID: <20180322164831.01519df6@gandalf.local.home> (raw)
In-Reply-To: <6b1952c4-1612-7abb-49c6-9bbaf6dc6997@fb.com>

On Thu, 22 Mar 2018 12:31:12 -0700
Alexei Starovoitov <ast@fb.com> wrote:

> On 3/22/18 11:11 AM, Steven Rostedt wrote:
> > On Thu, 22 Mar 2018 11:01:48 -0700
> > Alexei Starovoitov <ast@fb.com> wrote:
> >  
> >> From: Alexei Starovoitov <ast@kernel.org>
> >>
> >> Fix all tracepoint arguments to pass structures (large and small) by reference
> >> instead of by value.
> >> Avoiding passing large structs by value is a good coding style.
> >> Passing small structs sometimes is beneficial, but in all cases
> >> it makes no difference vs readability of the code.
> >> The subsequent patch enforces that all tracepoints args are either integers
> >> or pointers and fit into 64-bit.  
> >
> > But some of these structures are used to force type checking, and are
> > just the same size as a number. That's why they don't have "struct" in
> > front of them. Like pmd_t. Will the subsequent patches really break if
> > the structure itself has one element that is of size long? Just seems
> > to add extra code to pass in an address to something that fits into a
> > single register.  
> 
> yeah. C doesn't allow casting of 'struct s { u64 var };' into u64
> without massive hacks and aliasing warnings by compiler.
> CAST_TO_U64 macro in patch 7 will prevent tracepoint arguments to be
> things like pmd_t. It's not perfect, but doing & of pmd_t variable
> is imo clean enough as you can see in this patch.
> The macro can be tweaked to do the cast like
> *(sizeof(typeof(arg))*)&arg,
> but there is no way to get rid of compiler warning.

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));
 }

It shouldn't add any extra code, as those helper functions are
basically just special casts.

-- Steve

  parent reply	other threads:[~2018-03-22 20:48 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 [this message]
2018-03-22 20:52         ` Linus Torvalds
2018-03-22 22:52           ` Alexei Starovoitov
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=20180322164831.01519df6@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=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=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