Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2537148rdb; Wed, 21 Feb 2024 10:34:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWYeb6+UQ8RJKpAt9RTvuSz/Ev7MJDDCsSI3y9/kdPuER23+smvZiXsrPHtSgAItDi7xC8z2Hmj4foYO4tAduSH03bzbZqQmniNcumqjg== X-Google-Smtp-Source: AGHT+IFf3ekxXYY9DTeLTxGXgVQrZhv9kHaHQ3T2N8dvUcH2TzK+625pS8yOjRfJ4b6at7oHXlpg X-Received: by 2002:a17:90a:c24f:b0:299:63bd:c17d with SMTP id d15-20020a17090ac24f00b0029963bdc17dmr430981pjx.2.1708540461099; Wed, 21 Feb 2024 10:34:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708540461; cv=pass; d=google.com; s=arc-20160816; b=F0AnE/1GpbYuCfwXQ7w+xVHE9XbXJkk7azf9AOvQPw48Zu/WVezAG7MuURf0GPiit+ klmzUy8Y5Kp5gjcQumGcfhKOPVMwHsah6iqWVyHYWCSDgaXPK8MLNmAMEksedq4r+6nz MeFO9lp1r/252L/qN11++tRVGQoEyD9hYT5FiC7Kd73GOgHsghlQCCq4LKs5M+UevbuD DwcayqHDPp1uT/O4ilpUweWXbZwyATsB3iypiF8zKep5GkWeP4wo5qNh0Elc/0weZF4j 7zBZeV3OK01KesmEoJLkncM0vXlexlVbLYXf6+KcJ4Lrgzm9OkMlxFfCZqXQYPSdPSqQ 9bnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=5ZfYq+o4HUAg6zk4DYlNdaruLQWY+JIsadSfBudqmUQ=; fh=2TnW9QHUS0LKdBPmX+w6zVMGJLN5yZLyrD5C4PFNldw=; b=lR4Jc0jKS8qHm5p9OiAcFuu/Rlyq3IFz6PdaTWDvOw5rv6MHV/wOrMBYakdrRJN351 +3qI4kJsQbhBqY/mpd2MTYTpqidpeIhBVKZ575MZ8BHq9rqVCOFzVa3j4HzR8zBxHzW9 NCY6MWi904FtZ8dxryA0BoLwp8EBgbldkROKIB0yL4rYTy1r1je1vZol/btAOADVSNRd pHISY00Z65R/I5qxu4fmLX9MjU56z66C0AlZSDHq6o2YNC8X6E0MZTWh425cpqxm7G/9 d6vfdBSeL03HYnFU4fFwDj3hjpl9A6m/zcmWPiINyhPnObAYhnT+rNFrdILCMrpIAjqk yfpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Z+qxW5XT; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-75302-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75302-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id na13-20020a17090b4c0d00b0029a13031549si1792857pjb.8.2024.02.21.10.34.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 10:34:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75302-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Z+qxW5XT; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-75302-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75302-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C48E3284DAD for ; Wed, 21 Feb 2024 18:34:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E189285631; Wed, 21 Feb 2024 18:34:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Z+qxW5XT" Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C7141097B for ; Wed, 21 Feb 2024 18:34:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708540455; cv=none; b=cXpWTsSaen4Mb7PJAK63qPj8f+ilVP2i+HLUwRqKNkMl58+dv61bi0af+a91UgL9dUEXMl+ulLK6DaWKjBDKzC6jZSf5ZofolkYHxuGKY2KVGJWkvHUcYWnw76GWOcRxw+oH5u66a4ZdbLASA0O/vDqveeJf+CFLPDVbBUz7+sY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708540455; c=relaxed/simple; bh=LgjqrzXO+tkiNjtq7bVcYwIGi3coMgZGbOl9VQtJOO8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VpxKGVq3l9Tnke1J696BmJWkw8lAHvcJWaafyY4nvHtP0FGlCGp8yL9DjfoSDteAXPQjkrqEawDfRGl9G7ldbvUUwF3QbNUa3O+hu66Lk8OYat521ddIba3C8g79xgIhThfz0ospqZVCA7k88AK+6HF/x/21VIELsMCaBMGySNk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Z+qxW5XT; arc=none smtp.client-ip=91.218.175.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Wed, 21 Feb 2024 10:33:48 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708540450; 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=5ZfYq+o4HUAg6zk4DYlNdaruLQWY+JIsadSfBudqmUQ=; b=Z+qxW5XTS5ZBzmp50/Rw0CQto8fpUGAvw1L9hMrCBlgRWfmWCZL2QMyMRJBhhvUXyZrCZQ 7I1L3xEY0CBBjHvs/Nkvq6QoC4K4YDSewb5cbAQFUxNPOxqyAUBKyLOz9LQ0CPf5K9diqz sLS+cybCN1xIPho6etnzuEUulDq//M0= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Vlastimil Babka Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Zheng Yejian , Xiongwei Song , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com Subject: Re: [PATCH 2/3] mm, slab: use an enum to define SLAB_ cache creation flags Message-ID: References: <20240220-slab-cleanup-flags-v1-0-e657e373944a@suse.cz> <20240220-slab-cleanup-flags-v1-2-e657e373944a@suse.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240220-slab-cleanup-flags-v1-2-e657e373944a@suse.cz> X-Migadu-Flow: FLOW_OUT On Tue, Feb 20, 2024 at 05:58:26PM +0100, Vlastimil Babka wrote: > The values of SLAB_ cache creation flagsare defined by hand, which is > tedious and error-prone. Use an enum to assign the bit number and a > __SF_BIT() macro to #define the final flags. > > This renumbers the flag values, which is OK as they are only used > internally. > > Signed-off-by: Vlastimil Babka > --- > include/linux/slab.h | 81 ++++++++++++++++++++++++++++++++++++++-------------- > mm/slub.c | 6 ++-- > 2 files changed, 63 insertions(+), 24 deletions(-) > > diff --git a/include/linux/slab.h b/include/linux/slab.h > index 6252f44115c2..f893a132dd5a 100644 > --- a/include/linux/slab.h > +++ b/include/linux/slab.h > @@ -21,29 +21,68 @@ > #include > #include > > +enum _slab_flag_bits { > + _SLAB_CONSISTENCY_CHECKS, > + _SLAB_RED_ZONE, > + _SLAB_POISON, > + _SLAB_KMALLOC, > + _SLAB_HWCACHE_ALIGN, > + _SLAB_CACHE_DMA, > + _SLAB_CACHE_DMA32, > + _SLAB_STORE_USER, > + _SLAB_PANIC, > + _SLAB_TYPESAFE_BY_RCU, > + _SLAB_TRACE, > +#ifdef CONFIG_DEBUG_OBJECTS > + _SLAB_DEBUG_OBJECTS, > +#endif > + _SLAB_NOLEAKTRACE, > + _SLAB_NO_MERGE, > +#ifdef CONFIG_FAILSLAB > + _SLAB_FAILSLAB, > +#endif > +#ifdef CONFIG_MEMCG_KMEM > + _SLAB_ACCOUNT, > +#endif > +#ifdef CONFIG_KASAN_GENERIC > + _SLAB_KASAN, > +#endif > + _SLAB_NO_USER_FLAGS, > +#ifdef CONFIG_KFENCE > + _SLAB_SKIP_KFENCE, > +#endif > +#ifndef CONFIG_SLUB_TINY > + _SLAB_RECLAIM_ACCOUNT, > +#endif > + _SLAB_OBJECT_POISON, > + _SLAB_CMPXCHG_DOUBLE, > + _SLAB_FLAGS_LAST_BIT > +}; > + > +#define __SF_BIT(nr) ((slab_flags_t __force)(1U << (nr))) I'd rename it to (__)SLAB_FLAG_BIT(), as SF is a bit cryptic, but not a strong preference. Otherwise looks really good to me, nice cleanup. Reviewed-by: Roman Gushchin Thanks!