From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> To: linux-kernel@vger.kernel.org Cc: mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> Subject: [PATCH tip/core/rcu 04/20] torture: Reduce #ifdefs for preempt_schedule() Date: Fri, 1 Dec 2017 12:08:49 -0800 Message-ID: <1512158945-27269-4-git-send-email-paulmck@linux.vnet.ibm.com> (raw) In-Reply-To: <20171201200819.GA25519@linux.vnet.ibm.com> This commit adds a torture_preempt_schedule() that is nothingness in !PREEMPT builds and is preempt_schedule() otherwise. Then torture_preempt_schedule() is used to eliminate several ugly #ifdefs, both in rcutorture and in locktorture. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> --- include/linux/torture.h | 6 ++++++ kernel/locking/locktorture.c | 24 ++++++------------------ kernel/rcu/rcutorture.c | 4 +--- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/include/linux/torture.h b/include/linux/torture.h index a45702eb3e7b..907d266aaddc 100644 --- a/include/linux/torture.h +++ b/include/linux/torture.h @@ -96,4 +96,10 @@ void _torture_stop_kthread(char *m, struct task_struct **tp); #define torture_stop_kthread(n, tp) \ _torture_stop_kthread("Stopping " #n " task", &(tp)) +#ifdef CONFIG_PREEMPT +#define torture_preempt_schedule() preempt_schedule() +#else +#define torture_preempt_schedule() +#endif + #endif /* __LINUX_TORTURE_H */ diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c index f24582d4dad3..617cea2520b3 100644 --- a/kernel/locking/locktorture.c +++ b/kernel/locking/locktorture.c @@ -130,10 +130,8 @@ static void torture_lock_busted_write_delay(struct torture_random_state *trsp) if (!(torture_random(trsp) % (cxt.nrealwriters_stress * 2000 * longdelay_ms))) mdelay(longdelay_ms); -#ifdef CONFIG_PREEMPT if (!(torture_random(trsp) % (cxt.nrealwriters_stress * 20000))) - preempt_schedule(); /* Allow test to be preempted. */ -#endif + torture_preempt_schedule(); /* Allow test to be preempted. */ } static void torture_lock_busted_write_unlock(void) @@ -179,10 +177,8 @@ static void torture_spin_lock_write_delay(struct torture_random_state *trsp) if (!(torture_random(trsp) % (cxt.nrealwriters_stress * 2 * shortdelay_us))) udelay(shortdelay_us); -#ifdef CONFIG_PREEMPT if (!(torture_random(trsp) % (cxt.nrealwriters_stress * 20000))) - preempt_schedule(); /* Allow test to be preempted. */ -#endif + torture_preempt_schedule(); /* Allow test to be preempted. */ } static void torture_spin_lock_write_unlock(void) __releases(torture_spinlock) @@ -352,10 +348,8 @@ static void torture_mutex_delay(struct torture_random_state *trsp) mdelay(longdelay_ms * 5); else mdelay(longdelay_ms / 5); -#ifdef CONFIG_PREEMPT if (!(torture_random(trsp) % (cxt.nrealwriters_stress * 20000))) - preempt_schedule(); /* Allow test to be preempted. */ -#endif + torture_preempt_schedule(); /* Allow test to be preempted. */ } static void torture_mutex_unlock(void) __releases(torture_mutex) @@ -507,10 +501,8 @@ static void torture_rtmutex_delay(struct torture_random_state *trsp) if (!(torture_random(trsp) % (cxt.nrealwriters_stress * 2 * shortdelay_us))) udelay(shortdelay_us); -#ifdef CONFIG_PREEMPT if (!(torture_random(trsp) % (cxt.nrealwriters_stress * 20000))) - preempt_schedule(); /* Allow test to be preempted. */ -#endif + torture_preempt_schedule(); /* Allow test to be preempted. */ } static void torture_rtmutex_unlock(void) __releases(torture_rtmutex) @@ -547,10 +539,8 @@ static void torture_rwsem_write_delay(struct torture_random_state *trsp) mdelay(longdelay_ms * 10); else mdelay(longdelay_ms / 10); -#ifdef CONFIG_PREEMPT if (!(torture_random(trsp) % (cxt.nrealwriters_stress * 20000))) - preempt_schedule(); /* Allow test to be preempted. */ -#endif + torture_preempt_schedule(); /* Allow test to be preempted. */ } static void torture_rwsem_up_write(void) __releases(torture_rwsem) @@ -574,10 +564,8 @@ static void torture_rwsem_read_delay(struct torture_random_state *trsp) mdelay(longdelay_ms * 2); else mdelay(longdelay_ms / 2); -#ifdef CONFIG_PREEMPT if (!(torture_random(trsp) % (cxt.nrealreaders_stress * 20000))) - preempt_schedule(); /* Allow test to be preempted. */ -#endif + torture_preempt_schedule(); /* Allow test to be preempted. */ } static void torture_rwsem_up_read(void) __releases(torture_rwsem) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index b6fbbeb5a7da..61fb95612125 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -315,11 +315,9 @@ static void rcu_read_delay(struct torture_random_state *rrsp) } if (!(torture_random(rrsp) % (nrealreaders * 2 * shortdelay_us))) udelay(shortdelay_us); -#ifdef CONFIG_PREEMPT if (!preempt_count() && !(torture_random(rrsp) % (nrealreaders * 20000))) - preempt_schedule(); /* No QS if preempt_disable() in effect */ -#endif + torture_preempt_schedule(); /* QS only if preemptible. */ } static void rcu_torture_read_unlock(int idx) __releases(RCU) -- 2.5.2
next prev parent reply index Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-12-01 20:08 [PATCH tip/core/rcu 0/20] Torture-test updates for v4.16 Paul E. McKenney 2017-12-01 20:08 ` [PATCH tip/core/rcu 01/20] torture: Suppress CPU stall warnings during shutdown ftrace dump Paul E. McKenney 2017-12-01 20:08 ` [PATCH tip/core/rcu 02/20] torture: Prepare scripting for shift from %p to %pK Paul E. McKenney 2017-12-04 12:32 ` David Laight 2017-12-04 13:42 ` Paul E. McKenney 2017-12-04 14:13 ` David Laight 2017-12-04 16:11 ` Paul E. McKenney 2017-12-10 12:52 ` Andy Shevchenko 2017-12-10 18:51 ` Paul E. McKenney 2017-12-10 20:39 ` Linus Torvalds 2017-12-10 21:47 ` Paul E. McKenney 2017-12-11 19:59 ` Kees Cook 2017-12-12 16:08 ` Paul E. McKenney [not found] ` <87wp1sa55h.fsf@concordia.ellerman.id.au> [not found] ` <CA+55aFxHdAX_ztDMUyXihhUv_eftntHecGUUaV3qAtGj_ZbKCg@mail.gmail.com> 2017-12-13 12:59 ` Long live %pK (was Re: [PATCH tip/core/rcu 02/20] torture: Prepare scripting for shift from %p to %pK) Michael Ellerman 2017-12-13 18:21 ` Linus Torvalds 2017-12-01 20:08 ` [PATCH tip/core/rcu 03/20] rcutorture: Change printk() %p to %pK Paul E. McKenney 2017-12-01 20:08 ` Paul E. McKenney [this message] 2017-12-01 20:08 ` [PATCH tip/core/rcu 05/20] rcutorture: Preempt RCU-preempt readers more vigorously Paul E. McKenney 2017-12-01 20:08 ` [PATCH tip/core/rcu 06/20] rcutorture/configinit: Fix build directory error message Paul E. McKenney 2017-12-01 20:08 ` [PATCH tip/core/rcu 07/20] rcutorture: Remove unused script, config2frag.sh Paul E. McKenney 2017-12-01 20:08 ` [PATCH tip/core/rcu 08/20] rcutorture/kvm.sh: Remove unused variable, `alldone` Paul E. McKenney 2017-12-01 20:08 ` [PATCH tip/core/rcu 09/20] rcutorture/kvm.sh: Use consistent help text for --qemu-args Paul E. McKenney 2017-12-01 20:08 ` [PATCH tip/core/rcu 10/20] rcutorture/kvm.sh: Support execution from any directory Paul E. McKenney 2017-12-01 20:08 ` [PATCH tip/core/rcu 11/20] rcutorture/kvm-recheck-*: Improve result directory readability check Paul E. McKenney 2017-12-01 20:08 ` [PATCH tip/core/rcu 12/20] rcutorture: Simplify logging Paul E. McKenney 2017-12-01 20:08 ` [PATCH tip/core/rcu 13/20] rcutorture: Simplify functions.sh include path Paul E. McKenney 2017-12-01 20:08 ` [PATCH tip/core/rcu 14/20] rcutorture/kvm-build.sh: Skip build directory check Paul E. McKenney 2017-12-01 20:09 ` [PATCH tip/core/rcu 15/20] torture: Place all torture-test modules in one MAINTAINERS group Paul E. McKenney 2017-12-01 20:09 ` [PATCH tip/core/rcu 16/20] locking/locktorture: Fix rwsem reader_delay Paul E. McKenney 2017-12-01 20:09 ` [PATCH tip/core/rcu 17/20] locking/locktorture: Fix num reader/writer corner cases Paul E. McKenney 2017-12-01 20:09 ` [PATCH tip/core/rcu 18/20] torture: Make stutter less vulnerable to compilers and races Paul E. McKenney 2017-12-01 20:09 ` [PATCH tip/core/rcu 19/20] torture: Eliminate torture_runnable and perf_runnable Paul E. McKenney 2017-12-01 20:09 ` [PATCH tip/core/rcu 20/20] torture: Save a line in stutter_wait(): while -> for Paul E. McKenney
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1512158945-27269-4-git-send-email-paulmck@linux.vnet.ibm.com \ --to=paulmck@linux.vnet.ibm.com \ --cc=akpm@linux-foundation.org \ --cc=dhowells@redhat.com \ --cc=dipankar@in.ibm.com \ --cc=edumazet@google.com \ --cc=fweisbec@gmail.com \ --cc=jiangshanlai@gmail.com \ --cc=josh@joshtriplett.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mathieu.desnoyers@efficios.com \ --cc=mingo@kernel.org \ --cc=oleg@redhat.com \ --cc=peterz@infradead.org \ --cc=rostedt@goodmis.org \ --cc=tglx@linutronix.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
LKML Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \ linux-kernel@vger.kernel.org public-inbox-index lkml Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git