@@ -57,9 +57,9 @@ MODULE_AUTHOR("Paul E. McKenney <
[email protected] > and Josh Triplett <josh@
57
57
58
58
/* Bits for ->extendables field, extendables param, and related definitions. */
59
59
#define RCUTORTURE_RDR_SHIFT_1 8 /* Put SRCU index in upper bits. */
60
- #define RCUTORTURE_RDR_MASK_1 (1 << RCUTORTURE_RDR_SHIFT_1)
61
- #define RCUTORTURE_RDR_SHIFT_2 9 /* Put SRCU index in upper bits. */
62
- #define RCUTORTURE_RDR_MASK_2 (1 << RCUTORTURE_RDR_SHIFT_2)
60
+ #define RCUTORTURE_RDR_MASK_1 (0xff << RCUTORTURE_RDR_SHIFT_1)
61
+ #define RCUTORTURE_RDR_SHIFT_2 16 /* Put SRCU index in upper bits. */
62
+ #define RCUTORTURE_RDR_MASK_2 (0xff << RCUTORTURE_RDR_SHIFT_2)
63
63
#define RCUTORTURE_RDR_BH 0x01 /* Extend readers by disabling bh. */
64
64
#define RCUTORTURE_RDR_IRQ 0x02 /* ... disabling interrupts. */
65
65
#define RCUTORTURE_RDR_PREEMPT 0x04 /* ... disabling preemption. */
@@ -71,6 +71,9 @@ MODULE_AUTHOR("Paul E. McKenney <
[email protected] > and Josh Triplett <josh@
71
71
#define RCUTORTURE_MAX_EXTEND \
72
72
(RCUTORTURE_RDR_BH | RCUTORTURE_RDR_IRQ | RCUTORTURE_RDR_PREEMPT | \
73
73
RCUTORTURE_RDR_RBH | RCUTORTURE_RDR_SCHED)
74
+ #define RCUTORTURE_RDR_ALLBITS \
75
+ (RCUTORTURE_MAX_EXTEND | RCUTORTURE_RDR_RCU_1 | RCUTORTURE_RDR_RCU_2 | \
76
+ RCUTORTURE_RDR_MASK_1 | RCUTORTURE_RDR_MASK_2)
74
77
#define RCUTORTURE_RDR_MAX_LOOPS 0x7 /* Maximum reader extensions. */
75
78
/* Must be power of two minus one. */
76
79
#define RCUTORTURE_RDR_MAX_SEGS (RCUTORTURE_RDR_MAX_LOOPS + 3)
@@ -1820,7 +1823,7 @@ static void rcutorture_one_extend(int *readstate, int newstate,
1820
1823
int statesold = * readstate & ~newstate ;
1821
1824
1822
1825
WARN_ON_ONCE (idxold2 < 0 );
1823
- WARN_ON_ONCE (( idxold2 >> RCUTORTURE_RDR_SHIFT_2 ) > 1 );
1826
+ WARN_ON_ONCE (idxold2 & ~ RCUTORTURE_RDR_ALLBITS );
1824
1827
rtrsp -> rt_readstate = newstate ;
1825
1828
1826
1829
/* First, put new protection in place to avoid critical-section gap. */
@@ -1835,9 +1838,9 @@ static void rcutorture_one_extend(int *readstate, int newstate,
1835
1838
if (statesnew & RCUTORTURE_RDR_SCHED )
1836
1839
rcu_read_lock_sched ();
1837
1840
if (statesnew & RCUTORTURE_RDR_RCU_1 )
1838
- idxnew1 = (cur_ops -> readlock () & 0x1 ) << RCUTORTURE_RDR_SHIFT_1 ;
1841
+ idxnew1 = (cur_ops -> readlock () << RCUTORTURE_RDR_SHIFT_1 ) & RCUTORTURE_RDR_MASK_1 ;
1839
1842
if (statesnew & RCUTORTURE_RDR_RCU_2 )
1840
- idxnew2 = (cur_ops -> readlock () & 0x1 ) << RCUTORTURE_RDR_SHIFT_2 ;
1843
+ idxnew2 = (cur_ops -> readlock () << RCUTORTURE_RDR_SHIFT_2 ) & RCUTORTURE_RDR_MASK_2 ;
1841
1844
1842
1845
/*
1843
1846
* Next, remove old protection, in decreasing order of strength
@@ -1857,7 +1860,7 @@ static void rcutorture_one_extend(int *readstate, int newstate,
1857
1860
if (statesold & RCUTORTURE_RDR_RBH )
1858
1861
rcu_read_unlock_bh ();
1859
1862
if (statesold & RCUTORTURE_RDR_RCU_2 ) {
1860
- cur_ops -> readunlock ((idxold2 >> RCUTORTURE_RDR_SHIFT_2 ) & 0x1 );
1863
+ cur_ops -> readunlock ((idxold2 & RCUTORTURE_RDR_MASK_2 ) >> RCUTORTURE_RDR_SHIFT_2 );
1861
1864
WARN_ON_ONCE (idxnew2 != -1 );
1862
1865
idxold2 = 0 ;
1863
1866
}
@@ -1867,7 +1870,7 @@ static void rcutorture_one_extend(int *readstate, int newstate,
1867
1870
lockit = !cur_ops -> no_pi_lock && !statesnew && !(torture_random (trsp ) & 0xffff );
1868
1871
if (lockit )
1869
1872
raw_spin_lock_irqsave (& current -> pi_lock , flags );
1870
- cur_ops -> readunlock ((idxold1 >> RCUTORTURE_RDR_SHIFT_1 ) & 0x1 );
1873
+ cur_ops -> readunlock ((idxold1 & RCUTORTURE_RDR_MASK_1 ) >> RCUTORTURE_RDR_SHIFT_1 );
1871
1874
WARN_ON_ONCE (idxnew1 != -1 );
1872
1875
idxold1 = 0 ;
1873
1876
if (lockit )
@@ -1882,16 +1885,13 @@ static void rcutorture_one_extend(int *readstate, int newstate,
1882
1885
if (idxnew1 == -1 )
1883
1886
idxnew1 = idxold1 & RCUTORTURE_RDR_MASK_1 ;
1884
1887
WARN_ON_ONCE (idxnew1 < 0 );
1885
- if (WARN_ON_ONCE ((idxnew1 >> RCUTORTURE_RDR_SHIFT_1 ) > 1 ))
1886
- pr_info ("Unexpected idxnew1 value of %#x\n" , idxnew1 );
1887
1888
if (idxnew2 == -1 )
1888
1889
idxnew2 = idxold2 & RCUTORTURE_RDR_MASK_2 ;
1889
1890
WARN_ON_ONCE (idxnew2 < 0 );
1890
- WARN_ON_ONCE ((idxnew2 >> RCUTORTURE_RDR_SHIFT_2 ) > 1 );
1891
1891
* readstate = idxnew1 | idxnew2 | newstate ;
1892
1892
WARN_ON_ONCE (* readstate < 0 );
1893
- if (WARN_ON_ONCE (( * readstate >> RCUTORTURE_RDR_SHIFT_2 ) > 1 ))
1894
- pr_info ("Unexpected idxnew2 value of %#x\n" , idxnew2 );
1893
+ if (WARN_ON_ONCE (* readstate & ~ RCUTORTURE_RDR_ALLBITS ))
1894
+ pr_info ("Unexpected readstate value of %#x\n" , * readstate );
1895
1895
}
1896
1896
1897
1897
/* Return the biggest extendables mask given current RCU and boot parameters. */
@@ -1916,7 +1916,7 @@ rcutorture_extend_mask(int oldmask, struct torture_random_state *trsp)
1916
1916
unsigned long preempts_irq = preempts | RCUTORTURE_RDR_IRQ ;
1917
1917
unsigned long bhs = RCUTORTURE_RDR_BH | RCUTORTURE_RDR_RBH ;
1918
1918
1919
- WARN_ON_ONCE (mask >> RCUTORTURE_RDR_SHIFT_1 );
1919
+ WARN_ON_ONCE (mask >> RCUTORTURE_RDR_SHIFT_1 ); // Can't have reader idx bits.
1920
1920
/* Mostly only one bit (need preemption!), sometimes lots of bits. */
1921
1921
if (!(randmask1 & 0x7 ))
1922
1922
mask = mask & randmask2 ;
0 commit comments