From: "Paul E. McKenney" <paulmck@kernel.org>
To: Eric Dumazet <edumazet@google.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
linux-tip-commits@vger.kernel.org,
syzbot <syzkaller@googlegroups.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>
Subject: Re: [tip: timers/core] hrtimer: Annotate lockless access to timer->state
Date: Thu, 7 Nov 2019 08:54:28 -0800 [thread overview]
Message-ID: <20191107165428.GR20975@paulmck-ThinkPad-P72> (raw)
In-Reply-To: <CANn89iLqcqKLRgfn7TDnBr9ZatiJVyezXmmZaeN2f2BT=qFe7Q@mail.gmail.com>
On Thu, Nov 07, 2019 at 08:39:42AM -0800, Eric Dumazet wrote:
> On Thu, Nov 7, 2019 at 8:35 AM Eric Dumazet <edumazet@google.com> wrote:
> >
> > On Thu, Nov 7, 2019 at 8:11 AM Paul E. McKenney <paulmck@kernel.org> wrote:
> > >
> > > OK, so this is due to timer_pending() lockless access to ->entry.pprev
> > > to determine whether or not the timer is on the list. New one on me!
> > >
> > > Given that use case, I don't have an objection to your patch to list.h.
> > >
> > > Except...
> > >
> > > Would it make sense to add a READ_ONCE() to hlist_unhashed()
> > > and to then make timer_pending() invoke hlist_unhashed()? That
> > > would better confine the needed uses of READ_ONCE().
> >
> > Sounds good to me, I had the same idea but was too lazy to look at the
> > history of timer_pending()
> > to check if the pprev pointer check was really the same underlying idea.
>
> Note that forcing READ_ONCE() in hlist_unhashed() might force the compiler
> to read the pprev pointer twice in some cases.
>
> This was one of the reason for me to add skb_queue_empty_lockless()
> variant in include/linux/skbuff.h
Ouch!
> /**
> * skb_queue_empty_lockless - check if a queue is empty
> * @list: queue head
> *
> * Returns true if the queue is empty, false otherwise.
> * This variant can be used in lockless contexts.
> */
> static inline bool skb_queue_empty_lockless(const struct sk_buff_head *list)
> {
> return READ_ONCE(list->next) == (const struct sk_buff *) list;
> }
>
> So maybe add a hlist_unhashed_lockless() to clearly document why
> callers are using the lockless variant ?
That sounds like a reasonable approach to me. There aren't all that
many uses of hlist_unhashed(), so a name change should not be a problem.
Thanx, Paul
next prev parent reply other threads:[~2019-11-07 16:54 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-06 17:48 [PATCH] " Eric Dumazet
2019-11-06 18:09 ` Thomas Gleixner
2019-11-06 18:19 ` Eric Dumazet
2019-11-06 19:15 ` Thomas Gleixner
2019-11-06 20:00 ` Eric Dumazet
2019-11-06 21:06 ` [tip: timers/core] " tip-bot2 for Eric Dumazet
2019-11-06 22:02 ` Eric Dumazet
2019-11-06 22:16 ` Thomas Gleixner
2019-11-06 22:24 ` tip-bot2 for Eric Dumazet
2019-11-06 22:53 ` Eric Dumazet
2019-11-06 22:59 ` Eric Dumazet
2019-11-07 8:52 ` Paul E. McKenney
2019-11-07 15:48 ` Eric Dumazet
2019-11-07 16:11 ` Paul E. McKenney
2019-11-07 16:35 ` Eric Dumazet
2019-11-07 16:39 ` Eric Dumazet
2019-11-07 16:54 ` Paul E. McKenney [this message]
2019-11-07 16:59 ` Eric Dumazet
2019-11-07 17:07 ` Paul E. McKenney
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=20191107165428.GR20975@paulmck-ThinkPad-P72 \
--to=paulmck@kernel.org \
--cc=bp@alien8.de \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=syzkaller@googlegroups.com \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®