Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'smp-core-2026-04-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull SMP core updates from Thomas Gleixner:

- Switch smp_call_on_cpu() to user system_percpu_wq instead of
system_wq a part of the ongoing workqueue restructuring

- Improve the CSD-lock diagnostics for smp_call_function_single() to
provide better debug mechanisms on weakly ordered systems.

- Cache the current CPU number once in smp_call_function*() instead of
retrieving it over and over.

- Add missing kernel-doc comments all over the place

* tag 'smp-core-2026-04-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
smp: Use system_percpu_wq instead of system_wq
smp: Improve smp_call_function_single() CSD-lock diagnostics
smp: Get this_cpu once in smp_call_function
smp: Add missing kernel-doc comments

+66 -36
+23 -19
include/linux/smp.h
··· 73 73 } 74 74 75 75 /** 76 - * on_each_cpu_mask(): Run a function on processors specified by 76 + * on_each_cpu_mask() - Run a function on processors specified by 77 77 * cpumask, which may include the local processor. 78 78 * @mask: The set of cpus to run on (only runs on online subset). 79 79 * @func: The function to run. This must be fast and non-blocking. ··· 239 239 240 240 #endif /* !SMP */ 241 241 242 - /** 242 + /* 243 243 * raw_smp_processor_id() - get the current (unstable) CPU id 244 244 * 245 - * For then you know what you are doing and need an unstable 245 + * raw_smp_processor_id() is arch-specific/arch-defined and 246 + * may be a macro or a static inline function. 247 + * 248 + * For when you know what you are doing and need an unstable 246 249 * CPU id. 247 - */ 248 - 249 - /** 250 - * smp_processor_id() - get the current (stable) CPU id 251 - * 252 - * This is the normal accessor to the CPU id and should be used 253 - * whenever possible. 254 - * 255 - * The CPU id is stable when: 256 - * 257 - * - IRQs are disabled; 258 - * - preemption is disabled; 259 - * - the task is CPU affine. 260 - * 261 - * When CONFIG_DEBUG_PREEMPT; we verify these assumption and WARN 262 - * when smp_processor_id() is used when the CPU id is not stable. 263 250 */ 264 251 265 252 /* ··· 261 274 #ifdef CONFIG_DEBUG_PREEMPT 262 275 extern unsigned int debug_smp_processor_id(void); 263 276 # define smp_processor_id() debug_smp_processor_id() 277 + 264 278 #else 279 + /** 280 + * smp_processor_id() - get the current (stable) CPU id 281 + * 282 + * This is the normal accessor to the CPU id and should be used 283 + * whenever possible. 284 + * 285 + * The CPU id is stable when: 286 + * 287 + * - IRQs are disabled; 288 + * - preemption is disabled; 289 + * - the task is CPU affine. 290 + * 291 + * When CONFIG_DEBUG_PREEMPT=y, we verify these assumptions and WARN 292 + * when smp_processor_id() is used when the CPU id is not stable. 293 + */ 294 + 265 295 # define smp_processor_id() __smp_processor_id() 266 296 #endif 267 297
+43 -17
kernel/smp.c
··· 215 215 /** 216 216 * csd_lock_is_stuck - Has a CSD-lock acquisition been stuck too long? 217 217 * 218 - * Returns @true if a CSD-lock acquisition is stuck and has been stuck 218 + * Returns: @true if a CSD-lock acquisition is stuck and has been stuck 219 219 * long enough for a "non-responsive CSD lock" message to be printed. 220 220 */ 221 221 bool csd_lock_is_stuck(void) ··· 376 376 } 377 377 378 378 static DEFINE_PER_CPU_SHARED_ALIGNED(call_single_data_t, csd_data); 379 + 380 + #ifdef CONFIG_CSD_LOCK_WAIT_DEBUG 381 + static call_single_data_t *get_single_csd_data(int cpu) 382 + { 383 + if (static_branch_unlikely(&csdlock_debug_enabled)) 384 + return per_cpu_ptr(&csd_data, cpu); 385 + return this_cpu_ptr(&csd_data); 386 + } 387 + #else 388 + static call_single_data_t *get_single_csd_data(int cpu) 389 + { 390 + return this_cpu_ptr(&csd_data); 391 + } 392 + #endif 379 393 380 394 void __smp_call_single_queue(int cpu, struct llist_node *node) 381 395 { ··· 639 625 local_irq_restore(flags); 640 626 } 641 627 642 - /* 628 + /** 643 629 * smp_call_function_single - Run a function on a specific CPU 630 + * @cpu: Specific target CPU for this function. 644 631 * @func: The function to run. This must be fast and non-blocking. 645 632 * @info: An arbitrary pointer to pass to the function. 646 633 * @wait: If true, wait until function has completed on other CPUs. 647 634 * 648 - * Returns 0 on success, else a negative status code. 635 + * Returns: %0 on success, else a negative status code. 649 636 */ 650 637 int smp_call_function_single(int cpu, smp_call_func_t func, void *info, 651 638 int wait) ··· 685 670 686 671 csd = &csd_stack; 687 672 if (!wait) { 688 - csd = this_cpu_ptr(&csd_data); 673 + csd = get_single_csd_data(cpu); 689 674 csd_lock(csd); 690 675 } 691 676 692 677 csd->func = func; 693 678 csd->info = info; 694 679 #ifdef CONFIG_CSD_LOCK_WAIT_DEBUG 695 - csd->node.src = smp_processor_id(); 680 + csd->node.src = this_cpu; 696 681 csd->node.dst = cpu; 697 682 #endif 698 683 ··· 753 738 } 754 739 EXPORT_SYMBOL_GPL(smp_call_function_single_async); 755 740 756 - /* 741 + /** 757 742 * smp_call_function_any - Run a function on any of the given cpus 758 743 * @mask: The mask of cpus it can run on. 759 744 * @func: The function to run. This must be fast and non-blocking. 760 745 * @info: An arbitrary pointer to pass to the function. 761 746 * @wait: If true, wait until function has completed. 762 747 * 763 - * Returns 0 on success, else a negative status code (if no cpus were online). 764 - * 765 748 * Selection preference: 766 749 * 1) current cpu if in @mask 767 750 * 2) nearest cpu in @mask, based on NUMA topology 751 + * 752 + * Returns: %0 on success, else a negative status code (if no cpus were online). 768 753 */ 769 754 int smp_call_function_any(const struct cpumask *mask, 770 755 smp_call_func_t func, void *info, int wait) ··· 847 832 csd->func = func; 848 833 csd->info = info; 849 834 #ifdef CONFIG_CSD_LOCK_WAIT_DEBUG 850 - csd->node.src = smp_processor_id(); 835 + csd->node.src = this_cpu; 851 836 csd->node.dst = cpu; 852 837 #endif 853 838 trace_csd_queue_cpu(cpu, _RET_IP_, func, csd); ··· 895 880 } 896 881 897 882 /** 898 - * smp_call_function_many(): Run a function on a set of CPUs. 883 + * smp_call_function_many() - Run a function on a set of CPUs. 899 884 * @mask: The set of cpus to run on (only runs on online subset). 900 885 * @func: The function to run. This must be fast and non-blocking. 901 886 * @info: An arbitrary pointer to pass to the function. ··· 917 902 EXPORT_SYMBOL(smp_call_function_many); 918 903 919 904 /** 920 - * smp_call_function(): Run a function on all other CPUs. 905 + * smp_call_function() - Run a function on all other CPUs. 921 906 * @func: The function to run. This must be fast and non-blocking. 922 907 * @info: An arbitrary pointer to pass to the function. 923 908 * @wait: If true, wait (atomically) until function has completed 924 909 * on other CPUs. 925 - * 926 - * Returns 0. 927 910 * 928 911 * If @wait is true, then returns once @func has returned; otherwise 929 912 * it returns just before the target cpu calls @func. ··· 1022 1009 smp_cpus_done(setup_max_cpus); 1023 1010 } 1024 1011 1025 - /* 1026 - * on_each_cpu_cond(): Call a function on each processor for which 1012 + /** 1013 + * on_each_cpu_cond_mask() - Call a function on each processor for which 1027 1014 * the supplied function cond_func returns true, optionally waiting 1028 1015 * for all the required CPUs to finish. This may include the local 1029 1016 * processor. ··· 1037 1024 * @info: An arbitrary pointer to pass to both functions. 1038 1025 * @wait: If true, wait (atomically) until function has 1039 1026 * completed on other CPUs. 1027 + * @mask: The set of cpus to run on (only runs on online subset). 1040 1028 * 1041 1029 * Preemption is disabled to protect against CPUs going offline but not online. 1042 1030 * CPUs going online during the call will not be seen or sent an IPI. ··· 1109 1095 * scheduled, for any of the CPUs in the @mask. It does not guarantee 1110 1096 * correctness as it only provides a racy snapshot. 1111 1097 * 1112 - * Returns true if there is a pending IPI scheduled and false otherwise. 1098 + * Returns: true if there is a pending IPI scheduled and false otherwise. 1113 1099 */ 1114 1100 bool cpus_peek_for_pending_ipi(const struct cpumask *mask) 1115 1101 { ··· 1159 1145 complete(&sscs->done); 1160 1146 } 1161 1147 1148 + /** 1149 + * smp_call_on_cpu() - Call a function on a specific CPU and wait 1150 + * for it to return. 1151 + * @cpu: The CPU to run on. 1152 + * @func: The function to run 1153 + * @par: An arbitrary pointer parameter for @func. 1154 + * @phys: If @true, force to run on physical @cpu. See 1155 + * &struct smp_call_on_cpu_struct for more info. 1156 + * 1157 + * Returns: %-ENXIO if the @cpu is invalid; otherwise the return value 1158 + * from @func. 1159 + */ 1162 1160 int smp_call_on_cpu(unsigned int cpu, int (*func)(void *), void *par, bool phys) 1163 1161 { 1164 1162 struct smp_call_on_cpu_struct sscs = { ··· 1185 1159 if (cpu >= nr_cpu_ids || !cpu_online(cpu)) 1186 1160 return -ENXIO; 1187 1161 1188 - queue_work_on(cpu, system_wq, &sscs.work); 1162 + queue_work_on(cpu, system_percpu_wq, &sscs.work); 1189 1163 wait_for_completion(&sscs.done); 1190 1164 destroy_work_on_stack(&sscs.work); 1191 1165