Skip to content

Commit 623baa0

Browse files
paulmckrcuNeeraj Upadhyay (AMD)
authored andcommitted
srcu: Remove SRCU-lite implementation
This commit removes the SRCU-lite implementation, which has been replaced by SRCU-fast. Both SRCU-lite and SRCU-fast provide faster readers by dropping the smp_mb() call from their lock and unlock primitives, but incur a pair of added RCU grace periods during the SRCU grace period. There is a trivial mapping from the SRCU-lite API to that of SRCU-fast, so there should be no transition issues. [ paulmck: Apply Christoph Hellwig feedback. ] Signed-off-by: "Paul E. McKenney" <[email protected]> Signed-off-by: Neeraj Upadhyay (AMD) <[email protected]>
1 parent 3aea745 commit 623baa0

File tree

3 files changed

+2
-86
lines changed

3 files changed

+2
-86
lines changed

include/linux/srcu.h

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ int init_srcu_struct(struct srcu_struct *ssp);
4646
/* Values for SRCU Tree srcu_data ->srcu_reader_flavor, but also used by rcutorture. */
4747
#define SRCU_READ_FLAVOR_NORMAL 0x1 // srcu_read_lock().
4848
#define SRCU_READ_FLAVOR_NMI 0x2 // srcu_read_lock_nmisafe().
49-
#define SRCU_READ_FLAVOR_LITE 0x4 // srcu_read_lock_lite().
49+
// 0x4 // SRCU-lite is no longer with us.
5050
#define SRCU_READ_FLAVOR_FAST 0x8 // srcu_read_lock_fast().
5151
#define SRCU_READ_FLAVOR_ALL (SRCU_READ_FLAVOR_NORMAL | SRCU_READ_FLAVOR_NMI | \
5252
SRCU_READ_FLAVOR_FAST) // All of the above.
53-
#define SRCU_READ_FLAVOR_SLOWGP (SRCU_READ_FLAVOR_LITE | SRCU_READ_FLAVOR_FAST)
53+
#define SRCU_READ_FLAVOR_SLOWGP SRCU_READ_FLAVOR_FAST
5454
// Flavors requiring synchronize_rcu()
5555
// instead of smp_mb().
5656
void __srcu_read_unlock(struct srcu_struct *ssp, int idx) __releases(ssp);
@@ -299,33 +299,6 @@ static inline struct srcu_ctr __percpu *srcu_down_read_fast(struct srcu_struct *
299299
return __srcu_read_lock_fast(ssp);
300300
}
301301

302-
/**
303-
* srcu_read_lock_lite - register a new reader for an SRCU-protected structure.
304-
* @ssp: srcu_struct in which to register the new reader.
305-
*
306-
* Enter an SRCU read-side critical section, but for a light-weight
307-
* smp_mb()-free reader. See srcu_read_lock() for more information.
308-
*
309-
* If srcu_read_lock_lite() is ever used on an srcu_struct structure,
310-
* then none of the other flavors may be used, whether before, during,
311-
* or after. Note that grace-period auto-expediting is disabled for _lite
312-
* srcu_struct structures because auto-expedited grace periods invoke
313-
* synchronize_rcu_expedited(), IPIs and all.
314-
*
315-
* Note that srcu_read_lock_lite() can be invoked only from those contexts
316-
* where RCU is watching, that is, from contexts where it would be legal
317-
* to invoke rcu_read_lock(). Otherwise, lockdep will complain.
318-
*/
319-
static inline int srcu_read_lock_lite(struct srcu_struct *ssp) __acquires(ssp)
320-
{
321-
int retval;
322-
323-
srcu_check_read_flavor_force(ssp, SRCU_READ_FLAVOR_LITE);
324-
retval = __srcu_read_lock_lite(ssp);
325-
rcu_try_lock_acquire(&ssp->dep_map);
326-
return retval;
327-
}
328-
329302
/**
330303
* srcu_read_lock_nmisafe - register a new reader for an SRCU-protected structure.
331304
* @ssp: srcu_struct in which to register the new reader.
@@ -434,22 +407,6 @@ static inline void srcu_up_read_fast(struct srcu_struct *ssp, struct srcu_ctr __
434407
__srcu_read_unlock_fast(ssp, scp);
435408
}
436409

437-
/**
438-
* srcu_read_unlock_lite - unregister a old reader from an SRCU-protected structure.
439-
* @ssp: srcu_struct in which to unregister the old reader.
440-
* @idx: return value from corresponding srcu_read_lock_lite().
441-
*
442-
* Exit a light-weight SRCU read-side critical section.
443-
*/
444-
static inline void srcu_read_unlock_lite(struct srcu_struct *ssp, int idx)
445-
__releases(ssp)
446-
{
447-
WARN_ON_ONCE(idx & ~0x1);
448-
srcu_check_read_flavor(ssp, SRCU_READ_FLAVOR_LITE);
449-
srcu_lock_release(&ssp->dep_map);
450-
__srcu_read_unlock_lite(ssp, idx);
451-
}
452-
453410
/**
454411
* srcu_read_unlock_nmisafe - unregister a old reader from an SRCU-protected structure.
455412
* @ssp: srcu_struct in which to unregister the old reader.

include/linux/srcutiny.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ static inline void __srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_
9393
__srcu_read_unlock(ssp, __srcu_ptr_to_ctr(ssp, scp));
9494
}
9595

96-
#define __srcu_read_lock_lite __srcu_read_lock
97-
#define __srcu_read_unlock_lite __srcu_read_unlock
98-
9996
static inline void synchronize_srcu_expedited(struct srcu_struct *ssp)
10097
{
10198
synchronize_srcu(ssp);

include/linux/srcutree.h

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -278,44 +278,6 @@ static inline void __srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_
278278
RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_unlock_fast().");
279279
}
280280

281-
/*
282-
* Counts the new reader in the appropriate per-CPU element of the
283-
* srcu_struct. Returns an index that must be passed to the matching
284-
* srcu_read_unlock_lite().
285-
*
286-
* Note that this_cpu_inc() is an RCU read-side critical section either
287-
* because it disables interrupts, because it is a single instruction,
288-
* or because it is a read-modify-write atomic operation, depending on
289-
* the whims of the architecture.
290-
*/
291-
static inline int __srcu_read_lock_lite(struct srcu_struct *ssp)
292-
{
293-
struct srcu_ctr __percpu *scp = READ_ONCE(ssp->srcu_ctrp);
294-
295-
RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_lock_lite().");
296-
this_cpu_inc(scp->srcu_locks.counter); /* Y */
297-
barrier(); /* Avoid leaking the critical section. */
298-
return __srcu_ptr_to_ctr(ssp, scp);
299-
}
300-
301-
/*
302-
* Removes the count for the old reader from the appropriate
303-
* per-CPU element of the srcu_struct. Note that this may well be a
304-
* different CPU than that which was incremented by the corresponding
305-
* srcu_read_lock_lite(), but it must be within the same task.
306-
*
307-
* Note that this_cpu_inc() is an RCU read-side critical section either
308-
* because it disables interrupts, because it is a single instruction,
309-
* or because it is a read-modify-write atomic operation, depending on
310-
* the whims of the architecture.
311-
*/
312-
static inline void __srcu_read_unlock_lite(struct srcu_struct *ssp, int idx)
313-
{
314-
barrier(); /* Avoid leaking the critical section. */
315-
this_cpu_inc(__srcu_ctr_to_ptr(ssp, idx)->srcu_unlocks.counter); /* Z */
316-
RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_unlock_lite().");
317-
}
318-
319281
void __srcu_check_read_flavor(struct srcu_struct *ssp, int read_flavor);
320282

321283
// Record reader usage even for CONFIG_PROVE_RCU=n kernels. This is

0 commit comments

Comments
 (0)