mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Confused about hlist_unhashed_lockless()
@ 2020-01-31 16:43 Will Deacon
  2020-01-31 16:48 ` Eric Dumazet
  0 siblings, 1 reply; 27+ messages in thread
From: Will Deacon @ 2020-01-31 16:43 UTC (permalink / raw)
  To: edumazet, tglx, paulmck; +Cc: x86, linux-kernel, peterz

Hi folks,

I just ran into c54a2744497d ("list: Add hlist_unhashed_lockless()")
but I'm a bit confused about what it's trying to achieve. It also seems
to have been merged without any callers (even in -next) -- was that
intentional?

My main source of confusion is the lack of memory barriers. For example,
if you look at the following pair of functions:


static inline int hlist_unhashed_lockless(const struct hlist_node *h)
{
	return !READ_ONCE(h->pprev);
}

static inline void hlist_add_before(struct hlist_node *n,
				    struct hlist_node *next)
{
	WRITE_ONCE(n->pprev, next->pprev);
	WRITE_ONCE(n->next, next);
	WRITE_ONCE(next->pprev, &n->next);
	WRITE_ONCE(*(n->pprev), n);
}


Then running these two concurrently on the same node means that
hlist_unhashed_lockless() doesn't really tell you anything about whether
or not the node is reachable in the list (i.e. there is another node
with a next pointer pointing to it). In other words, I think all of
these outcomes are permitted:

	hlist_unhashed_lockless(n)	n reachable in list
	0				0 (No reordering)
	0				1 (No reordering)
	1				0 (No reordering)
	1				1 (Reorder first and last WRITE_ONCEs)

So I must be missing some details about the use-case here. Please could
you enlighten me? The RCU implementation permits only the first three
outcomes afaict, why not use that and leave non-RCU hlist as it was?

Cheers,

Will

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2020-02-03 21:16 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-31 16:43 Confused about hlist_unhashed_lockless() Will Deacon
2020-01-31 16:48 ` Eric Dumazet
2020-01-31 16:57   ` Will Deacon
2020-01-31 17:06     ` Eric Dumazet
2020-01-31 17:20       ` Will Deacon
2020-01-31 17:33         ` Eric Dumazet
2020-01-31 18:32           ` Will Deacon
2020-01-31 19:47           ` Thomas Gleixner
2020-01-31 20:52             ` Paul E. McKenney
2020-01-31 18:43   ` Peter Zijlstra
2020-01-31 18:48     ` Eric Dumazet
2020-01-31 18:52       ` Eric Dumazet
2020-01-31 20:53         ` Paul E. McKenney
2020-01-31 21:04           ` Eric Dumazet
2020-01-31 21:19             ` Paul E. McKenney
2020-02-03 15:45         ` David Laight
2020-02-03 15:54           ` Marco Elver
2020-02-03 16:05             ` David Laight
2020-02-03 17:25               ` Paul E. McKenney
2020-02-03 15:58           ` Paul E. McKenney
2020-02-03 16:02             ` Will Deacon
2020-02-03 17:29               ` Paul E. McKenney
2020-02-03 18:27                 ` Will Deacon
2020-02-03 21:16                   ` Paul E. McKenney
2020-01-31 19:20       ` Marco Elver
2020-01-31 18:52   ` Paul E. McKenney
2020-01-31 18:55     ` Eric Dumazet

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®