mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>, Tejun Heo <tj@kernel.org>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	Zhong Jinghua <zhongjinghua@huawei.com>,
	Yu Kuai <yukuai3@huawei.com>, Dennis Zhou <dennis@kernel.org>,
	Ming Lei <ming.lei@redhat.com>
Subject: [PATCH 2/3] lib/percpu-refcount: apply PERCPU_REF_AUTO_EXIT
Date: Wed, 14 Dec 2022 10:51:00 +0800	[thread overview]
Message-ID: <20221214025101.1268437-3-ming.lei@redhat.com> (raw)
In-Reply-To: <20221214025101.1268437-1-ming.lei@redhat.com>

Apply the added new flag of PERCPU_REF_AUTO_EXIT, so that users needn't
to call percpu_ref_exit() in ->release() any more.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 drivers/infiniband/ulp/rtrs/rtrs-srv.c | 4 ++--
 mm/memcontrol.c                        | 5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
index 22d7ba05e9fe..07d1af3fad28 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
@@ -122,7 +122,6 @@ static inline void rtrs_srv_inflight_ref_release(struct percpu_ref *ref)
 						      struct rtrs_srv_path,
 						      ids_inflight_ref);
 
-	percpu_ref_exit(&srv_path->ids_inflight_ref);
 	complete(&srv_path->complete_done);
 }
 
@@ -147,7 +146,8 @@ static int rtrs_srv_alloc_ops_ids(struct rtrs_srv_path *srv_path)
 	}
 
 	ret = percpu_ref_init(&srv_path->ids_inflight_ref,
-			      rtrs_srv_inflight_ref_release, 0, GFP_KERNEL);
+			      rtrs_srv_inflight_ref_release,
+			      PERCPU_REF_AUTO_EXIT, GFP_KERNEL);
 	if (ret) {
 		pr_err("Percpu reference init failed\n");
 		goto err;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 266a1ab05434..eaca7d16b143 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -294,7 +294,6 @@ static void obj_cgroup_release(struct percpu_ref *ref)
 	list_del(&objcg->list);
 	spin_unlock_irqrestore(&objcg_lock, flags);
 
-	percpu_ref_exit(ref);
 	kfree_rcu(objcg, rcu);
 }
 
@@ -307,8 +306,8 @@ static struct obj_cgroup *obj_cgroup_alloc(void)
 	if (!objcg)
 		return NULL;
 
-	ret = percpu_ref_init(&objcg->refcnt, obj_cgroup_release, 0,
-			      GFP_KERNEL);
+	ret = percpu_ref_init(&objcg->refcnt, obj_cgroup_release,
+			PERCPU_REF_AUTO_EXIT, GFP_KERNEL);
 	if (ret) {
 		kfree(objcg);
 		return NULL;
-- 
2.38.1


  parent reply	other threads:[~2022-12-14  2:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14  2:50 [PATCH 0/3] lib/percpu-refcount: fix use-after-free by late ->release Ming Lei
2022-12-14  2:50 ` [PATCH 1/3] lib/percpu-refcount: support to exit refcount automatically during releasing Ming Lei
2022-12-14  2:51 ` Ming Lei [this message]
2022-12-14  2:51 ` [PATCH 3/3] lib/percpu-refcount: drain ->release() in perpcu_ref_exit() Ming Lei
2022-12-15 16:54   ` Tejun Heo
2022-12-16 23:06   ` kernel test robot
2022-12-17  0:37   ` kernel test robot
2022-12-17  7:32   ` kernel test robot
     [not found] ` <20221214081651.954-1-hdanton@sina.com>
2022-12-14 13:30   ` Ming Lei
2022-12-14 16:07     ` Dennis Zhou
2022-12-15  0:34       ` Ming Lei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221214025101.1268437-3-ming.lei@redhat.com \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=dennis@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=yukuai3@huawei.com \
    --cc=zhongjinghua@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®