[Devel] [PATCH 2/3] blk-cbt: Don't disable interrupts when working with percpu cache

Nikolay Borisov nikolay.borisov at virtuozzo.com
Tue Jan 31 15:24:00 MSK 2023


When working with percpu variables the only guarantee we need is that
the process is not preempted. So let's do this by using the more
idiomatic get_cpu_ptr/put_cpu_ptr rather than the more heavyweight
local_irq_disable. No functional changes.

Signed-off-by: Nikolay Borisov <nikolay.borisov at virtuozzo.com>
---
 block/blk-cbt.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/block/blk-cbt.c b/block/blk-cbt.c
index 8baeb2804a61..d49ca7fc2865 100644
--- a/block/blk-cbt.c
+++ b/block/blk-cbt.c
@@ -238,17 +238,16 @@ static void blk_cbt_add(struct request_queue *q, blkcnt_t start, blkcnt_t len)
 		__blk_cbt_set(cbt, start, len, 1, 1, NULL, NULL);
 		goto out_rcu;
 	}
-	local_irq_disable();
-	ex = this_cpu_ptr(cbt->cache);
+	ex = get_cpu_ptr(cbt->cache);
 	if (ex->start + ex->len == start) {
 		ex->len += len;
-		local_irq_enable();
+		put_cpu_ptr(cbt->cache);
 		goto out_rcu;
 	}
 	old = *ex;
 	ex->start = start;
 	ex->len = len;
-	local_irq_enable();
+	put_cpu_ptr(cbt->cache);
 
 	if (likely(old.len))
 		__blk_cbt_set(cbt, old.start, old.len, 1, 1, NULL, NULL);
-- 
2.34.1



More information about the Devel mailing list