[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z42M-Zqd3kBNCfgz@pavilion.home>
Date: Mon, 20 Jan 2025 00:38:33 +0100
From: Frederic Weisbecker <frederic@...nel.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Frederic Weisbecker <frederic@...nel.org>,
Vlastimil Babka <vbabka@...e.cz>, RCU <rcu@...r.kernel.org>,
Michal Hocko <mhocko@...e.com>
Subject: [GIT PULL] kthread updates for v6.14
Hi Linus,
A pull request from me on the topic of kthreads may appear out of
the blue but this "subsystem" has no official maintainer and nobody
loudly volunteered to take these changes. Therefore I'm carrying
these myself.
Thanks.
The following changes since commit fac04efc5c793dccbd07e2d59af9f90b7fc0dca4:
Linux 6.13-rc2 (2024-12-08 14:03:39 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git tags/kthread-for-6.14-rc1
for you to fetch changes up to d8b4bf4ea04dd96fe43f6010c614149aba4c9b91:
kthread: modify kernel-doc function name to match code (2025-01-13 11:33:26 +0100)
----------------------------------------------------------------
Kthreads affinity follow either of 4 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. Affinity here is
a correctness constraint.
2) Some kthreads _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. Affinity here is assumed to be a correctness constraint.
3) Per-node kthreads _prefer_ to be affine to a specific NUMA node. This
is not a correctness constraint but merely a preference in terms of
memory locality. kswapd and kcompactd both fall into this category.
The affinity is set manually like for 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 node comes up.
Also care should be taken so that the node affinity doesn't cross
isolated (nohz_full) cpumask boundaries.
4) Similar to the previous point except kthreads have a _preferred_
affinity different than a node. Both RCU boost kthreads and RCU
exp kworkers fall into this category as they refer to "RCU nodes"
from a distinctly distributed tree.
Currently the preferred affinity patterns (3 and 4) have at least 4
identified users, with more or less success when it comes to handle
CPU-hotplug operations and CPU isolation. Each of which do it in its own
ad-hoc way.
This is an infrastructure proposal to handle this with the following API
changes:
_ kthread_create_on_node() automatically affines the created kthread to
its target node unless it has been set as per-cpu or bound with
kthread_bind[_mask]() before the first wake-up.
- kthread_affine_preferred() is a new function that can be called right
after kthread_create_on_node() to specify a preferred affinity
different than the specified node.
When the preferred affinity can't be applied because the possible
targets are offline or isolated (nohz_full), the kthread is affine
to the housekeeping CPUs (which means to all online CPUs most of the
time or only the non-nohz_full CPUs when nohz_full= is set).
kswapd, kcompactd, RCU boost kthreads and RCU exp kworkers have been
converted, along with a few old drivers.
Summary of the changes:
* Consolidate a bunch of ad-hoc implementations of kthread_run_on_cpu()
* Introduce task_cpu_fallback_mask() that defines the default last
resort affinity of a task to become nohz_full aware
* Add some correctness check to ensure kthread_bind() is always called
before the first kthread wake up.
* Default affine kthread to its preferred node.
* Convert kswapd / kcompactd and remove their halfway working ad-hoc
affinity implementation
* Implement kthreads preferred affinity
* Unify kthread worker and kthread API's style
* Convert RCU kthreads to the new API and remove the ad-hoc affinity
implementation.
----------------------------------------------------------------
Frederic Weisbecker (15):
arm/bL_switcher: Use kthread_run_on_cpu()
soc/qman: test: Use kthread_run_on_cpu()
kallsyms: Use kthread_run_on_cpu()
lib: test_objpool: Use kthread_run_on_cpu()
arm64: Exclude nohz_full CPUs from 32bits el0 support
sched,arm64: Handle CPU isolation on last resort fallback rq selection
kthread: Make sure kthread hasn't started while binding it
kthread: Default affine kthread to its preferred NUMA node
mm: Create/affine kcompactd to its preferred node
mm: Create/affine kswapd to its preferred node
kthread: Implement preferred affinity
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
Randy Dunlap (1):
kthread: modify kernel-doc function name to match code
Documentation/arch/arm64/asymmetric-32bit.rst | 8 +
arch/arm/common/bL_switcher.c | 10 +-
arch/arm64/include/asm/cpufeature.h | 1 +
arch/arm64/include/asm/mmu_context.h | 14 +-
arch/arm64/kernel/cpufeature.c | 15 +-
arch/x86/kvm/i8254.c | 2 +-
crypto/crypto_engine.c | 2 +-
drivers/cpufreq/cppc_cpufreq.c | 2 +-
drivers/gpu/drm/drm_vblank_work.c | 2 +-
.../gpu/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 +-
.../media/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/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 +++++-
include/linux/mmu_context.h | 1 +
kernel/kallsyms_selftest.c | 4 +-
kernel/kthread.c | 203 ++++++++++++++++++---
kernel/rcu/tree.c | 94 ++--------
kernel/rcu/tree_plugin.h | 11 +-
kernel/sched/core.c | 2 +-
kernel/sched/ext.c | 2 +-
kernel/workqueue.c | 2 +-
lib/test_objpool.c | 19 +-
mm/compaction.c | 43 +----
mm/vmscan.c | 8 +-
net/dsa/tag_ksz.c | 2 +-
net/dsa/tag_ocelot_8021q.c | 2 +-
net/dsa/tag_sja1105.c | 2 +-
47 files changed, 341 insertions(+), 221 deletions(-)
Powered by blists - more mailing lists