[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20190613101809.16231-1-rocking@whu.edu.cn>
Date: Thu, 13 Jun 2019 18:18:09 +0800
From: Peng Wang <rocking@....edu.cn>
To: peterz@...radead.org, mingo@...hat.com, will.deacon@....com
Cc: linux-kernel@...r.kernel.org, Peng Wang <rocking@....edu.cn>
Subject: [PATCH] locking/rwsem: save unnecessary rwsem_set_owner() after slow path
rwsem_down_write_failed() and rwsem_down_write_failed_killable() return
with sem->owner set if acquire semaphore successfully, so we can skip
rwsem_set_owner() to keep pace with reading.
Signed-off-by: Peng Wang <rocking@....edu.cn>
---
kernel/locking/rwsem.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/kernel/locking/rwsem.h b/kernel/locking/rwsem.h
index 64877f5294e3..4fa21f737151 100644
--- a/kernel/locking/rwsem.h
+++ b/kernel/locking/rwsem.h
@@ -225,7 +225,8 @@ static inline void __down_write(struct rw_semaphore *sem)
&sem->count);
if (unlikely(tmp != RWSEM_ACTIVE_WRITE_BIAS))
rwsem_down_write_failed(sem);
- rwsem_set_owner(sem);
+ else
+ rwsem_set_owner(sem);
}
static inline int __down_write_killable(struct rw_semaphore *sem)
@@ -234,10 +235,12 @@ static inline int __down_write_killable(struct rw_semaphore *sem)
tmp = atomic_long_add_return_acquire(RWSEM_ACTIVE_WRITE_BIAS,
&sem->count);
- if (unlikely(tmp != RWSEM_ACTIVE_WRITE_BIAS))
+ if (unlikely(tmp != RWSEM_ACTIVE_WRITE_BIAS)) {
if (IS_ERR(rwsem_down_write_failed_killable(sem)))
return -EINTR;
- rwsem_set_owner(sem);
+ } else {
+ rwsem_set_owner(sem);
+ }
return 0;
}
--
2.19.1
Powered by blists - more mailing lists