diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-03-31 14:05:24 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-03-31 14:05:24 -0400 |
| commit | b3fd4ea9df2d5c39cd6ce08faf965ed669eb3b56 (patch) | |
| tree | de45e2aff3106f4fa413ea3f08a7f8c969c0479b /kernel | |
| parent | 462bf234a82ae1ae9d7628f59bc81022591e1348 (diff) | |
| parent | 7de700e6806cafa30c70bc84478431a11197a5ea (diff) | |
Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull RCU updates from Ingo Molnar:
"Main changes:
- Torture-test changes, including refactoring of rcutorture and
introduction of a vestigial locktorture.
- Real-time latency fixes.
- Documentation updates.
- Miscellaneous fixes"
* 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (77 commits)
rcu: Provide grace-period piggybacking API
rcu: Ensure kernel/rcu/rcu.h can be sourced/used stand-alone
rcu: Fix sparse warning for rcu_expedited from kernel/ksysfs.c
notifier: Substitute rcu_access_pointer() for rcu_dereference_raw()
Documentation/memory-barriers.txt: Clarify release/acquire ordering
rcutorture: Save kvm.sh output to log
rcutorture: Add a lock_busted to test the test
rcutorture: Place kvm-test-1-run.sh output into res directory
rcutorture: Rename TREE_RCU-Kconfig.txt
locktorture: Add kvm-recheck.sh plug-in for locktorture
rcutorture: Gracefully handle NULL cleanup hooks
locktorture: Add vestigial locktorture configuration
rcutorture: Introduce "rcu" directory level underneath configs
rcutorture: Rename kvm-test-1-rcu.sh
rcutorture: Remove RCU dependencies from ver_functions.sh API
rcutorture: Create CFcommon file for common Kconfig parameters
rcutorture: Create config files for scripted test-the-test testing
rcutorture: Add an rcu_busted to test the test
locktorture: Add a lock-torture kernel module
rcutorture: Abstract kvm-recheck.sh
...
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/Makefile | 1 | ||||
| -rw-r--r-- | kernel/ksysfs.c | 2 | ||||
| -rw-r--r-- | kernel/locking/Makefile | 1 | ||||
| -rw-r--r-- | kernel/locking/locktorture.c | 452 | ||||
| -rw-r--r-- | kernel/notifier.c | 2 | ||||
| -rw-r--r-- | kernel/rcu/Makefile | 2 | ||||
| -rw-r--r-- | kernel/rcu/rcu.h | 7 | ||||
| -rw-r--r-- | kernel/rcu/rcutorture.c (renamed from kernel/rcu/torture.c) | 996 | ||||
| -rw-r--r-- | kernel/rcu/srcu.c | 11 | ||||
| -rw-r--r-- | kernel/rcu/tiny.c | 8 | ||||
| -rw-r--r-- | kernel/rcu/tiny_plugin.h | 4 | ||||
| -rw-r--r-- | kernel/rcu/tree.c | 80 | ||||
| -rw-r--r-- | kernel/rcu/tree.h | 4 | ||||
| -rw-r--r-- | kernel/rcu/tree_plugin.h | 19 | ||||
| -rw-r--r-- | kernel/rcu/tree_trace.c | 6 | ||||
| -rw-r--r-- | kernel/rcu/update.c | 5 | ||||
| -rw-r--r-- | kernel/torture.c | 719 |
17 files changed, 1491 insertions, 828 deletions
diff --git a/kernel/Makefile b/kernel/Makefile index bc010ee272b6..5c0e7666811d 100644 --- a/kernel/Makefile +++ b/kernel/Makefile | |||
| @@ -93,6 +93,7 @@ obj-$(CONFIG_PADATA) += padata.o | |||
| 93 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o | 93 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o |
| 94 | obj-$(CONFIG_JUMP_LABEL) += jump_label.o | 94 | obj-$(CONFIG_JUMP_LABEL) += jump_label.o |
| 95 | obj-$(CONFIG_CONTEXT_TRACKING) += context_tracking.o | 95 | obj-$(CONFIG_CONTEXT_TRACKING) += context_tracking.o |
| 96 | obj-$(CONFIG_TORTURE_TEST) += torture.o | ||
| 96 | 97 | ||
| 97 | $(obj)/configs.o: $(obj)/config_data.h | 98 | $(obj)/configs.o: $(obj)/config_data.h |
| 98 | 99 | ||
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index d945a949760f..e660964086e2 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c | |||
| @@ -19,6 +19,8 @@ | |||
| 19 | #include <linux/sched.h> | 19 | #include <linux/sched.h> |
| 20 | #include <linux/capability.h> | 20 | #include <linux/capability.h> |
| 21 | 21 | ||
| 22 | #include <linux/rcupdate.h> /* rcu_expedited */ | ||
| 23 | |||
| 22 | #define KERNEL_ATTR_RO(_name) \ | 24 | #define KERNEL_ATTR_RO(_name) \ |
| 23 | static struct kobj_attribute _name##_attr = __ATTR_RO(_name) | 25 | static struct kobj_attribute _name##_attr = __ATTR_RO(_name) |
| 24 | 26 | ||
diff --git a/kernel/locking/Makefile b/kernel/locking/Makefile index 2a9ee96ecf00..306a76b51e0f 100644 --- a/kernel/locking/Makefile +++ b/kernel/locking/Makefile | |||
| @@ -23,3 +23,4 @@ obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o | |||
| 23 | obj-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o | 23 | obj-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o |
| 24 | obj-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem-xadd.o | 24 | obj-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem-xadd.o |
| 25 | obj-$(CONFIG_PERCPU_RWSEM) += percpu-rwsem.o | 25 | obj-$(CONFIG_PERCPU_RWSEM) += percpu-rwsem.o |
| 26 | obj-$(CONFIG_LOCK_TORTURE_TEST) += locktorture.o | ||
diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c new file mode 100644 index 000000000000..f26b1a18e34e --- /dev/null +++ b/kernel/locking/locktorture.c | |||
| @@ -0,0 +1,452 @@ | |||
| 1 | /* | ||
| 2 | * Module-based torture test facility for locking | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation; either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program; if not, you can access it online at | ||
| 16 | * http://www.gnu.org/licenses/gpl-2.0.html. | ||
| 17 | * | ||
| 18 | * Copyright (C) IBM Corporation, 2014 | ||
| 19 | * | ||
| 20 | * Author: Paul E. McKenney <paulmck@us.ibm.com> | ||
| 21 | * Based on kernel/rcu/torture.c. | ||
| 22 | */ | ||
| 23 | #include <linux/types.h> | ||
| 24 | #include <linux/kernel.h> | ||
| 25 | #include <linux/init.h> | ||
| 26 | #include <linux/module.h> | ||
| 27 | #include <linux/kthread.h> | ||
| 28 | #include <linux/err.h> | ||
| 29 | #include <linux/spinlock.h> | ||
| 30 | #include <linux/smp.h> | ||
| 31 | #include <linux/interrupt.h> | ||
| 32 | #include <linux/sched.h> | ||
| 33 | #include <linux/atomic.h> | ||
| 34 | #include <linux/bitops.h> | ||
| 35 | #include <linux/completion.h> | ||
| 36 | #include <linux/moduleparam.h> | ||
| 37 | #include <linux/percpu.h> | ||
| 38 | #include <linux/notifier.h> | ||
| 39 | #include <linux/reboot.h> | ||
| 40 | #include <linux/freezer.h> | ||
| 41 | #include <linux/cpu.h> | ||
| 42 | #include <linux/delay.h> | ||
| 43 | #include <linux/stat.h> | ||
| 44 | #include <linux/slab.h> | ||
| 45 | #include <linux/trace_clock.h> | ||
| 46 | #include <asm/byteorder.h> | ||
| 47 | #include <linux/torture.h> | ||
| 48 | |||
| 49 | MODULE_LICENSE("GPL"); | ||
| 50 | MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com>"); | ||
| 51 | |||
| 52 | torture_param(int, nwriters_stress, -1, | ||
| 53 | "Number of write-locking stress-test threads"); | ||
| 54 | torture_param(int, onoff_holdoff, 0, "Time after boot before CPU hotplugs (s)"); | ||
| 55 | torture_param(int, onoff_interval, 0, | ||
| 56 | "Time between CPU hotplugs (s), 0=disable"); | ||
| 57 | torture_param(int, shuffle_interval, 3, | ||
| 58 | "Number of jiffies between shuffles, 0=disable"); | ||
| 59 | torture_param(int, shutdown_secs, 0, "Shutdown time (j), <= zero to disable."); | ||
| 60 | torture_param(int, stat_interval, 60, | ||
| 61 | "Number of seconds between stats printk()s"); | ||
| 62 | torture_param(int, stutter, 5, "Number of jiffies to run/halt test, 0=disable"); | ||
| 63 | torture_param(bool, verbose, true, | ||
| 64 | "Enable verbose debugging printk()s"); | ||
| 65 | |||
| 66 | static char *torture_type = "spin_lock"; | ||
| 67 | module_param(torture_type, charp, 0444); | ||
| 68 | MODULE_PARM_DESC(torture_type, | ||
| 69 | "Type of lock to torture (spin_lock, spin_lock_irq, ...)"); | ||
| 70 | |||
| 71 | static atomic_t n_lock_torture_errors; | ||
| 72 | |||
| 73 | static struct task_struct *stats_task; | ||
| 74 | static struct task_struct **writer_tasks; | ||
| 75 | |||
| 76 | static int nrealwriters_stress; | ||
| 77 | static bool lock_is_write_held; | ||
| 78 | |||
| 79 | struct lock_writer_stress_stats { | ||
| 80 | long n_write_lock_fail; | ||
| 81 | long n_write_lock_acquired; | ||
| 82 | }; | ||
| 83 | static struct lock_writer_stress_stats *lwsa; | ||
| 84 | |||
| 85 | #if defined(MODULE) || defined(CONFIG_LOCK_TORTURE_TEST_RUNNABLE) | ||
| 86 | #define LOCKTORTURE_RUNNABLE_INIT 1 | ||
| 87 | #else | ||
| 88 | #define LOCKTORTURE_RUNNABLE_INIT 0 | ||
| 89 | #endif | ||
| 90 | int locktorture_runnable = LOCKTORTURE_RUNNABLE_INIT; | ||
| 91 | module_param(locktorture_runnable, int, 0444); | ||
| 92 | MODULE_PARM_DESC(locktorture_runnable, "Start locktorture at boot"); | ||
| 93 | |||
| 94 | /* Forward reference. */ | ||
| 95 | static void lock_torture_cleanup(void); | ||
| 96 | |||
| 97 | /* | ||
| 98 | * Operations vector for selecting different types of tests. | ||
| 99 | */ | ||
| 100 | struct lock_torture_ops { | ||
| 101 | void (*init)(void); | ||
| 102 | int (*writelock)(void); | ||
| 103 | void (*write_delay)(struct torture_random_state *trsp); | ||
| 104 | void (*writeunlock)(void); | ||
| 105 | unsigned long flags; | ||
| 106 | const char *name; | ||
| 107 | }; | ||
| 108 | |||
| 109 | static struct lock_torture_ops *cur_ops; | ||
| 110 | |||
| 111 | /* | ||
| 112 | * Definitions for lock torture testing. | ||
| 113 | */ | ||
| 114 | |||
| 115 | static int torture_lock_busted_write_lock(void) | ||
| 116 | { | ||
| 117 | return 0; /* BUGGY, do not use in real life!!! */ | ||
| 118 | } | ||
| 119 | |||
| 120 | static void torture_lock_busted_write_delay(struct torture_random_state *trsp) | ||
| 121 | { | ||
| 122 | const unsigned long longdelay_us = 100; | ||
| 123 | |||
| 124 | /* We want a long delay occasionally to force massive contention. */ | ||
| 125 | if (!(torture_random(trsp) % | ||
| 126 | (nrealwriters_stress * 2000 * longdelay_us))) | ||
| 127 | mdelay(longdelay_us); | ||
| 128 | #ifdef CONFIG_PREEMPT | ||
| 129 | if (!(torture_random(trsp) % (nrealwriters_stress * 20000))) | ||
| 130 | preempt_schedule(); /* Allow test to be preempted. */ | ||
| 131 | #endif | ||
