[Devel] [PATCH RHEL7 COMMIT] blk-cbt: Don't disable interrupts when working with percpu cache

Konstantin Khorenko khorenko at virtuozzo.com
Tue Mar 7 21:15:10 MSK 2023


The commit is pushed to "branch-rh7-3.10.0-1160.83.1.vz7.194.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.83.1.vz7.194.5
------>
commit f7ce23edaf87460d302a3c3bcfe20774c9aaae10
Author: Nikolay Borisov <nikolay.borisov at virtuozzo.com>
Date:   Tue Jan 31 14:24:00 2023 +0200

    blk-cbt: Don't disable interrupts when working with percpu cache
    
    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.
    
    Fixes: 7f5e9ebe4c63 ("cbt: bitmap corruption caused by ipi")
    
    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 432697f009dc..108c55a8e7d1 100644
--- a/block/blk-cbt.c
+++ b/block/blk-cbt.c
@@ -233,17 +233,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);


More information about the Devel mailing list