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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88DD3C43334 for ; Thu, 7 Jul 2022 00:25:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 24CC06B0072; Wed, 6 Jul 2022 20:25:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FC916B0073; Wed, 6 Jul 2022 20:25:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EC8B6B0074; Wed, 6 Jul 2022 20:25:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 008896B0072 for ; Wed, 6 Jul 2022 20:25:15 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id C854A60D82 for ; Thu, 7 Jul 2022 00:25:15 +0000 (UTC) X-FDA: 79658409390.24.1658297 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by imf20.hostedemail.com (Postfix) with ESMTP id 4051C1C0009 for ; Thu, 7 Jul 2022 00:25:14 +0000 (UTC) Date: Wed, 6 Jul 2022 17:25:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1657153512; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0LdaR9FiBec9jtN92ZDWfwHZkl0FiXnWOtbvsNwfneg=; b=kf9hrgc2aZLUGaq33oVHT24d0K9rmQBcf9Wdx0c7sbxJcMrKx3texPWQdHML1gHQuVds86 YpFXkCfKSTaCSij3eUrYNxyMWs2DAP2Duk8VYHLe/M67gdP6EZyiUtdWduHdSjVlwT4aMx u4N6x5Fo91amVWuNKw7rxE+tP3z8WvY= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Shakeel Butt Cc: Yafang Shao , ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, quentin@isovalent.com, haoluo@google.com, bpf@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH bpf-next v2 1/2] bpf: Make non-preallocated allocation low priority Message-ID: References: <20220706155848.4939-1-laoar.shao@gmail.com> <20220706155848.4939-2-laoar.shao@gmail.com> <20220707000721.dtl356trspb23ctp@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220707000721.dtl356trspb23ctp@google.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657153515; a=rsa-sha256; cv=none; b=jUtl+o+KoXdBn9pKMlloFjnVZN0qjGET1F6/KluMiNMD3SMgfii7WoVEbjJtzEWJ6oOeMR BT4V/+E3bDa1GNuvzKxuj++H4Bjxl5ntg8NbFTtSrDrVBh9rDIkPP9PJAfUQg3Kn6E5tLt 1JnWlNX3Rt3n8qmVBYHIKu5MFedSFp0= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=kf9hrgc2; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf20.hostedemail.com: domain of roman.gushchin@linux.dev designates 94.23.1.103 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657153515; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0LdaR9FiBec9jtN92ZDWfwHZkl0FiXnWOtbvsNwfneg=; b=ymHjlF3LJmw6+yVD8iHPXWv/kQfIGDiE7pKGt4z/S8NDybu6+S1gptw2koYcbW4Vdh5zev 3R36VbISm7u/MwotWr3K1sR0n7xdVWfivaDpGQ2rBdNERLLJvQvS7ivh2rnVQaSmp3KmAY Vo1Eg8dlE/F0UtxwfZDzNOhlCvoY+Ig= Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=kf9hrgc2; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf20.hostedemail.com: domain of roman.gushchin@linux.dev designates 94.23.1.103 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev X-Stat-Signature: qbop7qgg53wcu6q1rw3qnkxkc9pi4xsg X-Rspamd-Queue-Id: 4051C1C0009 X-Rspamd-Server: rspam05 X-Rspam-User: X-HE-Tag: 1657153514-143059 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jul 07, 2022 at 12:07:21AM +0000, Shakeel Butt wrote: > On Wed, Jul 06, 2022 at 03:58:47PM +0000, Yafang Shao wrote: > > GFP_ATOMIC doesn't cooperate well with memcg pressure so far, especially > > if we allocate too much GFP_ATOMIC memory. For example, when we set the > > memcg limit to limit a non-preallocated bpf memory, the GFP_ATOMIC can > > easily break the memcg limit by force charge. So it is very dangerous to > > use GFP_ATOMIC in non-preallocated case. One way to make it safe is to > > remove __GFP_HIGH from GFP_ATOMIC, IOW, use (__GFP_ATOMIC | > > __GFP_KSWAPD_RECLAIM) instead, then it will be limited if we allocate > > too much memory. > > Please use GFP_NOWAIT instead of (__GFP_ATOMIC | __GFP_KSWAPD_RECLAIM). > There is already a plan to completely remove __GFP_ATOMIC and mm-tree > already have a patch for that. Oh, I didn't know this, thanks for heads up! I agree that GFP_NOWAIT is the best choice then. Btw, we probably shouldn't even add GFP_NOWAIT if the allocation is performed from the bpf syscall context. Why would we fail to pre-allocate a map if we can easily go into the reclaim? But probably better to leave it for a separate change. Thanks!