Skip to content

kthread: Introduce preferred affinity

Frederic Weisbecker linux-arm-kernel linux-mm linux-scsi linuxppc-dev lkml rcu 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest20 patches 18 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/20arm/bL_switcher: Use kthread_run_on_cpu()arch/arm/common/bL_switcher.c+4 -62 replies
2/20x86/resctrl: Use kthread_run_on_cpu()arch/x86/kernel/cpu/resctrl/pseudo_lock.c+8 -201 reply
3/20firmware: stratix10-svc: Use kthread_run_on_cpu()drivers/firmware/stratix10-svc.c+3 -60 replies
4/20scsi: bnx2fc: Use kthread_create_on_cpu()drivers/scsi/bnx2fc/bnx2fc_fcoe.c+2 -50 replies
5/20scsi: bnx2i: Use kthread_create_on_cpu()drivers/scsi/bnx2i/bnx2i_init.c+2 -50 replies
6/20scsi: qedi: Use kthread_create_on_cpu()drivers/scsi/qedi/qedi_main.c+2 -40 replies
7/20soc/qman: test: Use kthread_run_on_cpu()drivers/soc/fsl/qbman/qman_test_stash.c+2 -40 replies
8/20kallsyms: Use kthread_run_on_cpu()kernel/kallsyms_selftest.c+1 -30 replies
9/20lib: test_objpool: Use kthread_run_on_cpu()lib/test_objpool.c+5 -140 replies
10/20net: pktgen: Use kthread_create_on_node()net/core/pktgen.c+2 -50 replies
11/20kthread: Make sure kthread hasn't started while binding itkernel/kthread.c+7 -01 reply
12/20kthread: Implement preferred affinityinclude/linux/cpuhotplug.h include/linux/kthread.h kernel/kthread.c+123 -08 replies
13/20mm: Make Kcompactd use kthread's preferred affinitymm/compaction.c+3 -401 reply
14/20mm: Allocate kcompactd on its nodemm/compaction.c+1 -12 replies
15/20mm: Make kswapd use kthread's preferred affinitymm/vmscan.c+3 -51 reply
16/20mm: Allocate kswapd on its nodemm/vmscan.c+1 -11 reply
17/20rcu: Use kthread preferred affinity for RCU boostkernel/rcu/tree.c kernel/rcu/tree_plugin.h+21 -170 replies
18/20kthread: Unify kthread_create_on_cpu() and kthread_create_worker_on_cpu() automatic formatfs/erofs/zdata.c include/linux/kthread.h kernel/kthread.c+52 -300 replies
19/20treewide: Introduce kthread_run_worker[_on_cpu]()arch/x86/kvm/i8254.c crypto/crypto_engine.c drivers/cpufreq/cppc_cpufreq.c +29 more+82 -650 replies
20/20rcu: Use kthread preferred affinity for RCU exp kworkerskernel/rcu/tree.c+19 -861 reply

Reviews trailers per patch

9 of 20 patches have a Reviewed-by or Acked-by.

PatchPaul E. McKenneyVlastimil BabkaReinette ChatreDave MartinNicolas Pitre
1/20R-b A-b
2/20A-b
3/20
4/20
5/20
6/20
7/20
8/20
9/20
10/20
11/20A-b
12/20A-b
13/20A-b
14/20A-b
15/20A-b
16/20A-b
17/20
18/20
19/20
20/20A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v1 thread

Cover letter [PATCH 00/20] kthread: Introduce preferred affinity

Affining kthreads follow either of three existing different patterns:

1) Per-CPU kthreads must stay affine to a single CPU and never execute relevant code on any other CPU. This is currently handled by smpboot code which takes care of CPU-hotplug operations.

2) Kthreads that _have_ to be affine to a specific set of CPUs and can't run anywhere else. The affinity is set through kthread_bind_mask() and the subsystem takes care by itself to handle CPU-hotplug operations.

3) Kthreads that have a _preferred_ affinity but that can run anywhere without breaking correctness. Userspace can overwrite the affinity. It is set manually like any other task and CPU-hotplug is supposed to be handled by the relevant subsystem so that the task is properly reaffined whenever a given CPU from the preferred affinity comes up or down. Also care must be taken so that the preferred affinity doesn't cross housekeeping cpumask boundaries.

Currently the preferred affinity pattern has at least 4 identified users, with more or less success when it comes to handle CPU-hotplug operations and housekeeping cpumask.

This is a infrastructure proposal to handle this (after cleanups from 01 to 10).

Frederic Weisbecker (20):
arm/bL_switcher: Use kthread_run_on_cpu() x86/resctrl: Use kthread_run_on_cpu()
firmware: stratix10-svc: Use kthread_run_on_cpu()
scsi: bnx2fc: Use kthread_create_on_cpu()
scsi: bnx2i: Use kthread_create_on_cpu()
scsi: qedi: Use kthread_create_on_cpu() soc/qman: test: Use kthread_run_on_cpu()
kallsyms: Use kthread_run_on_cpu()
lib: test_objpool: Use kthread_run_on_cpu()
net: pktgen: Use kthread_create_on_node()
kthread: Make sure kthread hasn't started while binding it
kthread: Implement preferred affinity
mm: Make Kcompactd use kthread's preferred affinity
mm: Allocate kcompactd on its node
mm: Make kswapd use kthread's preferred affinity
mm: Allocate kswapd on its node
rcu: Use kthread preferred affinity for RCU boost
kthread: Unify kthread_create_on_cpu() and
kthread_create_worker_on_cpu() automatic format
treewide: Introduce kthread_run_worker[_on_cpu]()
rcu: Use kthread preferred affinity for RCU exp kworkers

 arch/arm/common/bL_switcher.c                 |  10 +-
 arch/x86/kernel/cpu/resctrl/pseudo_lock.c     |  28 +--
 arch/x86/kvm/i8254.c                          |   2 +-
 crypto/crypto_engine.c                        |   2 +-
 drivers/cpufreq/cppc_cpufreq.c                |   2 +-
 drivers/firmware/stratix10-svc.c              |   9 +-
 drivers/gpu/drm/drm_vblank_work.c             |   2 +-
 .../drm/i915/gem/selftests/i915_gem_context.c |   2 +-
 drivers/gpu/drm/i915/gt/selftest_execlists.c  |   2 +-
 drivers/gpu/drm/i915/gt/selftest_hangcheck.c  |   2 +-
 drivers/gpu/drm/i915/gt/selftest_slpc.c       |   2 +-
 drivers/gpu/drm/i915/selftests/i915_request.c |   8 +-
 drivers/gpu/drm/msm/disp/msm_disp_snapshot.c  |   2 +-
 drivers/gpu/drm/msm/msm_atomic.c              |   2 +-
 drivers/gpu/drm/msm/msm_gpu.c                 |   2 +-
 drivers/gpu/drm/msm/msm_kms.c                 |   2 +-
 .../platform/chips-media/wave5/wave5-vpu.c    |   2 +-
 drivers/net/dsa/mv88e6xxx/chip.c              |   2 +-
 drivers/net/ethernet/intel/ice/ice_dpll.c     |   2 +-
 drivers/net/ethernet/intel/ice/ice_gnss.c     |   2 +-
 drivers/net/ethernet/intel/ice/ice_ptp.c      |   2 +-
 drivers/platform/chrome/cros_ec_spi.c         |   2 +-
 drivers/ptp/ptp_clock.c                       |   2 +-
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c             |   7 +-
 drivers/scsi/bnx2i/bnx2i_init.c               |   7 +-
 drivers/scsi/qedi/qedi_main.c                 |   6 +-
 drivers/soc/fsl/qbman/qman_test_stash.c       |   6 +-
 drivers/spi/spi.c                             |   2 +-
 drivers/usb/typec/tcpm/tcpm.c                 |   2 +-
 drivers/vdpa/vdpa_sim/vdpa_sim.c              |   2 +-
 drivers/watchdog/watchdog_dev.c               |   2 +-
 fs/erofs/zdata.c                              |   2 +-
 include/linux/cpuhotplug.h                    |   1 +
 include/linux/kthread.h                       |  56 +++++-
 kernel/kallsyms_selftest.c                    |   4 +-
 kernel/kthread.c                              | 162 +++++++++++++++---
 kernel/rcu/tree.c                             |  94 ++--------
 kernel/rcu/tree_plugin.h                      |  11 +-
 kernel/workqueue.c                            |   2 +-
 lib/test_objpool.c                            |  19 +-
 mm/compaction.c                               |  43 +----
 mm/vmscan.c                                   |   8 +-
 net/core/pktgen.c                             |   7 +-
 net/dsa/tag_ksz.c                             |   2 +-
 net/dsa/tag_ocelot_8021q.c                    |   2 +-
 net/dsa/tag_sja1105.c                         |   2 +-
 46 files changed, 284 insertions(+), 258 deletions(-)
Signature · 1 line
2.45.2