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 0D286C43334 for ; Thu, 7 Jul 2022 03:36:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9788E6B0072; Wed, 6 Jul 2022 23:36:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 927036B0073; Wed, 6 Jul 2022 23:36:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EF9D6B0074; Wed, 6 Jul 2022 23:36:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6C0AF6B0072 for ; Wed, 6 Jul 2022 23:36:43 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 27713207A2 for ; Thu, 7 Jul 2022 03:36:43 +0000 (UTC) X-FDA: 79658891886.08.E370CE4 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf28.hostedemail.com (Postfix) with ESMTP id 82C49C0003 for ; Thu, 7 Jul 2022 03:36:42 +0000 (UTC) Date: Wed, 6 Jul 2022 20:36:33 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1657165000; 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=SAH+dRNUS66esNj71rVITjpSSCB+jDrJZseh+3rbbIc=; b=SDvNoR6LfSBUiENEh8s2LC6V5ULxeEs4xRgZXsjw5qQUbkZWd22r8rTY9agJgEU1IBpPpR nwCGBUVicQFDzihuz+RodbAuJLi1RUedVJHFCb4ERNlf1hIaoygsEC5O7Rlg9suh5gLRYr i1QqdJt9SrOtYa5OgFSRIII5URmbTGc= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Alexei Starovoitov Cc: Shakeel Butt , Yafang Shao , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Quentin Monnet , Hao Luo , bpf , linux-mm 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: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657165002; 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=SAH+dRNUS66esNj71rVITjpSSCB+jDrJZseh+3rbbIc=; b=6a8EZVinAWjcUNI86OqsSaNxiLWCPHXv1kSMrCYSuCL4BnNNvTWsl0ddRfGCtXYzg4sz6o yEcJH1p1IsTyMK5g2Px7Ej9asAp2lnWqJU98wrBbg0SNO9PZ9dvFUAsx4g7isPkXUnXI7e OZAqD/CpiYZ2bA0QlW23DtNa/LZLGLc= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=SDvNoR6L; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf28.hostedemail.com: domain of roman.gushchin@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657165002; a=rsa-sha256; cv=none; b=IxFkRN34whmD0jAVl/0rGCn9uWi6PHWbEuyMYosm3bpSpq2kLt+CSrSQsEbBuhe/xl1swJ 6BSxbaRICkXHygXG8cNBw7aBg9fEDQ07ppUNOJ7+rUctfpiuSQILyUP2lixuPOGhcdXCKX AjMSj7OwpQhHDtsprphqyg/DErladkE= X-Rspamd-Server: rspam11 X-Rspam-User: X-Stat-Signature: fgm7j31hnzdmo6t5knj6oieksyh1j9zf X-Rspamd-Queue-Id: 82C49C0003 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=SDvNoR6L; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf28.hostedemail.com: domain of roman.gushchin@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev X-HE-Tag: 1657165002-266254 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 Wed, Jul 06, 2022 at 07:09:22PM -0700, Alexei Starovoitov wrote: > On Wed, Jul 6, 2022 at 5:25 PM Roman Gushchin wrote: > > > > 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. > > The places affected by this patch are in atomic context. > Prealloc path from syscall is using GFP_USER. Right. Sorry, my bad, for some reason I was under an impression it's a common path for all allocations. Thanks!