From: Boqun Feng <boqun.feng@gmail.com>
To: Joel Fernandes <joel@joelfernandes.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Josh Triplett <josh@joshtriplett.org>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
"Paul E. McKenney" <paulmck@kernel.org>,
rcu <rcu@vger.kernel.org>, Will Deacon <will@kernel.org>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH RFC v2] rcu/segcblist: Add counters to segcblist datastructure
Date: Wed, 29 Jul 2020 09:28:21 +0800 [thread overview]
Message-ID: <20200729012821.GA136701@tardis> (raw)
In-Reply-To: <20200727230323.GA3390623@google.com>
[-- Attachment #1: Type: text/plain, Size: 2441 bytes --]
On Mon, Jul 27, 2020 at 07:03:23PM -0400, Joel Fernandes wrote:
> On Mon, Jul 27, 2020 at 09:49:25PM +0800, Boqun Feng wrote:
> [...]
> > So C11 features are available to gnu89 as extensions, also I tried to
> > compile the following code with -std=gnu89:
> >
> > #include <stdio.h>
> >
> > typedef struct {
> > int a;
> > } atomic_t;
> >
> > void g(void) {
> > printf("this is g\n");
> > }
> >
> > void h(void) {
> > printf("this is f\n");
> > }
> >
> > #define gen(x) _Generic((x), atomic_t : h(), int : g())
> >
> > int main(void) {
> > int a;
> > atomic_t b;
> > gen(a);
> > gen(b);
> > gen(b);
> > }
> >
> > , and it worked.
> >
> > Besides, please note that in include/linux/compiler_types.h, _Generic is
> > already used.
>
> > > > With these primitives introduced, you can avoid () to add those
> > > > rcu_segcblist_*_seglen() which have #ifdefs in them. Of course, an
> > > > alternative would be that we implement rcu_segcblist_*_seglen() using
> > > > _Generic, but I think someone else may have the similar problems or
> > > > requirement (already or in the future), so it might be worthwhile to
> > > > introduce the gen_ primitives for broader usage.
> > >
> > > One issue is code using memory barriers around the operation, such as
> > > in rcu_segcblist_add_len() where you use smp_mb__before_atomic() for
> > > the atomic version, and regular smp_mb() for the non-atomic version.
> > > So ifdef will still exist to some degree.
> > >
> >
> > Right, I think we can have two functions: long_add_mb() and
> > atomic_long_add_mb(), this part is similar to ifdef approach, but we can
> > make a gen_long_add_mb() based on these two functions, and
> > gen_long_add_mb() simply switches between those functions according to
> > the actual type of the field, which I think is better than ifdef
> > approach at readability and maintenance.
>
> Thanks for clarification. I agree with your idea, would you be able to write
> a patch to add the helpers my patch can use?
>
Sure, I will send a prototype to see others' feelings about this, will
try to get that done by a day or two, so hopefully it won't block your
work ;-)
Regards,
Boqun
> If others are Ok with your idea, I can go ahead and use your helpers.
>
> (I could write the helpers myself as well, next time I send the patch).
>
> thanks,
>
> - Joel
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-07-29 1:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-19 3:55 [PATCH RFC v2] rcu/segcblist: Add counters to segcblist datastructure Joel Fernandes (Google)
2020-07-19 4:06 ` Joel Fernandes
2020-07-19 4:18 ` Joel Fernandes
2020-07-20 8:22 ` boqun.feng
2020-07-24 19:34 ` Joel Fernandes
2020-07-27 13:49 ` Boqun Feng
2020-07-27 23:03 ` Joel Fernandes
2020-07-29 1:28 ` Boqun Feng [this message]
2020-07-20 0:53 ` [rcu/segcblist] af49115178: WARNING:at_kernel/rcu/tree.c:#rcu_do_batch kernel test robot
2020-07-27 23:21 ` Joel Fernandes
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=20200729012821.GA136701@tardis \
--to=boqun.feng@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=rcu@vger.kernel.org \
--cc=will@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.