diff mbox series

blk-core: replace call_rcu by kfree_rcu for simple kmem_cache_free callback

Message ID 20241025030709.9520-1-zenghongling@kylinos.cn (mailing list archive)
State New
Headers show
Series blk-core: replace call_rcu by kfree_rcu for simple kmem_cache_free callback | expand

Commit Message

Hongling Zeng Oct. 25, 2024, 3:07 a.m. UTC
Since SLOB was removed and since
commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"),
it is not necessary to use call_rcu when the callback only performs
kmem_cache_free. Use kfree_rcu() directly.

The changes were made using Coccinelle.

Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
---
 block/blk-core.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

Comments

Jens Axboe Oct. 25, 2024, 3:18 a.m. UTC | #1
On Oct 24, 2024, at 9:07 PM, Hongling Zeng <zenghongling@kylinos.cn> wrote:
> 
> Since SLOB was removed and since
> commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"),
> it is not necessary to use call_rcu when the callback only performs
> kmem_cache_free. Use kfree_rcu() directly.

I’d take an extra look at that one if I were you. 

— 
Jens Axboe
diff mbox series

Patch

diff --git a/block/blk-core.c b/block/blk-core.c
index bc5e8c5..459eb7e 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -245,14 +245,6 @@  void blk_clear_pm_only(struct request_queue *q)
 }
 EXPORT_SYMBOL_GPL(blk_clear_pm_only);
 
-static void blk_free_queue_rcu(struct rcu_head *rcu_head)
-{
-	struct request_queue *q = container_of(rcu_head,
-			struct request_queue, rcu_head);
-
-	percpu_ref_exit(&q->q_usage_counter);
-	kmem_cache_free(blk_requestq_cachep, q);
-}
 
 static void blk_free_queue(struct request_queue *q)
 {
@@ -261,7 +253,7 @@  static void blk_free_queue(struct request_queue *q)
 		blk_mq_release(q);
 
 	ida_free(&blk_queue_ida, q->id);
-	call_rcu(&q->rcu_head, blk_free_queue_rcu);
+	kfree_rcu(q, rcu_head);
 }
 
 /**