From: Pavel Begunkov <asml.silence@gmail.com> Date: 2021-10-21 13:31:03
Add percpu_ref_tryget_live_rcu(), which is a version of
percpu_ref_tryget_live() but the user is responsible for enclosing it in
a RCU read lock section.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
include/linux/percpu-refcount.h | 33 +++++++++++++++++++++++----------
1 file changed, 23 insertions(+), 10 deletions(-)
From: Pavel Begunkov <asml.silence@gmail.com> Date: 2021-10-21 13:31:06
blk_try_enter_queue() already takes rcu_read_lock/unlock, so we can
avoid the second pair in percpu_ref_tryget_live(), use a newly added
percpu_ref_tryget_live_rcu().
As rcu_read_lock/unlock imply barrier()s, it's pretty noticeable,
especially for for !CONFIG_PREEMPT_RCU (default for some distributions),
where __rcu_read_lock/unlock() are not inlined.
3.20% io_uring [kernel.vmlinux] [k] __rcu_read_unlock
3.05% io_uring [kernel.vmlinux] [k] __rcu_read_lock
2.52% io_uring [kernel.vmlinux] [k] __rcu_read_unlock
2.28% io_uring [kernel.vmlinux] [k] __rcu_read_lock
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
block/blk-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Dennis Zhou <dennis@kernel.org> Date: 2021-10-21 14:01:30
Hello,
On Thu, Oct 21, 2021 at 02:30:51PM +0100, Pavel Begunkov wrote:
quoted hunk
Add percpu_ref_tryget_live_rcu(), which is a version of
percpu_ref_tryget_live() but the user is responsible for enclosing it in
a RCU read lock section.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
include/linux/percpu-refcount.h | 33 +++++++++++++++++++++++----------
1 file changed, 23 insertions(+), 10 deletions(-)
Nit: it's dumb convention at this point, but do you mind copying this
guy up. I like consistency.
quoted hunk
@@ -283,20 +305,11 @@ static inline bool percpu_ref_tryget(struct percpu_ref *ref) */ static inline bool percpu_ref_tryget_live(struct percpu_ref *ref) {- unsigned long __percpu *percpu_count; bool ret = false; rcu_read_lock();-- if (__ref_is_percpu(ref, &percpu_count)) {- this_cpu_inc(*percpu_count);- ret = true;- } else if (!(ref->percpu_count_ptr & __PERCPU_REF_DEAD)) {- ret = atomic_long_inc_not_zero(&ref->data->count);- }-+ ret = percpu_ref_tryget_live_rcu(ref); rcu_read_unlock();- return ret; }
--
2.33.1
Currently I'm not carrying anything and I don't expect any percpu_ref
work to come in. Jens, feel free to pick this up.
Acked-by: Dennis Zhou <dennis@kernel.org>
Thanks,
Dennis
From: Pavel Begunkov <asml.silence@gmail.com> Date: 2021-10-22 09:22:33
On 10/21/21 15:01, Dennis Zhou wrote:
Hello,
On Thu, Oct 21, 2021 at 02:30:51PM +0100, Pavel Begunkov wrote:
quoted
Add percpu_ref_tryget_live_rcu(), which is a version of
percpu_ref_tryget_live() but the user is responsible for enclosing it in
a RCU read lock section.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
include/linux/percpu-refcount.h | 33 +++++++++++++++++++++++----------
1 file changed, 23 insertions(+), 10 deletions(-)
[...]
quoted
+
/**
* percpu_ref_tryget_live - try to increment a live percpu refcount
* @ref: percpu_ref to try-get
Nit: it's dumb convention at this point, but do you mind copying this
guy up. I like consistency.
Looks Jens already took it. If you still want it moved, do you mind
it in a separate patch?
And I'm not sure I follow where you want it to be, currently it's
right before percpu_ref_tryget_live, which uses it.
--
Pavel Begunkov
From: Dennis Zhou <dennis@kernel.org> Date: 2021-10-22 19:22:54
On Fri, Oct 22, 2021 at 10:22:30AM +0100, Pavel Begunkov wrote:
On 10/21/21 15:01, Dennis Zhou wrote:
quoted
Hello,
On Thu, Oct 21, 2021 at 02:30:51PM +0100, Pavel Begunkov wrote:
quoted
Add percpu_ref_tryget_live_rcu(), which is a version of
percpu_ref_tryget_live() but the user is responsible for enclosing it in
a RCU read lock section.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
include/linux/percpu-refcount.h | 33 +++++++++++++++++++++++----------
1 file changed, 23 insertions(+), 10 deletions(-)
[...]
quoted
quoted
+
/**
* percpu_ref_tryget_live - try to increment a live percpu refcount
* @ref: percpu_ref to try-get
Nit: it's dumb convention at this point, but do you mind copying this
guy up. I like consistency.
Looks Jens already took it. If you still want it moved, do you mind
it in a separate patch?
And I'm not sure I follow where you want it to be, currently it's
right before percpu_ref_tryget_live, which uses it.
Don't worry about it. I meant the @ref comment line. Honestly it's not
really useful, it's just every other header block has that convention
among most of percpu related files.
If I have to make any changes in the future, I'll clean it up then.
Thanks,
Dennis