diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/Makefile | 1 | ||||
| -rw-r--r-- | kernel/context_tracking.c | 83 | ||||
| -rw-r--r-- | kernel/ksysfs.c | 18 | ||||
| -rw-r--r-- | kernel/rcu.h | 2 | ||||
| -rw-r--r-- | kernel/rcupdate.c | 3 | ||||
| -rw-r--r-- | kernel/rcutiny.c | 2 | ||||
| -rw-r--r-- | kernel/rcutiny_plugin.h | 5 | ||||
| -rw-r--r-- | kernel/rcutorture.c | 54 | ||||
| -rw-r--r-- | kernel/rcutree.c | 347 | ||||
| -rw-r--r-- | kernel/rcutree.h | 67 | ||||
| -rw-r--r-- | kernel/rcutree_plugin.h | 415 | ||||
| -rw-r--r-- | kernel/rcutree_trace.c | 330 | ||||
| -rw-r--r-- | kernel/sched/core.c | 23 | ||||
| -rw-r--r-- | kernel/srcu.c | 16 |
14 files changed, 1014 insertions, 352 deletions
diff --git a/kernel/Makefile b/kernel/Makefile index 86e3285ae7e5..ac0d533eb7de 100644 --- a/kernel/Makefile +++ b/kernel/Makefile | |||
| @@ -110,6 +110,7 @@ obj-$(CONFIG_USER_RETURN_NOTIFIER) += user-return-notifier.o | |||
| 110 | obj-$(CONFIG_PADATA) += padata.o | 110 | obj-$(CONFIG_PADATA) += padata.o |
| 111 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o | 111 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o |
| 112 | obj-$(CONFIG_JUMP_LABEL) += jump_label.o | 112 | obj-$(CONFIG_JUMP_LABEL) += jump_label.o |
| 113 | obj-$(CONFIG_CONTEXT_TRACKING) += context_tracking.o | ||
| 113 | 114 | ||
| 114 | $(obj)/configs.o: $(obj)/config_data.h | 115 | $(obj)/configs.o: $(obj)/config_data.h |
| 115 | 116 | ||
diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c new file mode 100644 index 000000000000..e0e07fd55508 --- /dev/null +++ b/kernel/context_tracking.c | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | #include <linux/context_tracking.h> | ||
| 2 | #include <linux/rcupdate.h> | ||
| 3 | #include <linux/sched.h> | ||
| 4 | #include <linux/percpu.h> | ||
| 5 | #include <linux/hardirq.h> | ||
| 6 | |||
| 7 | struct context_tracking { | ||
| 8 | /* | ||
| 9 | * When active is false, hooks are not set to | ||
| 10 | * minimize overhead: TIF flags are cleared | ||
| 11 | * and calls to user_enter/exit are ignored. This | ||
| 12 | * may be further optimized using static keys. | ||
| 13 | */ | ||
| 14 | bool active; | ||
| 15 | enum { | ||
| 16 | IN_KERNEL = 0, | ||
| 17 | IN_USER, | ||
| 18 | } state; | ||
| 19 | }; | ||
| 20 | |||
| 21 | static DEFINE_PER_CPU(struct context_tracking, context_tracking) = { | ||
| 22 | #ifdef CONFIG_CONTEXT_TRACKING_FORCE | ||
| 23 | .active = true, | ||
| 24 | #endif | ||
| 25 | }; | ||
| 26 | |||
| 27 | void user_enter(void) | ||
| 28 | { | ||
| 29 | unsigned long flags; | ||
| 30 | |||
| 31 | /* | ||
| 32 | * Some contexts may involve an exception occuring in an irq, | ||
| 33 | * leading to that nesting: | ||
| 34 | * rcu_irq_enter() rcu_user_exit() rcu_user_exit() rcu_irq_exit() | ||
| 35 | * This would mess up the dyntick_nesting count though. And rcu_irq_*() | ||
| 36 | * helpers are enough to protect RCU uses inside the exception. So | ||
| 37 | * just return immediately if we detect we are in an IRQ. | ||
| 38 | */ | ||
| 39 | if (in_interrupt()) | ||
| 40 | return; | ||
| 41 | |||
| 42 | WARN_ON_ONCE(!current->mm); | ||
| 43 | |||
| 44 | local_irq_save(flags); | ||
| 45 | if (__this_cpu_read(context_tracking.active) && | ||
| 46 | __this_cpu_read(context_tracking.state) != IN_USER) { | ||
| 47 | __this_cpu_write(context_tracking.state, IN_USER); | ||
| 48 | rcu_user_enter(); | ||
| 49 | } | ||
| 50 | local_irq_restore(flags); | ||
| 51 | } | ||
| 52 | |||
| 53 | void user_exit(void) | ||
| 54 | { | ||
| 55 | unsigned long flags; | ||
| 56 | |||
| 57 | /* | ||
| 58 | * Some contexts may involve an exception occuring in an irq, | ||
| 59 | * leading to that nesting: | ||
| 60 | * rcu_irq_enter() rcu_user_exit() rcu_user_exit() rcu_irq_exit() | ||
| 61 | * This would mess up the dyntick_nesting count though. And rcu_irq_*() | ||
| 62 | * helpers are enough to protect RCU uses inside the exception. So | ||
| 63 | * just return immediately if we detect we are in an IRQ. | ||
| 64 | */ | ||
| 65 | if (in_interrupt()) | ||
| 66 | return; | ||
| 67 | |||
| 68 | local_irq_save(flags); | ||
| 69 | if (__this_cpu_read(context_tracking.state) == IN_USER) { | ||
| 70 | __this_cpu_write(context_tracking.state, IN_KERNEL); | ||
| 71 | rcu_user_exit(); | ||
| 72 | } | ||
| 73 | local_irq_restore(flags); | ||
| 74 | } | ||
| 75 | |||
| 76 | void context_tracking_task_switch(struct task_struct *prev, | ||
| 77 | struct task_struct *next) | ||
| 78 | { | ||
| 79 | if (__this_cpu_read(context_tracking.active)) { | ||
| 80 | clear_tsk_thread_flag(prev, TIF_NOHZ); | ||
| 81 | set_tsk_thread_flag(next, TIF_NOHZ); | ||
| 82 | } | ||
| 83 | } | ||
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index 4e316e1acf58..8715a798aa7c 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c | |||
| @@ -141,6 +141,23 @@ static ssize_t fscaps_show(struct kobject *kobj, | |||
| 141 | } | 141 | } |
| 142 | KERNEL_ATTR_RO(fscaps); | 142 | KERNEL_ATTR_RO(fscaps); |
| 143 | 143 | ||
| 144 | int rcu_expedited; | ||
| 145 | static ssize_t rcu_expedited_show(struct kobject *kobj, | ||
| 146 | struct kobj_attribute *attr, char *buf) | ||
| 147 | { | ||
| 148 | return sprintf(buf, "%d\n", rcu_expedited); | ||
| 149 | } | ||
| 150 | static ssize_t rcu_expedited_store(struct kobject *kobj, | ||
| 151 | struct kobj_attribute *attr, | ||
| 152 | const char *buf, size_t count) | ||
| 153 | { | ||
| 154 | if (kstrtoint(buf, 0, &rcu_expedited)) | ||
| 155 | return -EINVAL; | ||
| 156 | |||
| 157 | return count; | ||
| 158 | } | ||
| 159 | KERNEL_ATTR_RW(rcu_expedited); | ||
| 160 | |||
| 144 | /* | 161 | /* |
| 145 | * Make /sys/kernel/notes give the raw contents of our kernel .notes section. | 162 | * Make /sys/kernel/notes give the raw contents of our kernel .notes section. |
| 146 | */ | 163 | */ |
| @@ -182,6 +199,7 @@ static struct attribute * kernel_attrs[] = { | |||
| 182 | &kexec_crash_size_attr.attr, | 199 | &kexec_crash_size_attr.attr, |
| 183 | &vmcoreinfo_attr.attr, | 200 | &vmcoreinfo_attr.attr, |
| 184 | #endif | 201 | #endif |
| 202 | &rcu_expedited_attr.attr, | ||
| 185 | NULL | 203 | NULL |
| 186 | }; | 204 | }; |
| 187 | 205 | ||
diff --git a/kernel/rcu.h b/kernel/rcu.h index 8ba99cdc6515..20dfba576c2b 100644 --- a/kernel/rcu.h +++ b/kernel/rcu.h | |||
| @@ -109,4 +109,6 @@ static inline bool __rcu_reclaim(char *rn, struct rcu_head *head) | |||
| 109 | } | 109 | } |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | extern int rcu_expedited; | ||
| 113 | |||
| 112 | #endif /* __LINUX_RCU_H */ | 114 | #endif /* __LINUX_RCU_H */ |
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c index 29ca1c6da594..a2cf76177b44 100644 --- a/kernel/rcupdate.c +++ b/kernel/rcupdate.c | |||
| @@ -46,12 +46,15 @@ | |||
| 46 | #include <linux/export.h> | 46 | #include <linux/export.h> |
| 47 | #include <linux/hardirq.h> | 47 | #include <linux/hardirq.h> |
| 48 | #include <linux/delay.h> | 48 | #include <linux/delay.h> |
| 49 | #include <linux/module.h> | ||
| 49 | 50 | ||
| 50 | #define CREATE_TRACE_POINTS | 51 | #define CREATE_TRACE_POINTS |
| 51 | #include <trace/events/rcu.h> | 52 | #include <trace/events/rcu.h> |
| 52 | 53 | ||
| 53 | #include "rcu.h" | 54 | #include "rcu.h" |
| 54 | 55 | ||
| 56 | module_param(rcu_expedited, int, 0); | ||
| 57 | |||
| 55 | #ifdef CONFIG_PREEMPT_RCU | 58 | #ifdef CONFIG_PREEMPT_RCU |
| 56 | 59 | ||
| 57 | /* | 60 | /* |
diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c index e4c6a598d6f7..e7dce58f9c2a 100644 --- a/kernel/rcutiny.c +++ b/kernel/rcutiny.c | |||
| @@ -195,7 +195,7 @@ EXPORT_SYMBOL(rcu_is_cpu_idle); | |||
| 195 | */ | 195 | */ |
| 196 | int rcu_is_cpu_rrupt_from_idle(void) | 196 | int rcu_is_cpu_rrupt_from_idle(void) |
| 197 | { | 197 | { |
| 198 | return rcu_dynticks_nesting <= 0; | 198 | return rcu_dynticks_nesting <= 1; |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | /* | 201 | /* |
diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h index 3d0190282204..f85016a2309b 100644 --- a/kernel/rcutiny_plugin.h +++ b/kernel/rcutiny_plugin.h | |||
| @@ -706,7 +706,10 @@ void synchronize_rcu(void) | |||
| 706 | return; | 706 | return; |
| 707 | 707 | ||
| 708 | /* Once we get past the fastpath checks, same code as rcu_barrier(). */ | 708 | /* Once we get past the fastpath checks, same code as rcu_barrier(). */ |
| 709 | rcu_barrier(); | 709 | if (rcu_expedited) |
