From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Huang Ying <ying.huang@intel.com>
Cc: linux-kernel@vger.kernel.org, Andi Kleen <andi@firstfloor.org>,
Peter Zijlstra <peterz@infradead.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>, Chris Mason <chris.mason@oracle.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [PATCH -v10 0/4] Lock-less list
Date: Thu, 20 Jan 2011 00:55:23 -0500 [thread overview]
Message-ID: <20110120055523.GA27974@Krystal> (raw)
In-Reply-To: <1295245019-7816-1-git-send-email-ying.huang@intel.com>
Hi Huang,
I just found out about your lockless linked-list implementation, it looks
interesting. Paul McKenney and myself have created a similar implementation for
userspace within the Userspace RCU project, you might want to have a look (it's
LGPLv2.1).
One point about semantic: a singly-linked list for which you can either delete
the first element or all the elements should probably be called a stack ? I'm
therefore going to refer to "push/pop" in this email rather than "add/delete".
We've got two linked-list stack implementations in the userspace RCU tree:
One has wait-free push, and blocking pop. Useful if you can afford to block when
you pop from the list. There is no restriction on the number of concurrent
push/pop to/from the list. The code is at:
http://git.lttng.org/?p=userspace-rcu.git;a=blob;f=urcu/wfstack-static.h
The other has lock-free push and pop, no restriction on the number of concurrent
push/pop, but uses a clever trick that ensures that the cmpxchg loop will never
see a re-used pointer by using a RCU read-side to protect from memory reclaim.
It therefore requires that the memory used for the list must only be freed after
a RCU grace period. The code is at:
http://git.lttng.org/?p=userspace-rcu.git;a=blob;f=urcu/rculfstack-static.h
We could probably extend this to allow popping all stack entries in one go, but
I haven't given it much thought.
We also have queue implementations (enqueue at head, dequeue at tail). The first
has wait-free enqueue/blocking dequeue and the second has lock-free
enqueue/dequeue. We use the wait-free enqueue/blocking dequeue queue to push
RCU callbacks when call_rcu() is executed from real-time threads, and we then
dequeue the callbacks to execute with a blocking thread. The lock-free
enqueue/dequeue queue also needs a reference count on the "dummy" node it keeps
in addition to use RCU to delay memory reclamation (see comments in the code).
wait-free enqueue/blocking dequeue:
http://git.lttng.org/?p=userspace-rcu.git;a=blob;f=urcu/wfqueue-static.h
lock-free enqueue/dequeue (beware, the refcounting makes the API less elegant
than the other implementations):
http://git.lttng.org/?p=userspace-rcu.git;a=blob;f=urcu/rculfqueue-static.h
Hoping this might be helpful to you,
Mathieu
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2011-01-20 5:55 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-17 6:16 [PATCH -v10 0/4] Lock-less list Huang Ying
2011-01-17 6:16 ` [PATCH -v10 1/4] Add Kconfig option ARCH_HAVE_NMI_SAFE_CMPXCHG Huang Ying
2011-01-17 6:16 ` [PATCH -v10 2/4] lib, Add lock-less NULL terminated single list Huang Ying
2011-01-17 6:16 ` [PATCH -v10 3/4] irq_work, Use llist in irq_work Huang Ying
2011-01-17 6:16 ` [PATCH -v10 4/4] net, rds, Replace xlist in net/rds/xlist.h with llist Huang Ying
2011-01-19 21:55 ` [PATCH -v10 0/4] Lock-less list Andrew Morton
2011-01-20 0:45 ` Huang Ying
2011-01-20 0:52 ` Andrew Morton
2011-01-20 1:09 ` Huang Ying
2011-01-20 10:44 ` Peter Zijlstra
2011-01-20 11:18 ` huang ying
2011-01-20 11:27 ` Peter Zijlstra
2011-01-20 11:57 ` huang ying
2011-01-20 12:14 ` Ingo Molnar
2011-01-20 12:49 ` huang ying
2011-01-20 13:06 ` Ingo Molnar
2011-01-20 13:24 ` huang ying
2011-01-20 13:36 ` Borislav Petkov
2011-01-20 14:11 ` Ingo Molnar
2011-01-20 17:59 ` Luck, Tony
2011-01-20 22:53 ` Mike Waychison
2011-01-21 17:39 ` Tim Hockin
2011-01-21 18:01 ` Borislav Petkov
2011-01-20 5:55 ` Mathieu Desnoyers [this message]
2011-01-20 8:57 ` huang ying
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=20110120055523.GA27974@Krystal \
--to=mathieu.desnoyers@efficios.com \
--cc=andi@firstfloor.org \
--cc=chris.mason@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
--cc=ying.huang@intel.com \
/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