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 A776AC4332F for ; Wed, 8 Nov 2023 10:33:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C12D8D00B7; Wed, 8 Nov 2023 05:33:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 24B158D00AD; Wed, 8 Nov 2023 05:33:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EB708D00B7; Wed, 8 Nov 2023 05:33:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id EEE3B8D00AD for ; Wed, 8 Nov 2023 05:33:10 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B9985140C3F for ; Wed, 8 Nov 2023 10:33:10 +0000 (UTC) X-FDA: 81434424540.10.6AEC941 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf18.hostedemail.com (Postfix) with ESMTP id 95CB81C0014 for ; Wed, 8 Nov 2023 10:33:08 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="VRI/frVL"; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf18.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699439589; a=rsa-sha256; cv=none; b=C5+miLTGKQ1poQ2auhT965n609CPaYTp+Ux+VTk+YrlXIya/hd5FPBBrHZGP/ApG+fjzRP 6F3wzcQH+Hptde6HRko2ze1gkIQyNUo02UEMTndPvM5hTirw2FIzX2k1ahW3W9Gap2lnYo 5f0HkijQhH/gl818Li4y0wqCIm8/i1Q= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="VRI/frVL"; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf18.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699439589; 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=hFiAcviVraABnczS1H4QUx4zyBJCX/dllj1tUj43EaM=; b=u/S/F0Zc+KdpjRED6AuXmju5BC0V+23F1InIUmks24UqGwCCPmEv2SUcr1hF4H00Wyhd9r SX9nPzXeXWMdamxZcw/W/Mc4l/WgOvoOF2Cn26StXqFW79bdOvwKS0OITO34jCuPiwHSEH 6V0pc+Ho9TFILbS76SHBlZ2WEi6JOXU= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C0E6E21961; Wed, 8 Nov 2023 10:33:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1699439586; h=from:from:reply-to: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=hFiAcviVraABnczS1H4QUx4zyBJCX/dllj1tUj43EaM=; b=VRI/frVL4f+SKT0AVB4Pn17hcROGjrr/+ZShJ4WUA8vYk+1aL4Go82MAd5xxulXjT78kpc wDSp9gSAx3i0wbkx++PiITKFVHxyDBnUvYd41V0yb3s4f/XXA6Cj466rwFi3Ocnjgyulyx KyOTknSnpLJyF6AQg/ENNFFXJREMBPI= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 999A4133F5; Wed, 8 Nov 2023 10:33:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id jLZxIuJjS2UecQAAMHmgww (envelope-from ); Wed, 08 Nov 2023 10:33:06 +0000 Date: Wed, 8 Nov 2023 11:33:05 +0100 From: Michal Hocko To: Roman Gushchin Cc: Christoph Lameter , Matthew Wilcox , linux-mm@kvack.org, cgroups@vger.kernel.org, Shakeel Butt Subject: Re: cgroups: warning for metadata allocation with GFP_NOFAIL (was Re: folio_alloc_buffers() doing allocations > order 1 with GFP_NOFAIL) Message-ID: References: <6b42243e-f197-600a-5d22-56bd728a5ad8@gentwo.org> <8f6d3d89-3632-01a8-80b8-6a788a4ba7a8@linux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 95CB81C0014 X-Stat-Signature: 55z3c18sa3zncnb7wokjnacwf58xayre X-HE-Tag: 1699439588-645707 X-HE-Meta: U2FsdGVkX1+SSsM+f36pn+o+bkgVw2DwitdzW4JoP9bxbODQdqPFuh/LhYdfTkVO/nOlgP8Di6Zf65ODvruOw8rSgvI/H3cygp/UhyZcFY6ef5YPdLZtWeFLf1nSmp29o0tEGnqpXgbK6xwB+/bm5GGKnBSf/F2c9Q4FR+PTonSMmvuZWYfWhNrRSAWCOoKySBgHziTNJJ6uLqnGwkoTg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N2c4o1/CXoDhROJxp5AmvxY 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: List-Subscribe: List-Unsubscribe: On Tue 07-11-23 10:05:24, Roman Gushchin wrote: > On Mon, Nov 06, 2023 at 06:57:05PM -0800, Christoph Lameter wrote: > > Right.. Well lets add the cgoup folks to this. > > Hello! > > I think it's the best thing we can do now. Thoughts? > > >From 5ed3e88f4f052b6ce8dbec0545dfc80eb7534a1a Mon Sep 17 00:00:00 2001 > From: Roman Gushchin > Date: Tue, 7 Nov 2023 09:18:02 -0800 > Subject: [PATCH] mm: kmem: drop __GFP_NOFAIL when allocating objcg vectors > > Objcg vectors attached to slab pages to store slab object ownership > information are allocated using gfp flags for the original slab > allocation. Depending on slab page order and the size of slab objects, > objcg vector can take several pages. > > If the original allocation was done with the __GFP_NOFAIL flag, it > triggered a warning in the page allocation code. Indeed, order > 1 > pages should not been allocated with the __GFP_NOFAIL flag. > > Fix this by simple dropping the __GFP_NOFAIL flag when allocating > the objcg vector. It effectively allows to skip the accounting of a > single slab object under a heavy memory pressure. It would be really good to describe what happens if the memcg metadata allocation fails. AFAICS both callers of memcg_alloc_slab_cgroups - memcg_slab_post_alloc_hook and account_slab will simply skip the accounting which is rather curious but probably tolerable (does this allow to runaway from memcg limits). If that is intended then it should be documented so that new users do not get it wrong. We do not want to error ever propagate down to the allocator caller which doesn't expect it. Btw. if the large allocation is really necessary, which hasn't been explained so far AFAIK, would vmalloc fallback be an option? > An alternative would be to implement the mechanism to fallback to > order-0 allocations for accounting metadata, which is also not perfect > because it will increase performance penalty and memory footprint > of the kernel memory accounting under memory pressure. > > Reported-by: Christoph Lameter > Signed-off-by: Roman Gushchin > Cc: Matthew Wilcox > --- > mm/memcontrol.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 774bd6e21e27..1c1061df9cd1 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -2936,7 +2936,8 @@ void mem_cgroup_commit_charge(struct folio *folio, struct mem_cgroup *memcg) > * Moreover, it should not come from DMA buffer and is not readily > * reclaimable. So those GFP bits should be masked off. > */ > -#define OBJCGS_CLEAR_MASK (__GFP_DMA | __GFP_RECLAIMABLE | __GFP_ACCOUNT) > +#define OBJCGS_CLEAR_MASK (__GFP_DMA | __GFP_RECLAIMABLE | \ > + __GFP_ACCOUNT | __GFP_NOFAIL) > > /* > * mod_objcg_mlstate() may be called with irq enabled, so > -- > 2.42.0 -- Michal Hocko SUSE Labs