From: Steven Rostedt <rostedt@goodmis.org>
To: Jan Engelhardt <jengelh@inai.de>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
linux-kernel <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Paul <paulmck@linux.vnet.ibm.com>,
Josh Triplett <josh@joshtriplett.org>,
Lai Jiangshan <jiangshanlai@gmail.com>,
"Joel Fernandes, Google" <joel@joelfernandes.org>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
Florian Westphal <fw@strlen.de>,
"David S. Miller" <davem@davemloft.net>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
David Ahern <dsahern@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, rcu <rcu@vger.kernel.org>,
netfilter-devel <netfilter-devel@vger.kernel.org>,
coreteam <coreteam@netfilter.org>,
netdev <netdev@vger.kernel.org>
Subject: Re: [RFC][PATCH] rcu: Use typeof(p) instead of typeof(*p) *
Date: Tue, 5 Oct 2021 15:40:29 -0400 [thread overview]
Message-ID: <20211005154029.46f9c596@gandalf.local.home> (raw)
In-Reply-To: <srqsppq-p657-43qq-np31-pq5pp03271r6@vanv.qr>
On Tue, 5 Oct 2021 21:06:36 +0200 (CEST)
Jan Engelhardt <jengelh@inai.de> wrote:
> On Tuesday 2021-10-05 20:40, Steven Rostedt wrote:
> >>
> >> >>>> typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p);
> >>
> >> #define static_cast(type, expr) ((struct { type x; }){(expr)}.x)
> >> typeof(p) p1 = (typeof(p) __force)static_cast(void *, READ_ONCE(p));
> >>
> >> Let the name not fool you; it's absolutely _not_ the same as C++'s
> >> static_cast, but still: it does emit a warning when you do pass an
> >> integer, which is better than no warning at all in that case.
> >>
> >> *flies away*
> >
> >Are you suggesting I should continue this exercise ;-)
>
> “After all, why not?”
>
> typeof(p) p1 = (typeof(p) __force)READ_ONCE(p) +
> BUILD_BUG_ON_EXPR(__builtin_classify_type(p) != 5);
I may try it, because exposing the structure I want to hide, is pulling out
a lot of other crap with it :-p
struct trace_pid_list {
raw_spinlock_t lock;
struct irq_work refill_irqwork;
union upper_chunk *upper[UPPER1_SIZE]; // 1 or 2K in size
union upper_chunk *upper_list;
union lower_chunk *lower_list;
int free_upper_chunks;
int free_lower_chunks;
};
I can still abstract out the unions, but this means I need to also pull out
the define of "UPPER1_SIZE". Not to mention, I need to make sure irq_work
and spin locks are defined.
Another approach is to have it return:
struct trace_pid_list {
unsigned long ignore;
};
Rename the above struct trace_pid_list to struct trace_pid_internal.
And internally have:
union trace_pid_data {
struct trace_pid_list external;
struct trace_pid_internal internal;
};
Then use the internal version within the C file that modifies it, and just
return a pointer to the external part.
That should follow the "C standard".
-- Steve
next prev parent reply other threads:[~2021-10-05 19:40 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-05 13:47 [RFC][PATCH] rcu: Use typeof(p) instead of typeof(*p) * Steven Rostedt
2021-10-05 15:15 ` Mathieu Desnoyers
2021-10-05 15:58 ` Steven Rostedt
2021-10-05 16:15 ` Mathieu Desnoyers
2021-10-05 16:29 ` Paul E. McKenney
2021-10-05 16:40 ` Steven Rostedt
2021-10-11 8:39 ` David Laight
2021-10-12 14:18 ` Mathieu Desnoyers
2021-10-12 15:36 ` Steven Rostedt
2021-10-05 16:18 ` Linus Torvalds
2021-10-05 16:37 ` Steven Rostedt
2021-10-05 16:47 ` Linus Torvalds
2021-10-05 16:42 ` Steven Rostedt
2021-10-05 18:01 ` Rasmus Villemoes
2021-10-05 18:06 ` Mathieu Desnoyers
2021-10-05 18:28 ` Jan Engelhardt
2021-10-05 18:40 ` Steven Rostedt
2021-10-05 19:06 ` Jan Engelhardt
2021-10-05 19:40 ` Steven Rostedt [this message]
2021-10-05 19:46 ` Linus Torvalds
2021-10-05 20:02 ` Steven Rostedt
2021-10-05 19:49 ` Mathieu Desnoyers
2021-10-05 20:06 ` Steven Rostedt
2021-10-05 20:37 ` Steven Rostedt
2021-10-05 20:45 ` Linus Torvalds
2021-10-05 21:05 ` Steven Rostedt
2021-10-05 21:09 ` Jan Engelhardt
2021-10-05 21:24 ` Steven Rostedt
2021-10-11 8:34 ` David Laight
2021-10-05 21:27 ` Linus Torvalds
2021-10-05 22:26 ` Jan Engelhardt
2021-10-05 18:48 ` Rasmus Villemoes
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=20211005154029.46f9c596@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=fw@strlen.de \
--cc=jengelh@inai.de \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mathieu.desnoyers@efficios.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rcu@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=yoshfuji@linux-ipv6.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;
as well as URLs for NNTP newsgroup(s).