Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

percpu-rw-semaphores: use rcu_read_lock_sched

Use rcu_read_lock_sched / rcu_read_unlock_sched / synchronize_sched
instead of rcu_read_lock / rcu_read_unlock / synchronize_rcu.

This is an optimization. The RCU-protected region is very small, so
there will be no latency problems if we disable preempt in this region.

So we use rcu_read_lock_sched / rcu_read_unlock_sched that translates
to preempt_disable / preempt_disable. It is smaller (and supposedly
faster) than preemptible rcu_read_lock / rcu_read_unlock.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Mikulas Patocka and committed by
Linus Torvalds
1bf11c53 5c1eabe6

+4 -4
+4 -4
include/linux/percpu-rwsem.h
··· 17 17 18 18 static inline void percpu_down_read(struct percpu_rw_semaphore *p) 19 19 { 20 - rcu_read_lock(); 20 + rcu_read_lock_sched(); 21 21 if (unlikely(p->locked)) { 22 - rcu_read_unlock(); 22 + rcu_read_unlock_sched(); 23 23 mutex_lock(&p->mtx); 24 24 this_cpu_inc(*p->counters); 25 25 mutex_unlock(&p->mtx); 26 26 return; 27 27 } 28 28 this_cpu_inc(*p->counters); 29 - rcu_read_unlock(); 29 + rcu_read_unlock_sched(); 30 30 light_mb(); /* A, between read of p->locked and read of data, paired with D */ 31 31 } 32 32 ··· 51 51 { 52 52 mutex_lock(&p->mtx); 53 53 p->locked = true; 54 - synchronize_rcu(); 54 + synchronize_sched(); /* make sure that all readers exit the rcu_read_lock_sched region */ 55 55 while (__percpu_count(p->counters)) 56 56 msleep(1); 57 57 heavy_mb(); /* C, between read of p->counter and write to data, paired with B */