<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/lib/llist.c, branch v6.19.11</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.19.11</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.19.11'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2025-05-28T02:40:34+00:00</updated>
<entry>
<title>llist: make llist_add_batch() a static inline</title>
<updated>2025-05-28T02:40:34+00:00</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@kernel.dk</email>
</author>
<published>2025-05-23T19:13:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=375700bab5b150e876e42d894a9a7470881f8a61'/>
<id>urn:sha1:375700bab5b150e876e42d894a9a7470881f8a61</id>
<content type='text'>
The function is small enough that it should be, and it's a (very) hot path
for io_uring.  Doing this actually reduces my vmlinux text size for my
standard build/test box.

Before:
axboe@r7625 ~/g/linux (test)&gt; size vmlinux
   text	   data	    bss	    dec	    hex		filename
19892174 5938310 2470432 28300916 1afd674	vmlinux

After:
axboe@r7625 ~/g/linux (test)&gt; size vmlinux
   text	   data	    bss	    dec	    hex		filename
19891878 5938310 2470436 28300624 1afd550	vmlinux

Link: https://lkml.kernel.org/r/f1d104c6-7ac8-457a-a53d-6bb741421b2f@kernel.dk
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>llist: add llist_del_first_this()</title>
<updated>2023-10-16T16:44:06+00:00</updated>
<author>
<name>NeilBrown</name>
<email>neilb@suse.de</email>
</author>
<published>2023-09-11T14:39:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=8a3e5975ed11dd16d81dc501b514ab01986db94e'/>
<id>urn:sha1:8a3e5975ed11dd16d81dc501b514ab01986db94e</id>
<content type='text'>
llist_del_first_this() deletes a specific entry from an llist, providing
it is at the head of the list.  Multiple threads can call this
concurrently providing they each offer a different entry.

This can be uses for a set of worker threads which are on the llist when
they are idle.  The head can always be woken, and when it is woken it
can remove itself, and possibly wake the next if there is an excess of
work to do.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>llist: avoid extra memory read in llist_add_batch</title>
<updated>2022-11-18T21:55:06+00:00</updated>
<author>
<name>Uros Bizjak</name>
<email>ubizjak@gmail.com</email>
</author>
<published>2022-10-17T14:52:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6a6d7602caec1b49dda423b0d15a8c4f72c9c73d'/>
<id>urn:sha1:6a6d7602caec1b49dda423b0d15a8c4f72c9c73d</id>
<content type='text'>
try_cmpxchg implicitly assigns old head-&gt;first value to "first" when
cmpxchg fails. There is no need to re-read the value in the loop.

Link: https://lkml.kernel.org/r/20221017145226.4044-1-ubizjak@gmail.com
Signed-off-by: Uros Bizjak &lt;ubizjak@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>llist: use try_cmpxchg in llist_add_batch and llist_del_first</title>
<updated>2022-09-12T04:55:06+00:00</updated>
<author>
<name>Uros Bizjak</name>
<email>ubizjak@gmail.com</email>
</author>
<published>2022-07-12T14:49:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=4f1d2a030db09af4d21695983674a18633cd0ffb'/>
<id>urn:sha1:4f1d2a030db09af4d21695983674a18633cd0ffb</id>
<content type='text'>
Use try_cmpxchg instead of cmpxchg (*ptr, old, new) == old in
llist_add_batch and llist_del_first.  x86 CMPXCHG instruction returns
success in ZF flag, so this change saves a compare after cmpxchg.

Also, try_cmpxchg implicitly assigns old *ptr value to "old" when cmpxchg
fails, enabling further code simplifications.

No functional change intended.

Link: https://lkml.kernel.org/r/20220712144917.4497-1-ubizjak@gmail.com
Signed-off-by: Uros Bizjak &lt;ubizjak@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333</title>
<updated>2019-06-05T15:37:06+00:00</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2019-05-29T23:57:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=4505153954fdb1465d2b178288a9bf646f2a2166'/>
<id>urn:sha1:4505153954fdb1465d2b178288a9bf646f2a2166</id>
<content type='text'>
Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 as
  published by the free software foundation this program is
  distributed in the hope that it will be useful but without any
  warranty without even the implied warranty of merchantability or
  fitness for a particular purpose see the gnu general public license
  for more details you should have received a copy of the gnu general
  public license along with this program if not write to the free
  software foundation inc 59 temple place suite 330 boston ma 02111
  1307 usa

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 136 file(s).

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Alexios Zavras &lt;alexios.zavras@intel.com&gt;
Reviewed-by: Allison Randal &lt;allison@lohutok.net&gt;
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190530000436.384967451@linutronix.de
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE()</title>
<updated>2017-10-25T09:01:08+00:00</updated>
<author>
<name>Mark Rutland</name>
<email>mark.rutland@arm.com</email>
</author>
<published>2017-10-23T21:07:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6aa7de059173a986114ac43b8f50b297a86f09a8'/>
<id>urn:sha1:6aa7de059173a986114ac43b8f50b297a86f09a8</id>
<content type='text'>
Please do not apply this to mainline directly, instead please re-run the
coccinelle script shown below and apply its output.

For several reasons, it is desirable to use {READ,WRITE}_ONCE() in
preference to ACCESS_ONCE(), and new code is expected to use one of the
former. So far, there's been no reason to change most existing uses of
ACCESS_ONCE(), as these aren't harmful, and changing them results in
churn.

However, for some features, the read/write distinction is critical to
correct operation. To distinguish these cases, separate read/write
accessors must be used. This patch migrates (most) remaining
ACCESS_ONCE() instances to {READ,WRITE}_ONCE(), using the following
coccinelle script:

----
// Convert trivial ACCESS_ONCE() uses to equivalent READ_ONCE() and
// WRITE_ONCE()

// $ make coccicheck COCCI=/home/mark/once.cocci SPFLAGS="--include-headers" MODE=patch

virtual patch

@ depends on patch @
expression E1, E2;
@@

- ACCESS_ONCE(E1) = E2
+ WRITE_ONCE(E1, E2)

@ depends on patch @
expression E;
@@

- ACCESS_ONCE(E)
+ READ_ONCE(E)
----

Signed-off-by: Mark Rutland &lt;mark.rutland@arm.com&gt;
Signed-off-by: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: davem@davemloft.net
Cc: linux-arch@vger.kernel.org
Cc: mpe@ellerman.id.au
Cc: shuah@kernel.org
Cc: snitzer@redhat.com
Cc: thor.thayer@linux.intel.com
Cc: tj@kernel.org
Cc: viro@zeniv.linux.org.uk
Cc: will.deacon@arm.com
Link: http://lkml.kernel.org/r/1508792849-3115-19-git-send-email-paulmck@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/llist.c: fix data race in llist_del_first</title>
<updated>2015-11-07T01:50:42+00:00</updated>
<author>
<name>Dmitry Vyukov</name>
<email>dvyukov@google.com</email>
</author>
<published>2015-11-07T00:31:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=2cf12f821cd4f996bfabeec23d8f25e7a2052a28'/>
<id>urn:sha1:2cf12f821cd4f996bfabeec23d8f25e7a2052a28</id>
<content type='text'>
llist_del_first reads entry-&gt;next, but it did not acquire visibility over
the entry node.  As the result it can get a stale value of entry-&gt;next
(e.g.  NULL or whatever garbage was there before the appending thread
wrote correct value).  And then commit that value as llist head with
cmpxchg.  That will corrupt llist.

Note there is a control-dependency between read of head-&gt;first and read of
entry-&gt;next, but it does not make the code correct.  Kernel memory model
unambiguously says: "A load-load control dependency requires a full read
memory barrier".

Use smp_load_acquire to acquire visibility over the entry node.

The data race was found with KernelThreadSanitizer (KTSAN).

Here is an example of KTSAN report:

ThreadSanitizer: data-race in llist_del_first

Read of size 1 by thread T389 (K2630, CPU0):
 [&lt;ffffffff8156b8a9&gt;] llist_del_first+0x39/0x70 lib/llist.c:74
 [&lt;     inlined    &gt;] tty_buffer_alloc drivers/tty/tty_buffer.c:181
 [&lt;ffffffff81664af4&gt;] __tty_buffer_request_room+0xb4/0x250 drivers/tty/tty_buffer.c:292
 [&lt;ffffffff81664e6c&gt;] tty_insert_flip_string_fixed_flag+0x6c/0x150 drivers/tty/tty_buffer.c:337
 [&lt;     inlined    &gt;] tty_insert_flip_string include/linux/tty_flip.h:35
 [&lt;ffffffff81667422&gt;] pty_write+0x72/0xc0 drivers/tty/pty.c:110
 [&lt;     inlined    &gt;] process_output_block drivers/tty/n_tty.c:611
 [&lt;ffffffff8165c016&gt;] n_tty_write+0x346/0x7f0 drivers/tty/n_tty.c:2401
 [&lt;     inlined    &gt;] do_tty_write drivers/tty/tty_io.c:1159
 [&lt;ffffffff816568df&gt;] tty_write+0x21f/0x3f0 drivers/tty/tty_io.c:1245
 [&lt;ffffffff8125f00f&gt;] __vfs_write+0x5f/0x1f0 fs/read_write.c:489
 [&lt;ffffffff8125ff8f&gt;] vfs_write+0xef/0x280 fs/read_write.c:538
 [&lt;     inlined    &gt;] SYSC_write fs/read_write.c:585
 [&lt;ffffffff81261390&gt;] SyS_write+0x70/0xe0 fs/read_write.c:577
 [&lt;ffffffff81ee862e&gt;] entry_SYSCALL_64_fastpath+0x12/0x71 arch/x86/entry/entry_64.S:186

Previous write of size 8 by thread T226 (K761, CPU0):
 [&lt;ffffffff8156b832&gt;] llist_add_batch+0x32/0x70 lib/llist.c:44 (discriminator 16)
 [&lt;     inlined    &gt;] llist_add include/linux/llist.h:180
 [&lt;ffffffff816649fc&gt;] tty_buffer_free+0x6c/0xb0 drivers/tty/tty_buffer.c:221
 [&lt;ffffffff816651e7&gt;] flush_to_ldisc+0x107/0x300 drivers/tty/tty_buffer.c:514
 [&lt;ffffffff810b20ee&gt;] process_one_work+0x47e/0x930 kernel/workqueue.c:2036
 [&lt;ffffffff810b2650&gt;] worker_thread+0xb0/0x900 kernel/workqueue.c:2170
 [&lt;ffffffff810bbe20&gt;] kthread+0x150/0x170 kernel/kthread.c:209
 [&lt;ffffffff81ee8a1f&gt;] ret_from_fork+0x3f/0x70 arch/x86/entry/entry_64.S:526

Signed-off-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Reviewed-by: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Cc: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Cc: Huang Ying &lt;ying.huang@intel.com&gt;
Cc: Konstantin Serebryany &lt;kcc@google.com&gt;
Cc: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Cc: Alexander Potapenko &lt;glider@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>lib/llist.c: remove redundant include</title>
<updated>2015-02-13T02:54:15+00:00</updated>
<author>
<name>Rasmus Villemoes</name>
<email>linux@rasmusvillemoes.dk</email>
</author>
<published>2015-02-12T23:02:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=9b40570bd986128bb8e3c5f6f1abc60e1ad89794'/>
<id>urn:sha1:9b40570bd986128bb8e3c5f6f1abc60e1ad89794</id>
<content type='text'>
This file doesn't seem to use anything provided by linux/interrupt.h or
anything recursively included through that.  Removing it produces
byte-identical output, while reducing .llist.o.cmd from 541 to 156 lines.

Signed-off-by: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>llists-move-llist_reverse_order-from-raid5-to-llistc-fix</title>
<updated>2013-11-15T00:32:22+00:00</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@linux-foundation.org</email>
</author>
<published>2013-11-14T22:32:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=0791a6057cb60d12ec5e3182b99e6ffa8044ee3a'/>
<id>urn:sha1:0791a6057cb60d12ec5e3182b99e6ffa8044ee3a</id>
<content type='text'>
fix comment typo, per Jan

Cc: Christoph Hellwig &lt;hch@lst.de&gt;
Cc: Jan Kara &lt;jack@suse.cz&gt;
Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>llists: move llist_reverse_order from raid5 to llist.c</title>
<updated>2013-11-15T00:32:22+00:00</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@infradead.org</email>
</author>
<published>2013-11-14T22:32:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b89241e8cdb8321c20546d47645a9b65b58113b5'/>
<id>urn:sha1:b89241e8cdb8321c20546d47645a9b65b58113b5</id>
<content type='text'>
Make this useful helper available for other users.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Jan Kara &lt;jack@suse.cz&gt;
Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Cc: Neil Brown &lt;neilb@suse.de&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
