hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/lib/smp_processor_id.c
....@@ -5,10 +5,11 @@
55 * DEBUG_PREEMPT variant of smp_processor_id().
66 */
77 #include <linux/export.h>
8
+#include <linux/kprobes.h>
89 #include <linux/sched.h>
910
10
-notrace static unsigned int check_preemption_disabled(const char *what1,
11
- const char *what2)
11
+noinstr static
12
+unsigned int check_preemption_disabled(const char *what1, const char *what2)
1213 {
1314 int this_cpu = raw_smp_processor_id();
1415
....@@ -22,8 +23,13 @@
2223 * Kernel threads bound to a single CPU can safely use
2324 * smp_processor_id():
2425 */
25
- if (cpumask_equal(&current->cpus_allowed, cpumask_of(this_cpu)))
26
+ if (current->nr_cpus_allowed == 1)
2627 goto out;
28
+
29
+#ifdef CONFIG_SMP
30
+ if (current->migration_disabled)
31
+ goto out;
32
+#endif
2733
2834 /*
2935 * It is valid to assume CPU-locality during early bootup:
....@@ -36,6 +42,7 @@
3642 */
3743 preempt_disable_notrace();
3844
45
+ instrumentation_begin();
3946 if (!printk_ratelimit())
4047 goto out_enable;
4148
....@@ -46,18 +53,19 @@
4653 dump_stack();
4754
4855 out_enable:
56
+ instrumentation_end();
4957 preempt_enable_no_resched_notrace();
5058 out:
5159 return this_cpu;
5260 }
5361
54
-notrace unsigned int debug_smp_processor_id(void)
62
+noinstr unsigned int debug_smp_processor_id(void)
5563 {
5664 return check_preemption_disabled("smp_processor_id", "");
5765 }
5866 EXPORT_SYMBOL(debug_smp_processor_id);
5967
60
-notrace void __this_cpu_preempt_check(const char *op)
68
+noinstr void __this_cpu_preempt_check(const char *op)
6169 {
6270 check_preemption_disabled("__this_cpu_", op);
6371 }