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 73DC9C48BF6 for ; Mon, 26 Feb 2024 08:43:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 02B2A6B017F; Mon, 26 Feb 2024 03:43:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F1CD46B0180; Mon, 26 Feb 2024 03:43:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D96396B0181; Mon, 26 Feb 2024 03:43:40 -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 CA2A06B017F for ; Mon, 26 Feb 2024 03:43:40 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 98D9A1C07C9 for ; Mon, 26 Feb 2024 08:43:40 +0000 (UTC) X-FDA: 81833316600.27.DFD631C Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf14.hostedemail.com (Postfix) with ESMTP id A1235100004 for ; Mon, 26 Feb 2024 08:43:37 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="p/94khlF"; dkim=pass header.d=suse.com header.s=susede1 header.b=bWNTJkTO; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf14.hostedemail.com: domain of mhocko@suse.com designates 195.135.223.131 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=1708937018; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lCro49qKFb96ctGGHx0sMJf91QqvH7dMQtCRbD9/a3Y=; b=ombPQVx0zdaKwQ3GuCedrnrxHEnmHBfo4NInasWhTEhSwC8/h6fLM37hp9a/+1n9YGXxM1 Oitqh9wlHkqvILWKQ17wS4qYKJOTfdvWEfEmWUj+4r/FoDbqNMyzFTV5KyC8v20yQxq7XP hujDFE0hSqWGuxU+b21CAILMktPbpss= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="p/94khlF"; dkim=pass header.d=suse.com header.s=susede1 header.b=bWNTJkTO; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf14.hostedemail.com: domain of mhocko@suse.com designates 195.135.223.131 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708937018; a=rsa-sha256; cv=none; b=WRa036TRHgZTEM0oYfWWrtAMYDFty9ohC452TdgHQaOuL2kJRpFPbLBtfc5FW1QwrGbVJu qElNeQnZD0lWcCs6lNs16/6hTXLHxG5Gazt7M4Chphpg04AoyJemp8Qh/+PdmJq3lowUE9 NbdB5abQjFk7Axr2RacXuKb8k/0ryic= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CE9701FB3D; Mon, 26 Feb 2024 08:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1708937016; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lCro49qKFb96ctGGHx0sMJf91QqvH7dMQtCRbD9/a3Y=; b=p/94khlFMrPoU8svplFmUmTUb8/+VJ9NtDtg9Nv120CoQt12J5AKgAaJQTDCzD0PAqYsEB HSKeuUyLUMu1GZlJFzHpWBylEGdjGuL86bvtkqgCFyzL67wal/MfNiUm/T+8UJlVNOdVrK oCjAlSjY33goDle8rpo+m5nb+3/eaOM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1708937015; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lCro49qKFb96ctGGHx0sMJf91QqvH7dMQtCRbD9/a3Y=; b=bWNTJkTOWTfd1NIXZT1FXBRV0jUN7QWza9A6QAZIcqK2h5L2BNdf8bB0+xmaeNtn8hoCwL 1V+XcMv+GpwcCaZK6344GJImjy2FF9jlfq8gss9FmXHoCvJAag20KAwvUhgP2wWF7xLVPU KxcxIBFHJGKtsaGI0YmDv6DNQL4mh54= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C250513A58; Mon, 26 Feb 2024 08:43:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Rdf/LjdP3GUJFQAAD6G6ig (envelope-from ); Mon, 26 Feb 2024 08:43:35 +0000 Date: Mon, 26 Feb 2024 09:43:35 +0100 From: Michal Hocko To: Suren Baghdasaryan Cc: Christophe JAILLET , akpm@linux-foundation.org, kent.overstreet@linux.dev, petr@tesarici.cz, keescook@chromium.org, pasha.tatashin@soleen.com, kernel-team@android.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 1/1] mm: enumerate all gfp flags Message-ID: References: <20240224015800.2569851-1-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: A1235100004 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: iyt3eqcgywkam8qn9i9xcdq6qso618cn X-HE-Tag: 1708937017-61748 X-HE-Meta: U2FsdGVkX1/pCAq8zJnBBNAtpw/t0TctFH0Onmw+VkfzX0nKB2hfIwA2FqxB7R05/yKCLrzsbJf7FaYbUe92FNRlc1pKxeIkNrXf0sBNblWmA0svYgiQsIzVS+XZ0RdZEw5aDuu3OspHe1Y8frzzy+Ea36t55h/SqEKRaf8GkZaYM3cnAR7ihm7oD1BYuEtyGvOtDPngJqKIhiVXDFfj6/ojroiJacqkBr/hKM5njZxjO7aS3Goa5cvoNsSuSk87s8kYoEHWQ1PWeuLg7y4FhjfbSpewkzsJFSTp+Zh1T4azUTAqwkG14nT7mN9EjMdwci8kuf6cjoFRExgBg8u/pmkCZgVfpOTA8RZmjhPtfWk4RUYBuZ/1743bIBxBZesTaCi1zxa1vQF57owymnbVcKHMbw412yTVdF0k/+LkhG28JW/B0jicVVQG+yuvz+3Ql87SAb3p25JzrnhAtVcHZZffUiP2glGviS+wR1/cKSsDiQUp4Np491jEo7Kn4SsNmf1o4gddSsUnOuMyRc/nHgQc4tRIsLATsmH79fjSN4fpxn2o8Be0CgEf2YEz3HNlH6Kg8eBdEbWLryQwl5x5uRJ+O8Ddz5qIEPQRDwirwfRs6537PA4OMYjYHib1uLPY+ne2Ml41B/BLmxk55HR2J8kAoWv5mZ8dOB5rfMTGBwKhGtVLkeiNibtEsrEWwq4uvin2u6R4/6XcmgS7cnZa7IPI9W8i1frUkjqpKCahXZIpwS14KLAAEnjNST1IGhSJsbZxBLRGhWtUrCNnzWNaNimtdC2vAhGxaefJdPPMj9dPDow3BUHGIjsdGekoFp4Gn4vxGWwumqHLusrJPAJWvYLY50EiYyeryAUAxfYBTeh1kuffe6S5I1SSBaClKzZy5oKffHuoq10= 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 Sun 25-02-24 01:12:46, Suren Baghdasaryan wrote: > On Sat, Feb 24, 2024 at 7:03 AM Christophe JAILLET > wrote: > > > > Le 24/02/2024 à 02:58, Suren Baghdasaryan a écrit : > > > Introduce GFP bits enumeration to let compiler track the number of used > > > bits (which depends on the config options) instead of hardcoding them. > > > That simplifies __GFP_BITS_SHIFT calculation. > > > > > > Suggested-by: Petr Tesařík > > > Signed-off-by: Suren Baghdasaryan > > > Reviewed-by: Kees Cook > > > Reviewed-by: Pasha Tatashin > > > Acked-by: Michal Hocko > > > --- > > > Changes from v4 [1]: > > > - Split from the series [2] as a stand-alone patch, per Michal Hocko > > > - Added Reviewed-by, per Pasha Tatashin > > > - Added Acked-by, per Michal Hocko > > > > > > [1] https://lore.kernel.org/all/20240221194052.927623-7-surenb@google.com/ > > > [2] https://lore.kernel.org/all/20240221194052.927623-1-surenb@google.com/ > > > > > > include/linux/gfp_types.h | 90 +++++++++++++++++++++++++++------------ > > > 1 file changed, 62 insertions(+), 28 deletions(-) > > > > > > diff --git a/include/linux/gfp_types.h b/include/linux/gfp_types.h > > > index 1b6053da8754..868c8fb1bbc1 100644 > > > --- a/include/linux/gfp_types.h > > > +++ b/include/linux/gfp_types.h > > > @@ -21,44 +21,78 @@ typedef unsigned int __bitwise gfp_t; > > > * include/trace/events/mmflags.h and tools/perf/builtin-kmem.c > > > */ > > > > > > +enum { > > > + ___GFP_DMA_BIT, > > > + ___GFP_HIGHMEM_BIT, > > > + ___GFP_DMA32_BIT, > > > + ___GFP_MOVABLE_BIT, > > > + ___GFP_RECLAIMABLE_BIT, > > > + ___GFP_HIGH_BIT, > > > + ___GFP_IO_BIT, > > > + ___GFP_FS_BIT, > > > + ___GFP_ZERO_BIT, > > > + ___GFP_UNUSED_BIT, /* 0x200u unused */ > > > > Hi, > > > > what is the need to have this ___GFP_UNUSED_BIT now? > > Hi! > We can remove it but then all values will shift. That should be safe > to do now but I prefer one patch to do only one thing. We can add a > separate patch to do further cleanup of unused values. Agreed! > > > + ___GFP_DIRECT_RECLAIM_BIT, > > > + ___GFP_KSWAPD_RECLAIM_BIT, > > > + ___GFP_WRITE_BIT, > > > + ___GFP_NOWARN_BIT, > > > + ___GFP_RETRY_MAYFAIL_BIT, > > > + ___GFP_NOFAIL_BIT, > > > + ___GFP_NORETRY_BIT, > > > + ___GFP_MEMALLOC_BIT, > > > + ___GFP_COMP_BIT, > > > + ___GFP_NOMEMALLOC_BIT, > > > + ___GFP_HARDWALL_BIT, > > > + ___GFP_THISNODE_BIT, > > > + ___GFP_ACCOUNT_BIT, > > > + ___GFP_ZEROTAGS_BIT, > > > +#ifdef CONFIG_KASAN_HW_TAGS > > > + ___GFP_SKIP_ZERO_BIT, > > > + ___GFP_SKIP_KASAN_BIT, > > > +#endif > > > +#ifdef CONFIG_LOCKDEP > > > + ___GFP_NOLOCKDEP_BIT, > > > +#endif > > > + ___GFP_LAST_BIT > > > +}; > > > > Does it make sense to have something like: > > BUILD_BUG_ON(___GFP_LAST_BIT > BITS_PER_LONG, "blah"); > > I suppose that would not hurt, except gfp_t is unsigned int, not long. > Something like this would work I think: > > BUILD_BUG_ON_MSG(___GFP_LAST_BIT > BITS_PER_TYPE(gfp_t), "GFP bit overflow"); > > except I'm not sure where to put this check. One of the __init > functions in page_alloc.c would probably work but none seem to be > appropriate. mm_core_init() perhaps? Other ideas? Would that check add much? We currently cannot use the full width of the gfp_t because radix tree code needs to fit also its own tag into the same word (see radix_tree_init). If the radix tree constrain is lifted then we should add something like the above. -- Michal Hocko SUSE Labs