1
0
Fork 0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-01-22 07:53:11 -05:00
linux/drivers/cpufreq
Linus Torvalds 1d6d399223 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.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEd76+gtGM8MbftQlOhSRUR1COjHcFAmeNf8gACgkQhSRUR1CO
 jHedQQ/+IxTjjqQiItzrq41TES2S0desHDq8lNJFb7rsR/DtKFyLx3s67cOYV+cM
 Yx54QHg2m/Fz4nXMQ7Po5ygOtJGCKBc5C5QQy7y0lVKeTQK+daDfEtBSa3oG7j3C
 u+E3tTY6qxkbCzymUyaKkHN4/ay2vLvjFS50luV7KMyI3x47Aji+t7VdCX4LCPP2
 eAwOALWD0+7qLJ/VF6gsmQLKA4Qx7PQAzBa3KSBmUN9UcN8Gk1bQHCTIQKDHP9LQ
 v8BXrNZtYX1o2+snNYpX2z6/ECjxkdwriOgqqZY5306hd9RAQ1u46Dx3byrIqjGn
 ULG/XQ2istPyhTqb/h+RbrobdOcwEUIeqk8hRRbBXE8bPpqUz9EMuaCMxWDbQjgH
 NTuKG4ifKJ/IqstkkuDkdOiByE/ysMmwqrTXgSnu2ITNL9yY3BEgFbvA95hgo42s
 f7QCxEfZb1MHcNEMENSMwM3xw5lLMGMpxVZcMQ3gLwyotMBRrhFZm1qZJG7TITYW
 IDIeCbH4JOMdQwLs3CcWTXio0N5/85NhRNFV+IDn96OrgxObgnMtV8QwNgjXBAJ5
 wGeJWt8s34W1Zo3qS9gEuVzEhW4XaxISQQMkHe8faKkK6iHmIB/VjSQikDwwUNQ/
 AspYj82RyWBCDZsqhiYh71kpxjvS6Xp0bj39Ce1sNsOnuksxKkQ=
 =g8In
 -----END PGP SIGNATURE-----

Merge tag 'kthread-for-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks

Pull kthread updates from Frederic Weisbecker:
 "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"

* tag 'kthread-for-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks:
  kthread: modify kernel-doc function name to match code
  rcu: Use kthread preferred affinity for RCU exp kworkers
  treewide: Introduce kthread_run_worker[_on_cpu]()
  kthread: Unify kthread_create_on_cpu() and kthread_create_worker_on_cpu() automatic format
  rcu: Use kthread preferred affinity for RCU boost
  kthread: Implement preferred affinity
  mm: Create/affine kswapd to its preferred node
  mm: Create/affine kcompactd to its preferred node
  kthread: Default affine kthread to its preferred NUMA node
  kthread: Make sure kthread hasn't started while binding it
  sched,arm64: Handle CPU isolation on last resort fallback rq selection
  arm64: Exclude nohz_full CPUs from 32bits el0 support
  lib: test_objpool: Use kthread_run_on_cpu()
  kallsyms: Use kthread_run_on_cpu()
  soc/qman: test: Use kthread_run_on_cpu()
  arm/bL_switcher: Use kthread_run_on_cpu()
2025-01-21 17:10:05 -08:00
..
acpi-cpufreq.c cpufreq: ACPI: Simplify MSR read on the boot CPU 2024-11-12 21:42:29 +01:00
amd-pstate-trace.c
amd-pstate-trace.h
amd-pstate-ut.c cpufreq/amd-pstate-ut: Add fix for min freq unit test 2024-10-28 14:54:36 -05:00
amd-pstate.c cpufreq/amd-pstate: Use boost numerator for upper bound of frequencies 2024-12-10 10:17:43 -06:00
amd-pstate.h cpufreq/amd-pstate: Export symbols for changing modes 2024-09-11 10:23:23 -05:00
amd_freq_sensitivity.c
apple-soc-cpufreq.c cpufreq: Fix warning on unused of_device_id tables for !CONFIG_OF 2024-09-04 20:43:59 +05:30
armada-8k-cpufreq.c cpufreq: armada-8k: Avoid excessive stack usage 2024-08-07 12:11:46 +05:30
armada-37xx-cpufreq.c
bmips-cpufreq.c cpufreq: Make cpufreq_driver->exit() return void 2024-07-09 08:45:30 +05:30
brcmstb-avs-cpufreq.c ARM cpufreq updates for 6.13 2024-11-19 21:35:14 +01:00
cppc_cpufreq.c treewide: Introduce kthread_run_worker[_on_cpu]() 2025-01-08 18:15:03 +01:00
cpufreq-dt-platdev.c cpufreq: sun50i: add a100 cpufreq support 2024-11-11 11:24:42 +05:30
cpufreq-dt.c cpufreq: Switch back to struct platform_driver::remove() 2024-10-28 12:24:39 +01:00
cpufreq-dt.h
cpufreq-nforce2.c
cpufreq.c cpufreq: use proper units for frequency 2024-10-28 12:24:29 +01:00
cpufreq_conservative.c
cpufreq_governor.c
cpufreq_governor.h
cpufreq_governor_attr_set.c
cpufreq_ondemand.c
cpufreq_ondemand.h
cpufreq_performance.c
cpufreq_powersave.c
cpufreq_stats.c
cpufreq_userspace.c
davinci-cpufreq.c cpufreq: Switch back to struct platform_driver::remove() 2024-10-28 12:24:39 +01:00
e_powersaver.c cpufreq: Make cpufreq_driver->exit() return void 2024-07-09 08:45:30 +05:30
elanfreq.c
freq_table.c
gx-suspmod.c
highbank-cpufreq.c
imx-cpufreq-dt.c cpufreq: Switch back to struct platform_driver::remove() 2024-10-28 12:24:39 +01:00
imx6q-cpufreq.c cpufreq: Switch back to struct platform_driver::remove() 2024-10-28 12:24:39 +01:00
intel_pstate.c Merge back cpufreq material for 6.13 2024-11-14 12:23:32 +01:00
Kconfig cpufreq: Move endif to the end of Kconfig file 2025-01-14 20:54:04 +01:00
Kconfig.arm cpufreq: Enable COMPILE_TEST on Arm drivers 2024-09-04 20:43:58 +05:30
Kconfig.powerpc cpufreq: maple: Remove maple driver 2024-11-13 12:02:23 +11:00
Kconfig.x86
kirkwood-cpufreq.c cpufreq: Switch back to struct platform_driver::remove() 2024-10-28 12:24:39 +01:00
longhaul.c
longhaul.h
longrun.c
loongson2_cpufreq.c cpufreq: loongson2: Unregister platform_driver on failure 2024-10-16 15:20:21 +05:30
loongson3_cpufreq.c ARM cpufreq updates for 6.13 2024-11-19 21:35:14 +01:00
Makefile powerpc updates for 6.13 2024-11-23 10:44:31 -08:00
mediatek-cpufreq-hw.c ARM cpufreq updates for 6.13 2024-11-19 21:35:14 +01:00
mediatek-cpufreq.c cpufreq: Fix warning on unused of_device_id tables for !CONFIG_OF 2024-09-04 20:43:59 +05:30
mvebu-cpufreq.c
omap-cpufreq.c cpufreq: Switch back to struct platform_driver::remove() 2024-10-28 12:24:39 +01:00
p4-clockmod.c
pasemi-cpufreq.c cpufreq: powerpc: add missing MODULE_DESCRIPTION() macros 2024-08-02 14:45:20 +02:00
pcc-cpufreq.c cpufreq: Switch back to struct platform_driver::remove() 2024-10-28 12:24:39 +01:00
pmac32-cpufreq.c
pmac64-cpufreq.c ARM cpufreq updates for 6.12 2024-09-06 20:50:46 +02:00
powernow-k6.c cpufreq: Make cpufreq_driver->exit() return void 2024-07-09 08:45:30 +05:30
powernow-k7.c cpufreq: Make cpufreq_driver->exit() return void 2024-07-09 08:45:30 +05:30
powernow-k7.h
powernow-k8.c cpufreq: Make cpufreq_driver->exit() return void 2024-07-09 08:45:30 +05:30
powernow-k8.h
powernv-cpufreq.c ARM cpufreq updates for 6.12 2024-09-06 20:50:46 +02:00
ppc_cbe_cpufreq.c cpufreq: powerpc: add missing MODULE_DESCRIPTION() macros 2024-08-02 14:45:20 +02:00
ppc_cbe_cpufreq.h
ppc_cbe_cpufreq_pervasive.c
ppc_cbe_cpufreq_pmi.c
pxa2xx-cpufreq.c
pxa3xx-cpufreq.c
qcom-cpufreq-hw.c cpufreq: Switch back to struct platform_driver::remove() 2024-10-28 12:24:39 +01:00
qcom-cpufreq-nvmem.c pmdomain core: 2024-11-20 12:44:59 -08:00
qoriq-cpufreq.c cpufreq: Switch back to struct platform_driver::remove() 2024-10-28 12:24:39 +01:00
raspberrypi-cpufreq.c cpufreq: Switch back to struct platform_driver::remove() 2024-10-28 12:24:39 +01:00
s3c64xx-cpufreq.c
s5pv210-cpufreq.c
sa1110-cpufreq.c
sc520_freq.c
scmi-cpufreq.c cpufreq: scmi: Fix cleanup path when boost enablement fails 2024-11-11 09:18:25 +05:30
scpi-cpufreq.c cpufreq: Switch back to struct platform_driver::remove() 2024-10-28 12:24:39 +01:00
sh-cpufreq.c cpufreq: Make cpufreq_driver->exit() return void 2024-07-09 08:45:30 +05:30
sparc-us2e-cpufreq.c cpufreq: Make cpufreq_driver->exit() return void 2024-07-09 08:45:30 +05:30
sparc-us3-cpufreq.c cpufreq: Make cpufreq_driver->exit() return void 2024-07-09 08:45:30 +05:30
spear-cpufreq.c cpufreq: spear: Use of_property_for_each_u32() instead of open coding 2024-08-07 12:11:45 +05:30
speedstep-centrino.c ARM cpufreq updates for 6.11 2024-07-09 17:58:20 +02:00
speedstep-ich.c
speedstep-lib.c
speedstep-lib.h
speedstep-smi.c
sti-cpufreq.c cpufreq: Use of_property_present() 2024-08-07 12:11:45 +05:30
sun50i-cpufreq-nvmem.c ARM cpufreq updates for 6.13 2024-11-19 21:35:14 +01:00
tegra20-cpufreq.c
tegra124-cpufreq.c
tegra186-cpufreq.c cpufreq: Switch back to struct platform_driver::remove() 2024-10-28 12:24:39 +01:00
tegra194-cpufreq.c cpufreq: Switch back to struct platform_driver::remove() 2024-10-28 12:24:39 +01:00
ti-cpufreq.c cpufreq: ti-cpufreq: Remove revision offsets in AM62 family 2024-10-10 12:54:42 +05:30
vexpress-spc-cpufreq.c cpufreq: Switch back to struct platform_driver::remove() 2024-10-28 12:24:39 +01:00
virtual-cpufreq.c cpufreq: add virtual-cpufreq driver 2024-10-29 12:05:14 +05:30