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 F2C72E7717D for ; Wed, 11 Dec 2024 10:09:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DDD18D0016; Wed, 11 Dec 2024 05:09:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 68DB28D0013; Wed, 11 Dec 2024 05:09:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 507718D0016; Wed, 11 Dec 2024 05:09:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2DE9A8D0013 for ; Wed, 11 Dec 2024 05:09:03 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9EED0120A03 for ; Wed, 11 Dec 2024 10:09:02 +0000 (UTC) X-FDA: 82882254210.30.635B778 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by imf02.hostedemail.com (Postfix) with ESMTP id D090B80014 for ; Wed, 11 Dec 2024 10:08:16 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=cBCR55mR; spf=pass (imf02.hostedemail.com: domain of mhocko@suse.com designates 209.85.221.54 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733911729; 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=HQTIkbXiSjL4ZTjxx7KFR/cd8ulUeA/BaZmO4ST/YMs=; b=6GVaqU43RxarrsgkaEZV2iMOlYV09cSoKF7qdrsQAGatO8/6hmtOm/BOuvU536lk28nMZb I60p8Or8m3jHM1LeMDWVP2kYPppv+Cvm8uixqZEEmQpgPQ1Koisfaw7Ql0VQlbzwPjBCda fZtr7Y3Q7Ih+1iaTrnKB69nkZukJiNU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733911729; a=rsa-sha256; cv=none; b=LaNIsvdC6+MIzuZeW03NmmUhR+xR3Tp+o1Rk74Kjq/fowFTINiUiKoHCiruH8pYqutaT+P T+PDsNjEyxL3KY5182vHKmsX6LfI/is7Y31mAVvLm7w/TQxo8/Ab4YtV7U+o5isKALqoeH C1AobQu39hA75xxfKtkw3LbgSWk3xro= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=cBCR55mR; spf=pass (imf02.hostedemail.com: domain of mhocko@suse.com designates 209.85.221.54 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3862d16b4f5so286226f8f.0 for ; Wed, 11 Dec 2024 02:09:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1733911739; x=1734516539; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=HQTIkbXiSjL4ZTjxx7KFR/cd8ulUeA/BaZmO4ST/YMs=; b=cBCR55mReFGeRklOKs947v8FQAtdU/Ro7QcnVEke0ejopslYyl5cg0pd02RzOBAHVv ba7K3tFNe1SSPXTvJXyvMPu6fhJel82yNGEED2YS9AHPD0K1BjFLS9LEM0mQYSpje18g n8KY1LAK+BIyRtI0xo269RmwJu29YOvynOKF3VPWd639yxBz11GS4I0dFfW6CIDhEwir 5P9DMr6O6wDfKtuexPAWCNEcNxrlJmN+ytnpYLvhaQrRQvWKwuq0WmsmO5yr8UXeRndG G+grNfcfkwlBDIbQjcBSxXIQtqyPJypW0TuyOZ2S4EKmWcraZeEYZga3ACEeBiuyTs/D +g+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733911739; x=1734516539; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HQTIkbXiSjL4ZTjxx7KFR/cd8ulUeA/BaZmO4ST/YMs=; b=o1SJVwWyIk5q9Fvs+Xx5r9KWhIbTcyWmFVE+bvVyBc+bXsv2pSbzSvLJcxBHA4CaU4 /mnSinx6izH6NGB9GvA/nc7wqnGoUvUe+E1o/wNTdKGkqtWYpve5nE21HNN0TQN9XNng S3S9LG1w1NAHWKdSIQrXztM8ocTiDgjBlPusOtr1fhluynEgdRN1rQhKE9/wtAp+8b7m Dn9CMxsSGe33mT+diAHI0vtCgHna79HGXuZxxxtaqjUV1JUVw1MSQ9+O3/Y7qNXadfW0 ulY4IYGh06bRHux+CqPmyyDIb3ZL+RExdVjit2UvVE+7626adejf5TGNoWvLzWRkQF3m PtGQ== X-Forwarded-Encrypted: i=1; AJvYcCUN0xhZF7vJAg0wd08Qw6kybAT+uDpZS/0MuRmRbWqfe7BT4XmRzPJzCY/RA3h1UohKh6XFQBNppw==@kvack.org X-Gm-Message-State: AOJu0Yx4YHS5F6pgIgAJWMME0F5tAFK/ovhdZrUekIeD5hZTB5QLHfVs e8gKvlHhoxd1lRXy4RnwG23ShV86Po0mZgJbt35z5sMUpCPK2B+QncRgPtfluG0= X-Gm-Gg: ASbGncsKEJQyEjOZSC2T/SZTznPnUeYN/v7VRY6C5hiK7SsQQtVXRP7vGxYpHO05gTm p62NVPGZw0SDMB/+3NAU7IQUtBoW/BIRuczxSIFvlJtNhfyLbPsfEnrxTWpe+1VUcYkX5/e4T6A IW+TTNEOFFkcTwn6SfdK2/EUfcKgkJbRgH1N8Idoq0UJA6mpfWtHBPvO21kwmqAXGrS5pwdz18N Kd9/lalFKY8U87NtX/tHqkYHg9jBB5VlhvMtatWvHYA7fho8cmm0r2HSzbhBpDCAv4= X-Google-Smtp-Source: AGHT+IHj9KuyCI3jM8C2B2pywNKTz2+PID1sNOAsuKjh17FO/LgGrHovdODyf4DWcBc8jd7QHwU0kg== X-Received: by 2002:a5d:64c3:0:b0:386:42b1:d7e4 with SMTP id ffacd0b85a97d-3864dedffa5mr1404642f8f.19.1733911738817; Wed, 11 Dec 2024 02:08:58 -0800 (PST) Received: from localhost (109-81-86-131.rct.o2.cz. [109.81.86.131]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-387824a4f4dsm914438f8f.31.2024.12.11.02.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 02:08:58 -0800 (PST) Date: Wed, 11 Dec 2024 11:08:57 +0100 From: Michal Hocko To: Shakeel Butt Cc: Alexei Starovoitov , Matthew Wilcox , bpf@vger.kernel.org, andrii@kernel.org, memxor@gmail.com, akpm@linux-foundation.org, peterz@infradead.org, vbabka@suse.cz, bigeasy@linutronix.de, rostedt@goodmis.org, houtao1@huawei.com, hannes@cmpxchg.org, tglx@linutronix.de, tj@kernel.org, linux-mm@kvack.org, kernel-team@fb.com Subject: Re: [PATCH bpf-next v2 1/6] mm, bpf: Introduce __GFP_TRYLOCK for opportunistic page allocation Message-ID: References: <20241210023936.46871-1-alexei.starovoitov@gmail.com> <20241210023936.46871-2-alexei.starovoitov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: D090B80014 X-Stat-Signature: 4xxa8w6b1rhnzxdfoaeora67hmadkxzd X-Rspam-User: X-HE-Tag: 1733911696-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YSBbUy8CIMMWhjNoepLCFnQEoA4QtGGzZCWNfvarxX+0cNKLfXgn/AbnVRlP6mwDVOgRGNpIBjWE1YTL9R0H7lcu/zorwXd+d/WInd95XI6nVh/On6i0oOzmVHJJnDYj5bqU6W7WPTlTyZK80VT/2t/L/D+smX3K05kaHQEoZcONSPINX5d8WT8BM6o+yV0HYIk+Ul1ccb6mvg9NEri/lTykd5ghxgan7RnA6YOEa4I2h9W3gVy26kXQ3jOMhpCeQSBSC7mM0v/as6iI7oB8CGcl0Y+oW96Inzk/Hbmxmv/rQXOPvZM3rv+Ftbhyy3k79uMME1OjL4eIk2Y82KT9U1QVoD7XNdmJlPuIcC4IxaPLfA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000106, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue 10-12-24 12:25:04, Shakeel Butt wrote: > On Tue, Dec 10, 2024 at 10:05:22AM +0100, Michal Hocko wrote: > > On Tue 10-12-24 05:31:30, Matthew Wilcox wrote: > > > On Mon, Dec 09, 2024 at 06:39:31PM -0800, Alexei Starovoitov wrote: > > > > + if (preemptible() && !rcu_preempt_depth()) > > > > + return alloc_pages_node_noprof(nid, > > > > + GFP_NOWAIT | __GFP_ZERO, > > > > + order); > > > > + return alloc_pages_node_noprof(nid, > > > > + __GFP_TRYLOCK | __GFP_NOWARN | __GFP_ZERO, > > > > + order); > > > > > > [...] > > > > > > > @@ -4009,7 +4018,7 @@ gfp_to_alloc_flags(gfp_t gfp_mask, unsigned int order) > > > > * set both ALLOC_NON_BLOCK and ALLOC_MIN_RESERVE(__GFP_HIGH). > > > > */ > > > > alloc_flags |= (__force int) > > > > - (gfp_mask & (__GFP_HIGH | __GFP_KSWAPD_RECLAIM)); > > > > + (gfp_mask & (__GFP_HIGH | __GFP_KSWAPD_RECLAIM | __GFP_TRYLOCK)); > > > > > > It's not quite clear to me that we need __GFP_TRYLOCK to implement this. > > > I was originally wondering if this wasn't a memalloc_nolock_save() / > > > memalloc_nolock_restore() situation (akin to memalloc_nofs_save/restore), > > > but I wonder if we can simply do: > > > > > > if (!preemptible() || rcu_preempt_depth()) > > > alloc_flags |= ALLOC_TRYLOCK; > > > > preemptible is unusable without CONFIG_PREEMPT_COUNT but I do agree that > > __GFP_TRYLOCK is not really a preferred way to go forward. For 3 > > reasons. > > > > First I do not really like the name as it tells what it does rather than > > how it should be used. This is a general pattern of many gfp flags > > unfotrunatelly and historically it has turned out error prone. If a gfp > > flag is really needed then something like __GFP_ANY_CONTEXT should be > > used. If the current implementation requires to use try_lock for > > zone->lock or other changes is not an implementation detail but the user > > should have a clear understanding that allocation is allowed from any > > context (NMI, IRQ or otherwise atomic contexts). > > > > Is there any reason why GFP_ATOMIC cannot be extended to support new > > GFP_ATOMIC has access to memory reserves. I see GFP_NOWAIT a better fit > and if someone wants access to the reserve they can use __GFP_HIGH with > GFP_NOWAIT. Right. The problem with GFP_NOWAIT is that it is very often used as an opportunistic allocation attempt before a more costly fallback. Failing those just because of the zone lock (or other internal locks) contention seems too aggressive. > > Third, do we even want such a strong guarantee in the generic page > > allocator path and make it even more complex and harder to maintain? > > I think the alternative would be higher maintenance cost i.e. everyone > creating their own layer/solution/caching over page allocator which I > think we agree we want to avoid (Vlastimil's LSFMM talk). Yes, I do agree that we do not want to grow special case allocators. I was merely interested in an option to reuse existing bulk allocator for this new purpose. -- Michal Hocko SUSE Labs