From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3834E7C for ; Thu, 27 Jul 2023 01:21:57 +0000 (UTC) Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E2A2A3 for ; Wed, 26 Jul 2023 18:21:55 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4RBCfK1pWfz4f3mKk for ; Thu, 27 Jul 2023 09:21:45 +0800 (CST) Received: from [10.174.176.117] (unknown [10.174.176.117]) by APP4 (Coremail) with SMTP id gCh0CgB337KoxsFkvoWUOw--.19749S2; Thu, 27 Jul 2023 09:21:47 +0800 (CST) Subject: Re: [PATCH bpf 1/2] bpf/memalloc: Non-atomically allocate freelist during prefill To: YiFei Zhu Cc: bpf@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Stanislav Fomichev , Martin KaFai Lau , Andrii Nakryiko References: <0f90694e-308c-65e6-5360-a3d5dc7337b1@huaweicloud.com> <0d242e21-3f53-87ca-7aa8-bb55b5223552@huaweicloud.com> From: Hou Tao Message-ID: <8a8ab9b4-e2f1-9f53-f9ab-a3affadf332b@huaweicloud.com> Date: Thu, 27 Jul 2023 09:21:44 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID:gCh0CgB337KoxsFkvoWUOw--.19749S2 X-Coremail-Antispam: 1U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flected X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Hi, On 7/27/2023 2:44 AM, YiFei Zhu wrote: > On Wed, Jul 26, 2023 at 4:38 AM Hou Tao wrote: >> Hi, >> >> On 7/21/2023 10:31 AM, YiFei Zhu wrote: >>> On Thu, Jul 20, 2023 at 6:45 PM Hou Tao wrote: >>>> On 7/21/2023 4:44 AM, YiFei Zhu wrote: >>>>> Sometimes during prefill all precpu chunks are full and atomic >>>>> __alloc_percpu_gfp would not allocate new chunks. This will cause >>>>> -ENOMEM immediately upon next unit_alloc. >>>>> >>>>> Prefill phase does not actually run in atomic context, so we can >>>>> use this fact to allocate non-atomically with GFP_KERNEL instead >>>>> of GFP_NOWAIT. This avoids the immediate -ENOMEM. Unfortunately >>>>> unit_alloc runs in atomic context, even from map item allocation in >>>>> syscalls, due to rcu_read_lock, so we can't do non-atomic >>>>> workarounds in unit_alloc. >>>>> >>>>> Fixes: 4ab67149f3c6 ("bpf: Add percpu allocation support to bpf_mem_alloc.") >>>>> Signed-off-by: YiFei Zhu >>>> Make sense to me, so >>>> >>>> Acked-by: Hou Tao >>>> >>>> But I don't know whether or not it is suitable for bpf tree. >>> I don't mind either way :) If changing to bpf-next requires a resend I >>> can do that too. >> Please resend and rebase the patch again bpf-next tree. >> > Will do. Should I drop the Fixes tag then? Before the introduction of bpf memory allocator, the allocation flag for per-cpu memory allocation in hash map is GFP_NOWAIT. BPF memory allocator doesn't change that, so I think we could drop the Fixes tag. > > YiFei Zhu > > .