lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 12 Apr 2024 22:14:39 +0800
From: Haifeng Xu <haifeng.xu@...pee.com>
To: Matthew Wilcox <willy@...radead.org>, Vlastimil Babka <vbabka@...e.cz>
Cc: "Christoph Lameter (Ampere)" <cl@...ux.com>, penberg@...nel.org,
 rientjes@...gle.com, iamjoonsoo.kim@....com, akpm@...ux-foundation.org,
 roman.gushchin@...ux.dev, 42.hyeyoo@...il.com, linux-mm@...ck.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH] slub: Clear __GFP_COMP flag when allocating 0 order page



On 2024/4/12 20:17, Matthew Wilcox wrote:
> On Fri, Apr 12, 2024 at 10:01:29AM +0200, Vlastimil Babka wrote:
>> On 4/11/24 6:51 PM, Christoph Lameter (Ampere) wrote:
>>> On Thu, 11 Apr 2024, Haifeng Xu wrote:
>>>
>>>> @@ -1875,6 +1875,13 @@ static inline struct slab *alloc_slab_page(gfp_t flags, int node,
>>>> 	struct slab *slab;
>>>> 	unsigned int order = oo_order(oo);
>>>>
>>>> +	/*
>>>> +	 * If fallback to the minimum order allocation and the order is 0,
>>>> +	 * clear the __GFP_COMP flag.
>>>> +	 */
>>>> +	if (order == 0)
>>>> +		flags = flags & ~__GFP_COMP;
>>>
>>>
>>> This would be better placed in allocate_slab() when the need for a
>>> fallback to a lower order is detected after the first call to alloc_slab_page().
>>
>> Yeah. Although I don't really see the harm of __GFP_COMP with order-0 in the
>> first place, if the only issue is that the error output might be confusing.
>> I'd also hope we should eventually get rid of those odd non-__GFP_COMP
>> high-order allocations and then can remove the flag.
> 
> The patch seems pointless to me.  I wouldn't clear the flag.  If
> somebody finds it confusing, that's really just their expectations being
> wrong.  folio_alloc() sets __GFP_COMP on all allocations, whether or not
> they're order 0.

If we don't care about the warnings at all, then higher-order and lower-order allocations can set
__GFP_COMP when creating a new slab, just like folio_alloc(). If so, there is no need to check 
the order in calculate_sizes() and we can set __GFP_COMP in kmem_cache by default.

diff --git a/mm/slub.c b/mm/slub.c
index e7bf1a1a31a8..49a3ebefab86 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4461,9 +4461,7 @@ static int calculate_sizes(struct kmem_cache *s)
        if ((int)order < 0)
                return 0;

-       s->allocflags = 0;
-       if (order)
-               s->allocflags |= __GFP_COMP;
+       s->allocflags = __GFP_COMP;

        if (s->flags & SLAB_CACHE_DMA)
                s->allocflags |= GFP_DMA;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ