[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <62c19f0d-4dfe-4bc8-99b6-c84583747093@redhat.com>
Date: Wed, 5 Jun 2024 10:33:02 +0200
From: David Hildenbrand <david@...hat.com>
To: ran xiaokai <ranxiaokai627@....com>
Cc: akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, mhocko@...nel.org, ran.xiaokai@....com.cn,
v-songbaohua@...o.com, xu.xin16@....com.cn, yang.yang29@....com.cn,
ziy@...dia.com
Subject: Re: [PATCH linux-next] mm: huge_memory: fix misused
mapping_large_folio_support() for anon folios
On 05.06.24 10:30, ran xiaokai wrote:
>> On 05.06.24 04:20, ran xiaokai wrote:
>>>> On 04.06.24 07:47, xu.xin16@....com.cn wrote:
>>>>> From: Ran Xiaokai <ran.xiaokai@....com.cn>
>>>>>
>>>>> When I did a large folios split test, a WARNING
>>>>> "[ 5059.122759][ T166] Cannot split file folio to non-0 order"
>>>>> was triggered. But my test cases are only for anonmous folios.
>>>>> while mapping_large_folio_support() is only reasonable for page
>>>>> cache folios.
>>>>
>>>> Agreed.
>>>>
>>>> I wonder if mapping_large_folio_support() should either
>>>>
>>>> a) Complain if used for anon folios, so we can detect the wrong use more
>>>> easily. (VM_WARN_ON_ONCE())
>>>
>>>> b) Return "true" for anonymous mappings, although that's more debatable.
>>>>
>>>
>>> Hi, David,
>>> Thanks for the review.
>>> I think a) is better.
>>> But we have to add a new parameter "folio" to mapping_large_folio_support(), right ?
>>> something like mapping_large_folio_support(struct address_space *mapping, struct folio *folio) ?
>>> But in the __filemap_get_folio() path,
>>>
>>> __filemap_get_folio()
>>> no_page:
>>> ....
>>> if (!mapping_large_folio_support(mapping))
>>>
>>> the folio is not allocated yet, yes ?
>>> Or do you mean there is some other way to do this ?
>>
>> If we really pass unmodified folio->mapping, you can do what
>> folio_test_anon() would and make sure PAGE_MAPPING_ANON is not set.
>
> I think I just misunderstood your suggestion.
Likely my use of "folio" was confusing.
> How about this ?
>
> static inline bool mapping_large_folio_support(struct address_space *mapping)
> {
> VM_WARN_ONCE((unsigned long)mapping & PAGE_MAPPING_ANON,
> "Anonymous mapping always supports large folio");
>
> return IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) &&
> test_bit(AS_LARGE_FOLIO_SUPPORT, &mapping->flags);
> }
Yes, and we should likely document that this is not supposed to be used
with mappings from anonymous folios.
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists