From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B2A01A8409 for ; Tue, 21 Jan 2025 10:46:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737456391; cv=none; b=dTrycPPOl6sFmYfRhy8PTSef7gL/4QPGGMxOsKp5Jg+clBraiCIUZS8Sym1+TG5F8Tb1NmryqzoSQBusHQJdXPdOUZuahK3kH2NWDDa3IeKZ1ZFZnnhXcQ9y7Exg96NJ/VZhWtFG5OsOzHcGoYjfcJ+J2oU0CXqAdwp7SLwFWoI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737456391; c=relaxed/simple; bh=F3+oexYqLchQRQteF/UcXq40oKPPgukRPRZibgTtabs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=gTASktoYRy4rxjFbg8EqQACEJ1F4JqjNEuZWqfv455hWfWpbbmKnCxS54knuJwvCNB0ASbeH0NSxSHJl/hsf5a2LGc9v+MCoqorGzdmSghJhDzRmhjpHhK7qspt8XZKoaauFABK7Qs6hyoH28FMtjw2rNl0+G/NsFX7Wh/yD1jE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0144F106F; Tue, 21 Jan 2025 02:46:57 -0800 (PST) Received: from [10.57.80.144] (unknown [10.57.80.144]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 508F13F740; Tue, 21 Jan 2025 02:46:24 -0800 (PST) Message-ID: <8ee3efbd-e24d-4e7b-ab3b-6b0efd62296b@arm.com> Date: Tue, 21 Jan 2025 11:46:20 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm/slab: simplify SLAB_* flag handling To: "Christoph Lameter (Ampere)" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com> References: <20250117113226.3484784-1-kevin.brodsky@arm.com> <0fa27da8-d523-77f7-0473-bb317ec9d83e@gentwo.org> Content-Language: en-GB From: Kevin Brodsky In-Reply-To: <0fa27da8-d523-77f7-0473-bb317ec9d83e@gentwo.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 17/01/2025 23:13, Christoph Lameter (Ampere) wrote: > On Fri, 17 Jan 2025, Kevin Brodsky wrote: > >> index a29457bef626..3b07cdaac3ae 100644 >> --- a/mm/slab_common.c >> +++ b/mm/slab_common.c >> @@ -305,18 +305,6 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, >> goto out_unlock; >> } >> >> - /* Refuse requests with allocator specific flags */ >> - if (flags & ~SLAB_FLAGS_PERMITTED) { >> - err = -EINVAL; >> - goto out_unlock; >> - } > I think we should keep checking for invalid flags. The commit that introduced this check [1] aimed to ensure that no allocator-specific flag is passed to kmem_cache_create(), so it seemed to me it was no longer needed now that allocator-specific flags are gone. Having said that, we could keep it in order to reject flags that are not supposed to be passed to kmem_cache_create() (e.g. SLAB_SKIP_KFENCE). With that approach we'd just need to clear SLAB_DEBUG_FLAGS below if !CONFIG_SLUB_DEBUG (and get rid of CACHE_CREATE_MASK). - Kevin [1] https://lore.kernel.org/all/1478553075-120242-2-git-send-email-thgarnie@google.com/ >> - /* >> - * Some allocators will constraint the set of valid flags to a subset >> - * of all flags. We expect them to define CACHE_CREATE_MASK in this >> - * case, and we'll just provide them with a sanitized version of the >> - * passed flags. >> - */ >> flags &= CACHE_CREATE_MASK; > This would silently clear some flags instead of creating an error.