Skip to content

Commit f5d2a04

Browse files
committed
Merge branches 'doc.2014.04.29a', 'fixes.2014.04.29a' and 'torture.2014.05.14a' into HEAD
doc.2014.04.29a: Documentation updates. fixes.2014.04.29a: Miscellaneous fixes. torture.2014.05.14a: RCU/Lock torture tests.
3 parents d07e6d0 + a5d6d3a + 6348675 commit f5d2a04

26 files changed

Lines changed: 747 additions & 383 deletions

‎include/linux/percpu.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ do { \
639639
# define raw_cpu_add_return_8(pcp, val) raw_cpu_generic_add_return(pcp, val)
640640
# endif
641641
# define raw_cpu_add_return(pcp, val) \
642-
__pcpu_size_call_return2(raw_add_return_, pcp, val)
642+
__pcpu_size_call_return2(raw_cpu_add_return_, pcp, val)
643643
#endif
644644

645645
#define raw_cpu_sub_return(pcp, val) raw_cpu_add_return(pcp, -(typeof(pcp))(val))

‎include/linux/rcupdate.h‎

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,25 @@
4444
#include <linux/debugobjects.h>
4545
#include <linux/bug.h>
4646
#include <linux/compiler.h>
47+
#include <linux/percpu.h>
4748
#include <asm/barrier.h>
4849

4950
extern int rcu_expedited; /* for sysctl */
5051
#ifdef CONFIG_RCU_TORTURE_TEST
5152
extern int rcutorture_runnable; /* for sysctl */
5253
#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
5354

55+
enum rcutorture_type {
56+
RCU_FLAVOR,
57+
RCU_BH_FLAVOR,
58+
RCU_SCHED_FLAVOR,
59+
SRCU_FLAVOR,
60+
INVALID_RCU_FLAVOR
61+
};
62+
5463
#if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
64+
void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags,
65+
unsigned long *gpnum, unsigned long *completed);
5566
void rcutorture_record_test_transition(void);
5667
void rcutorture_record_progress(unsigned long vernum);
5768
void do_trace_rcu_torture_read(const char *rcutorturename,
@@ -60,6 +71,15 @@ void do_trace_rcu_torture_read(const char *rcutorturename,
6071
unsigned long c_old,
6172
unsigned long c);
6273
#else
74+
static inline void rcutorture_get_gp_data(enum rcutorture_type test_type,
75+
int *flags,
76+
unsigned long *gpnum,
77+
unsigned long *completed)
78+
{
79+
*flags = 0;
80+
*gpnum = 0;
81+
*completed = 0;
82+
}
6383
static inline void rcutorture_record_test_transition(void)
6484
{
6585
}
@@ -267,6 +287,41 @@ static inline void rcu_user_hooks_switch(struct task_struct *prev,
267287
bool __rcu_is_watching(void);
268288
#endif /* #if defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE) || defined(CONFIG_SMP) */
269289

290+
/*
291+
* Hooks for cond_resched() and friends to avoid RCU CPU stall warnings.
292+
*/
293+
294+
#define RCU_COND_RESCHED_LIM 256 /* ms vs. 100s of ms. */
295+
DECLARE_PER_CPU(int, rcu_cond_resched_count);
296+
void rcu_resched(void);
297+
298+
/*
299+
* Is it time to report RCU quiescent states?
300+
*
301+
* Note unsynchronized access to rcu_cond_resched_count. Yes, we might
302+
* increment some random CPU's count, and possibly also load the result from
303+
* yet another CPU's count. We might even clobber some other CPU's attempt
304+
* to zero its counter. This is all OK because the goal is not precision,
305+
* but rather reasonable amortization of rcu_note_context_switch() overhead
306+
* and extremely high probability of avoiding RCU CPU stall warnings.
307+
* Note that this function has to be preempted in just the wrong place,
308+
* many thousands of times in a row, for anything bad to happen.
309+
*/
310+
static inline bool rcu_should_resched(void)
311+
{
312+
return raw_cpu_inc_return(rcu_cond_resched_count) >=
313+
RCU_COND_RESCHED_LIM;
314+
}
315+
316+
/*
317+
* Report quiscent states to RCU if it is time to do so.
318+
*/
319+
static inline void rcu_cond_resched(void)
320+
{
321+
if (unlikely(rcu_should_resched()))
322+
rcu_resched();
323+
}
324+
270325
/*
271326
* Infrastructure to implement the synchronize_() primitives in
272327
* TREE_RCU and rcu_barrier_() primitives in TINY_RCU.
@@ -328,7 +383,7 @@ extern struct lockdep_map rcu_lock_map;
328383
extern struct lockdep_map rcu_bh_lock_map;
329384
extern struct lockdep_map rcu_sched_lock_map;
330385
extern struct lockdep_map rcu_callback_map;
331-
extern int debug_lockdep_rcu_enabled(void);
386+
int debug_lockdep_rcu_enabled(void);
332387

333388
/**
334389
* rcu_read_lock_held() - might we be in RCU read-side critical section?
@@ -949,6 +1004,9 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
9491004
* pointers, but you must use rcu_assign_pointer() to initialize the
9501005
* external-to-structure pointer -after- you have completely initialized
9511006
* the reader-accessible portions of the linked structure.
1007+
*
1008+
* Note that unlike rcu_assign_pointer(), RCU_INIT_POINTER() provides no
1009+
* ordering guarantees for either the CPU or the compiler.
9521010
*/
9531011
#define RCU_INIT_POINTER(p, v) \
9541012
do { \

‎include/linux/rcutiny.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ static inline void rcu_sched_force_quiescent_state(void)
119119
{
120120
}
121121

122+
static inline void show_rcu_gp_kthreads(void)
123+
{
124+
}
125+
122126
static inline void rcu_cpu_stall_reset(void)
123127
{
124128
}

‎include/linux/rcutree.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ extern unsigned long rcutorture_vernum;
8484
long rcu_batches_completed(void);
8585
long rcu_batches_completed_bh(void);
8686
long rcu_batches_completed_sched(void);
87+
void show_rcu_gp_kthreads(void);
8788

8889
void rcu_force_quiescent_state(void);
8990
void rcu_bh_force_quiescent_state(void);

‎include/linux/torture.h‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@
4949
#define VERBOSE_TOROUT_ERRSTRING(s) \
5050
do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! %s\n", torture_type, s); } while (0)
5151

52-
/* Definitions for a non-string torture-test module parameter. */
53-
#define torture_parm(type, name, init, msg) \
54-
static type name = init; \
55-
module_param(name, type, 0444); \
56-
MODULE_PARM_DESC(name, msg);
57-
5852
/* Definitions for online/offline exerciser. */
5953
int torture_onoff_init(long ooholdoff, long oointerval);
6054
char *torture_onoff_stats(char *page);
@@ -81,7 +75,7 @@ void stutter_wait(const char *title);
8175
int torture_stutter_init(int s);
8276

8377
/* Initialization and cleanup. */
84-
void torture_init_begin(char *ttype, bool v, int *runnable);
78+
bool torture_init_begin(char *ttype, bool v, int *runnable);
8579
void torture_init_end(void);
8680
bool torture_cleanup(void);
8781
bool torture_must_stop(void);

‎kernel/locking/locktorture.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ struct lock_writer_stress_stats {
8282
};
8383
static struct lock_writer_stress_stats *lwsa;
8484

85-
#if defined(MODULE) || defined(CONFIG_LOCK_TORTURE_TEST_RUNNABLE)
85+
#if defined(MODULE)
8686
#define LOCKTORTURE_RUNNABLE_INIT 1
8787
#else
8888
#define LOCKTORTURE_RUNNABLE_INIT 0
8989
#endif
9090
int locktorture_runnable = LOCKTORTURE_RUNNABLE_INIT;
9191
module_param(locktorture_runnable, int, 0444);
92-
MODULE_PARM_DESC(locktorture_runnable, "Start locktorture at boot");
92+
MODULE_PARM_DESC(locktorture_runnable, "Start locktorture at module init");
9393

9494
/* Forward reference. */
9595
static void lock_torture_cleanup(void);
@@ -219,7 +219,8 @@ static int lock_torture_writer(void *arg)
219219
set_user_nice(current, 19);
220220

221221
do {
222-
schedule_timeout_uninterruptible(1);
222+
if ((torture_random(&rand) & 0xfffff) == 0)
223+
schedule_timeout_uninterruptible(1);
223224
cur_ops->writelock();
224225
if (WARN_ON_ONCE(lock_is_write_held))
225226
lwsp->n_write_lock_fail++;
@@ -354,7 +355,8 @@ static int __init lock_torture_init(void)
354355
&lock_busted_ops, &spin_lock_ops, &spin_lock_irq_ops,
355356
};
356357

357-
torture_init_begin(torture_type, verbose, &locktorture_runnable);
358+
if (!torture_init_begin(torture_type, verbose, &locktorture_runnable))
359+
return -EBUSY;
358360

359361
/* Process args and tell the world that the torturer is on the job. */
360362
for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {

0 commit comments

Comments
 (0)