Skip to contentSkip to conversation

io-wq: using kfree_rcu() to simplify the code

PATCH Applied YueHaibing 2 participants 2 messages Nov 2, 2019 VFS

lore
Share & tools
lore

YueHaibing

author
#0 lore raw

PATCH 1/1 io-wq: using kfree_rcu() to simplify the code

The callback function of call_rcu() just calls a kfree(), so can use kfree_rcu() instead of call_rcu() + callback function.

---
 fs/io-wq.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
fs/io-wq.c +1 -8
index 652b8ba..3bbab2c 100644
@@ -102,13 +102,6 @@ struct io_wq {
 	struct completion done;
 };
 
-static void io_wq_free_worker(struct rcu_head *head)
-{
-	struct io_worker *worker = container_of(head, struct io_worker, rcu);
-
-	kfree(worker);
-}
-
 static bool io_worker_get(struct io_worker *worker)
 {
 	return refcount_inc_not_zero(&worker->ref);
@@ -194,7 +187,7 @@ static void io_worker_exit(struct io_worker *worker)
 	if (all_done && refcount_dec_and_test(&wqe->wq->refs))
 		complete(&wqe->wq->done);
 
-	call_rcu(&worker->rcu, io_wq_free_worker);
+	kfree_rcu(worker, rcu);
 }
 
 static void io_worker_start(struct io_wqe *wqe, struct io_worker *worker)
Signature · 1 line
2.7.4
Applied
#1 lore raw
Quoted 2 lines · YueHaibing

The callback function of call_rcu() just calls a kfree(), so can use kfree_rcu() instead of call_rcu() + callback function.

Applied, thanks.

Signature · 1 line
Jens Axboe