From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46051C433FE for ; Tue, 11 Oct 2022 09:09:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229905AbiJKJJu (ORCPT ); Tue, 11 Oct 2022 05:09:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229747AbiJKJJr (ORCPT ); Tue, 11 Oct 2022 05:09:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7DC212AF6; Tue, 11 Oct 2022 02:09:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 782AEB8077D; Tue, 11 Oct 2022 09:09:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09370C433D6; Tue, 11 Oct 2022 09:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665479384; bh=e/JcTTsFExZNIu2rmBxBfqtrwgiK/DKYtwEa/H3b/ng=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=hnndYwFMHpi4kR7q16r87yuReLUbAnhNXK2PNks+YXRBrQrMhMePbZ/Anz4g3O1NN NiEbm3Q+ORLUXvJJYLGIFpnJxUinJ8781Lc/kZiB8x6ssPYgHO4rX0he2qRSx2bsJ6 xAT5ZaY9+KuWhLeOFluc4/tftUZNnEhuAA8Hi/dokQZ9zy48rwFuQRg2pmx7Wfd5/J d0jjAo3fWJdbwTBghHxIQ7DEH+uRL2bDdzGVnHJOLLs8z9LMnkbvDygVD9GZJWRNV8 QQNQ3G6LfpBvYCkdx3h4Viib54arAzqf7Z0YW/PI+/SkNj9XtqTRAmVQx8hwfLEOTv tSQQ9Ghhzod8w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 5D5F85C1959; Tue, 11 Oct 2022 02:09:41 -0700 (PDT) Date: Tue, 11 Oct 2022 02:09:41 -0700 From: "Paul E. McKenney" To: Hou Tao Cc: bpf@vger.kernel.org, Martin KaFai Lau , Andrii Nakryiko , Song Liu , Hao Luo , Yonghong Song , Alexei Starovoitov , Daniel Borkmann , KP Singh , "David S . Miller" , Jakub Kicinski , Stanislav Fomichev , Jiri Olsa , John Fastabend , Delyan Kratunov , rcu@vger.kernel.org, houtao1@huawei.com Subject: Re: [PATCH bpf-next 3/3] bpf: Free trace program array after one RCU-tasks-trace grace period Message-ID: <20221011090941.GI4221@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20221011071128.3470622-1-houtao@huaweicloud.com> <20221011071128.3470622-4-houtao@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221011071128.3470622-4-houtao@huaweicloud.com> Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org On Tue, Oct 11, 2022 at 03:11:28PM +0800, Hou Tao wrote: > From: Hou Tao > > 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(). And the same here. ;-) Thanx, Paul > Signed-off-by: Hou Tao > --- > 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 >