All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hou Tao <houtao@huaweicloud.com>
To: bpf@vger.kernel.org
Cc: Martin KaFai Lau <kafai@fb.com>,
	Andrii Nakryiko <andrii@kernel.org>,
	Song Liu <songliubraving@fb.com>, Hao Luo <haoluo@google.com>,
	Yonghong Song <yhs@fb.com>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	KP Singh <kpsingh@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Stanislav Fomichev <sdf@google.com>, Jiri Olsa <jolsa@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Delyan Kratunov <delyank@fb.com>,
	rcu@vger.kernel.org, houtao1@huawei.com
Subject: [PATCH bpf-next 3/3] bpf: Free trace program array after one RCU-tasks-trace grace period
Date: Tue, 11 Oct 2022 15:11:28 +0800	[thread overview]
Message-ID: <20221011071128.3470622-4-houtao@huaweicloud.com> (raw)
In-Reply-To: <20221011071128.3470622-1-houtao@huaweicloud.com>

From: Hou Tao <houtao1@huawei.com>

To support sleepable uprobe bpf program, the freeing of trace program
array chains a RCU-tasks-trace grace period with a normal RCU grace
period. But considering in the current implementation of RCU-tasks-trace
that one RCU-tasks-trace grace period implies one normal RCU grace
period, so it is not need for such chaining and it is safe to free the
array in the callback of call_rcu_tasks_trace().

Signed-off-by: Hou Tao <houtao1@huawei.com>
---
 kernel/bpf/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 711fd293b6de..f943620b55b0 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -2247,12 +2247,15 @@ void bpf_prog_array_free(struct bpf_prog_array *progs)
 	kfree_rcu(progs, rcu);
 }
 
+/* Now RCU Tasks grace period implies RCU grace period, so no need to call
+ * kfree_rcu(), just call kfree() directly.
+ */
 static void __bpf_prog_array_free_sleepable_cb(struct rcu_head *rcu)
 {
 	struct bpf_prog_array *progs;
 
 	progs = container_of(rcu, struct bpf_prog_array, rcu);
-	kfree_rcu(progs, rcu);
+	kfree(progs);
 }
 
 void bpf_prog_array_free_sleepable(struct bpf_prog_array *progs)
-- 
2.29.2


  parent reply	other threads:[~2022-10-11  6:45 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11  7:11 [PATCH bpf-next 0/3] Remove unnecessary RCU grace period chaining Hou Tao
2022-10-11  7:11 ` [PATCH bpf-next 1/3] bpf: Free elements after one RCU-tasks-trace grace period Hou Tao
2022-10-11  9:07   ` Paul E. McKenney
2022-10-11 11:31     ` Hou Tao
2022-10-12  6:36       ` Paul E. McKenney
2022-10-12  9:26         ` Hou Tao
2022-10-12 16:11           ` Paul E. McKenney
2022-10-13  1:25             ` Hou Tao
2022-10-13  5:07               ` Martin KaFai Lau
2022-10-13  9:02                 ` Hou Tao
2022-10-13 19:00               ` Paul E. McKenney
2022-10-14  4:20                 ` Hou Tao
2022-10-14 12:15                   ` Paul E. McKenney
2022-10-17  6:55                     ` Hou Tao
2022-10-17 10:23                       ` Paul E. McKenney
2022-10-13  1:41             ` Hou Tao
2022-10-13 19:04               ` Paul E. McKenney
2022-10-14  4:04                 ` Hou Tao
2022-10-11  7:11 ` [PATCH bpf-next 2/3] bpf: Free local storage memory " Hou Tao
2022-10-11  9:09   ` Paul E. McKenney
2022-10-11  7:11 ` Hou Tao [this message]
2022-10-11  9:09   ` [PATCH bpf-next 3/3] bpf: Free trace program array " Paul E. McKenney

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=20221011071128.3470622-4-houtao@huaweicloud.com \
    --to=houtao@huaweicloud.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=delyank@fb.com \
    --cc=haoluo@google.com \
    --cc=houtao1@huawei.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=sdf@google.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.