.. | .. |
---|
5 | 5 | * DEBUG_PREEMPT variant of smp_processor_id(). |
---|
6 | 6 | */ |
---|
7 | 7 | #include <linux/export.h> |
---|
| 8 | +#include <linux/kprobes.h> |
---|
8 | 9 | #include <linux/sched.h> |
---|
9 | 10 | |
---|
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) |
---|
12 | 13 | { |
---|
13 | 14 | int this_cpu = raw_smp_processor_id(); |
---|
14 | 15 | |
---|
.. | .. |
---|
22 | 23 | * Kernel threads bound to a single CPU can safely use |
---|
23 | 24 | * smp_processor_id(): |
---|
24 | 25 | */ |
---|
25 | | - if (cpumask_equal(¤t->cpus_allowed, cpumask_of(this_cpu))) |
---|
| 26 | + if (current->nr_cpus_allowed == 1) |
---|
26 | 27 | goto out; |
---|
| 28 | + |
---|
| 29 | +#ifdef CONFIG_SMP |
---|
| 30 | + if (current->migration_disabled) |
---|
| 31 | + goto out; |
---|
| 32 | +#endif |
---|
27 | 33 | |
---|
28 | 34 | /* |
---|
29 | 35 | * It is valid to assume CPU-locality during early bootup: |
---|
.. | .. |
---|
36 | 42 | */ |
---|
37 | 43 | preempt_disable_notrace(); |
---|
38 | 44 | |
---|
| 45 | + instrumentation_begin(); |
---|
39 | 46 | if (!printk_ratelimit()) |
---|
40 | 47 | goto out_enable; |
---|
41 | 48 | |
---|
.. | .. |
---|
46 | 53 | dump_stack(); |
---|
47 | 54 | |
---|
48 | 55 | out_enable: |
---|
| 56 | + instrumentation_end(); |
---|
49 | 57 | preempt_enable_no_resched_notrace(); |
---|
50 | 58 | out: |
---|
51 | 59 | return this_cpu; |
---|
52 | 60 | } |
---|
53 | 61 | |
---|
54 | | -notrace unsigned int debug_smp_processor_id(void) |
---|
| 62 | +noinstr unsigned int debug_smp_processor_id(void) |
---|
55 | 63 | { |
---|
56 | 64 | return check_preemption_disabled("smp_processor_id", ""); |
---|
57 | 65 | } |
---|
58 | 66 | EXPORT_SYMBOL(debug_smp_processor_id); |
---|
59 | 67 | |
---|
60 | | -notrace void __this_cpu_preempt_check(const char *op) |
---|
| 68 | +noinstr void __this_cpu_preempt_check(const char *op) |
---|
61 | 69 | { |
---|
62 | 70 | check_preemption_disabled("__this_cpu_", op); |
---|
63 | 71 | } |
---|