rmlock: Micro-optimize read locking

Use get_pcpu() instead of an open-coded pcpu_find(td->td_oncpu).  This
eliminates some memory accesses and results in a shorter instruction
sequence.  Note that get_pcpu() didn't exist when rmlocks were added.

Reviewed by:	jah, mjg
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34377
This commit is contained in:
Mark Johnston 2022-02-25 13:42:51 -05:00
parent 1517b8d5a7
commit c84bb8cd77

View File

@ -452,7 +452,7 @@ _rm_rlock(struct rmlock *rm, struct rm_priotracker *tracker, int trylock)
atomic_interrupt_fence();
pc = cpuid_to_pcpu[td->td_oncpu]; /* pcpu_find(td->td_oncpu); */
pc = get_pcpu();
rm_tracker_add(pc, tracker);
@ -517,7 +517,7 @@ _rm_runlock(struct rmlock *rm, struct rm_priotracker *tracker)
return;
td->td_critnest++; /* critical_enter(); */
pc = cpuid_to_pcpu[td->td_oncpu]; /* pcpu_find(td->td_oncpu); */
pc = get_pcpu();
rm_tracker_remove(pc, tracker);
td->td_critnest--;
sched_unpin();