linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET wq/for-6.9] workqueue: Implement BH workqueue and convert several tasklet users
@ 2024-01-30  9:11 Tejun Heo
  2024-01-30  9:11 ` [PATCH 1/8] workqueue: Update lock debugging code Tejun Heo
                   ` (11 more replies)
  0 siblings, 12 replies; 56+ messages in thread
From: Tejun Heo @ 2024-01-30  9:11 UTC (permalink / raw)
  To: torvalds, mpatocka
  Cc: linux-kernel, dm-devel, msnitzer, ignat, damien.lemoal, bob.liu,
	houtao1, peterz, mingo, netdev, allen.lkml, kernel-team

Hello,

The only generic interface to execute asynchronously in the BH context is
tasklet; however, it's marked deprecated and has some design flaws such as
the execution code accessing the tasklet item after the execution is
complete which can lead to subtle use-after-free in certain usage scenarios
and less-developed flush and cancel mechanisms.

Mikulas Patocka recently reported that dm-crypt and dm-crypt are affected by
the access-after-completion issue and suggested adding TASKLET_STATE_ONESHOT
flag which selectively removes post-completion access while significantly
limiting how the tasklet can be used in the following thread:

 http://lkml.kernel.org/r/82b964f0-c2c8-a2c6-5b1f-f3145dc2c8e5@redhat.com

Linus didn't like the approach and suggested extending workqueue to support
execution from atomic context:

 http://lkml.kernel.org/r/CAHk-=wjDW53w4-YcSmgKC5RruiRLHmJ1sXeYdp_ZgVoBw=5byA@mail.gmail.com

As suggested, this patchset implements BH workqueues which are like regular
workqueues but executes work items in the BH (softirq) context and converts
several tasklet users.

- The name bh is used instead of the suggested atomic as it's more in line
  with widely used execution context interface - local_bh_enable/disable()
  and friends.

- The system default BH workqueues - system_bh_wq and system_bh_highpri_wq -
  are provided. As queue-wide flushing doesn't exist in tasklet, all
  existing tasklet users should be able to use the system BH workqueues
  without creating their own.

- BH workqueues currently use tasklet to run the work items to avoid
  priority inversions involving tasklet_hi and WQ_BH | WQ_HIGHPRI. Once all
  tasklet users are converted, tasklet code can be removed and BH workqueues
  can take over its softirqs.

This patchset is on top of wq/for-6.9 (aae17ebb53c ("workqueue: Avoid using
isolated cpus' timers on queue_delayed_work")) and contains the following
eight patches.

 0001-workqueue-Update-lock-debugging-code.patch
 0002-workqueue-Factor-out-init_cpu_worker_pool.patch
 0003-workqueue-Implement-BH-workqueues-to-eventually-repl.patch
 0004-backtracetest-Convert-from-tasklet-to-BH-workqueue.patch
 0005-usb-core-hcd-Convert-from-tasklet-to-BH-workqueue.patch
 0006-net-tcp-tsq-Convert-from-tasklet-to-BH-workqueue.patch
 0007-dm-crypt-Convert-from-tasklet-to-BH-workqueue.patch
 0008-dm-verity-Convert-from-tasklet-to-BH-workqueue.patch

0001-0003 prepare and implement BH workqueues.

0004-0008 convert some tasklet users to BH workqueue. The conversions are
relatively straightforward but are in descending order of confidence.

The patchset is also available in the following git branch.

 git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git wq-bh-v1

diffstat follows. Thanks.

 Documentation/core-api/workqueue.rst |   29 ++++-
 drivers/md/dm-crypt.c                |   36 -------
 drivers/md/dm-verity-target.c        |    8 -
 drivers/md/dm-verity.h               |    2
 drivers/usb/core/hcd.c               |   23 ++--
 include/linux/usb/hcd.h              |    2
 include/linux/workqueue.h            |    9 +
 include/net/tcp.h                    |    2
 kernel/backtracetest.c               |   18 +--
 kernel/workqueue.c                   |  312 ++++++++++++++++++++++++++++++++++++++++++++++++--------------
 kernel/workqueue_internal.h          |    3
 net/ipv4/tcp.c                       |    2
 net/ipv4/tcp_output.c                |   36 +++----
 tools/workqueue/wq_dump.py           |   11 +-
 14 files changed, 335 insertions(+), 158 deletions(-)

--
tejun

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

end of thread, other threads:[~2024-02-29 21:08 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-30  9:11 [PATCHSET wq/for-6.9] workqueue: Implement BH workqueue and convert several tasklet users Tejun Heo
2024-01-30  9:11 ` [PATCH 1/8] workqueue: Update lock debugging code Tejun Heo
2024-01-30  9:11 ` [PATCH 2/8] workqueue: Factor out init_cpu_worker_pool() Tejun Heo
2024-01-30  9:11 ` [PATCH 3/8] workqueue: Implement BH workqueues to eventually replace tasklets Tejun Heo
2024-01-30 17:25   ` Linus Torvalds
2024-02-01 11:02   ` Lai Jiangshan
2024-02-01 21:47     ` Tejun Heo
2024-02-02  1:15   ` [PATCH v2 " Tejun Heo
2024-02-04  2:20     ` Lai Jiangshan
2024-02-04 21:29   ` [PATCH v3 " Tejun Heo
2024-02-05  4:48     ` Hillf Danton
2024-02-05 17:47       ` Tejun Heo
2024-02-26  2:00     ` Boqun Feng
2024-02-26 18:47       ` Tejun Heo
2024-02-27  1:38       ` [PATCH for-6.9] workqueue: Drain BH work items on hot-unplugged CPUs Tejun Heo
2024-02-29 20:37         ` Tejun Heo
2024-02-29 21:07           ` Boqun Feng
2024-01-30  9:11 ` [PATCH 4/8] backtracetest: Convert from tasklet to BH workqueue Tejun Heo
2024-01-30  9:11 ` [PATCH 5/8] usb: core: hcd: " Tejun Heo
2024-01-30 16:38   ` Greg Kroah-Hartman
2024-02-20 17:25   ` Davidlohr Bueso
2024-02-20 17:55     ` Linus Torvalds
2024-02-20 18:19       ` Tejun Heo
2024-02-20 19:36       ` Davidlohr Bueso
2024-01-30  9:11 ` [PATCH 6/8] net: tcp: tsq: " Tejun Heo
2024-02-16  5:31   ` Tejun Heo
2024-02-16  8:23     ` Eric Dumazet
2024-02-16 15:52       ` David Wei
2024-02-16 16:24       ` Tejun Heo
2024-01-30  9:11 ` [PATCH 7/8] dm-crypt: " Tejun Heo
2024-01-30 10:46   ` Sebastian Andrzej Siewior
2024-01-30 15:53     ` Tejun Heo
2024-01-31 21:23   ` Mikulas Patocka
2024-01-30  9:11 ` [PATCH 8/8] dm-verity: " Tejun Heo
2024-01-31 21:19   ` Mikulas Patocka
2024-01-31 21:32     ` Tejun Heo
2024-01-31 22:02       ` Mikulas Patocka
2024-01-31 23:19       ` Linus Torvalds
2024-02-01  0:04         ` Tejun Heo
2024-02-01  0:19           ` Mike Snitzer
2024-02-20 19:44             ` Mike Snitzer
2024-02-20 20:05               ` Tejun Heo
2024-02-22 21:24                 ` Mike Snitzer
2024-02-23 17:22                   ` Tejun Heo
2024-02-01  0:07         ` Mike Snitzer
2024-01-30  9:22 ` [PATCHSET wq/for-6.9] workqueue: Implement BH workqueue and convert several tasklet users Tejun Heo
2024-01-30 10:20 ` Sebastian Andrzej Siewior
2024-01-30 15:50   ` Tejun Heo
2024-01-30 23:37 ` Allen
2024-02-04 21:33 ` Tejun Heo
2024-02-05 20:50   ` Allen
2024-02-05 21:12     ` Tejun Heo
2024-02-05 21:31       ` Allen
2024-02-07 19:02         ` Allen
2024-02-08 16:56           ` Tejun Heo
2024-02-08 19:07             ` Allen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).