[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20210927163847.3308333-2-yanfei.xu@windriver.com>
Date: Tue, 28 Sep 2021 00:38:47 +0800
From: Yanfei Xu <yanfei.xu@...driver.com>
To: peterz@...radead.org, mingo@...hat.com, will@...nel.org,
longman@...hat.com, boqun.feng@...il.com
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH 2/2] locking/rwsem: add preempt_disable/enable for spin region
The rwsem_optimistic_spin() invokes the rwsem_spin_on_owner() with
preemption disabled, but rwsem_down_write_slowpath() doesn't. Because
the spin region should not be preempted, add preempt_disable/enable()
in rwsem_spin_on_owner().
Signed-off-by: Yanfei Xu <yanfei.xu@...driver.com>
---
kernel/locking/rwsem.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
index 2907f9d8e4a6..db3a6a06a9c8 100644
--- a/kernel/locking/rwsem.c
+++ b/kernel/locking/rwsem.c
@@ -674,6 +674,7 @@ rwsem_spin_on_owner(struct rw_semaphore *sem)
if (state != OWNER_WRITER)
return state;
+ preempt_disable();
rcu_read_lock();
for (;;) {
/*
@@ -704,6 +705,7 @@ rwsem_spin_on_owner(struct rw_semaphore *sem)
cpu_relax();
}
rcu_read_unlock();
+ preempt_enable();
return state;
}
--
2.27.0
Powered by blists - more mailing lists