svn commit: r357673 - head/sys/kern
Mateusz Guzik
mjg at FreeBSD.org
Fri Feb 7 22:44:42 UTC 2020
Author: mjg
Date: Fri Feb 7 22:44:41 2020
New Revision: 357673
URL: https://svnweb.freebsd.org/changeset/base/357673
Log:
rms: use newly added zpcpu routines instead of direct access where appropriate
Modified:
head/sys/kern/kern_rmlock.c
Modified: head/sys/kern/kern_rmlock.c
==============================================================================
--- head/sys/kern/kern_rmlock.c Fri Feb 7 22:43:58 2020 (r357672)
+++ head/sys/kern/kern_rmlock.c Fri Feb 7 22:44:41 2020 (r357673)
@@ -900,60 +900,56 @@ static void __noinline
rms_rlock_fallback(struct rmslock *rms)
{
- (*zpcpu_get(rms->readers_influx)) = 0;
+ zpcpu_set_protected(rms->readers_influx, 0);
critical_exit();
mtx_lock(&rms->mtx);
MPASS(*zpcpu_get(rms->readers_pcpu) == 0);
while (rms->writers > 0)
msleep(&rms->readers, &rms->mtx, PUSER - 1, mtx_name(&rms->mtx), 0);
- (*zpcpu_get(rms->readers_pcpu))++;
+ critical_enter();
+ zpcpu_add_protected(rms->readers_pcpu, 1);
mtx_unlock(&rms->mtx);
+ critical_exit();
}
void
rms_rlock(struct rmslock *rms)
{
- int *influx;
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
critical_enter();
- influx = zpcpu_get(rms->readers_influx);
+ zpcpu_set_protected(rms->readers_influx, 1);
__compiler_membar();
- *influx = 1;
- __compiler_membar();
if (__predict_false(rms->writers > 0)) {
rms_rlock_fallback(rms);
return;
}
__compiler_membar();
- (*zpcpu_get(rms->readers_pcpu))++;
+ zpcpu_add_protected(rms->readers_pcpu, 1);
__compiler_membar();
- *influx = 0;
+ zpcpu_set_protected(rms->readers_influx, 0);
critical_exit();
}
int
rms_try_rlock(struct rmslock *rms)
{
- int *influx;
critical_enter();
- influx = zpcpu_get(rms->readers_influx);
+ zpcpu_set_protected(rms->readers_influx, 1);
__compiler_membar();
- *influx = 1;
- __compiler_membar();
if (__predict_false(rms->writers > 0)) {
__compiler_membar();
- *influx = 0;
+ zpcpu_set_protected(rms->readers_influx, 0);
critical_exit();
return (0);
}
__compiler_membar();
- (*zpcpu_get(rms->readers_pcpu))++;
+ zpcpu_add_protected(rms->readers_pcpu, 1);
__compiler_membar();
- *influx = 0;
+ zpcpu_set_protected(rms->readers_influx, 0);
critical_exit();
return (1);
}
@@ -962,7 +958,7 @@ static void __noinline
rms_runlock_fallback(struct rmslock *rms)
{
- (*zpcpu_get(rms->readers_influx)) = 0;
+ zpcpu_set_protected(rms->readers_influx, 0);
critical_exit();
mtx_lock(&rms->mtx);
@@ -978,21 +974,18 @@ rms_runlock_fallback(struct rmslock *rms)
void
rms_runlock(struct rmslock *rms)
{
- int *influx;
critical_enter();
- influx = zpcpu_get(rms->readers_influx);
+ zpcpu_set_protected(rms->readers_influx, 1);
__compiler_membar();
- *influx = 1;
- __compiler_membar();
if (__predict_false(rms->writers > 0)) {
rms_runlock_fallback(rms);
return;
}
__compiler_membar();
- (*zpcpu_get(rms->readers_pcpu))--;
+ zpcpu_sub_protected(rms->readers_pcpu, 1);
__compiler_membar();
- *influx = 0;
+ zpcpu_set_protected(rms->readers_influx, 0);
critical_exit();
}
More information about the svn-src-all
mailing list