linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: ran xiaokai <ranxiaokai627@163.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, mhocko@kernel.org, ran.xiaokai@zte.com.cn,
	v-songbaohua@oppo.com, xu.xin16@zte.com.cn,
	yang.yang29@zte.com.cn, ziy@nvidia.com
Subject: Re: [PATCH linux-next] mm: huge_memory: fix misused mapping_large_folio_support() for anon folios
Date: Wed, 5 Jun 2024 10:33:02 +0200	[thread overview]
Message-ID: <62c19f0d-4dfe-4bc8-99b6-c84583747093@redhat.com> (raw)
In-Reply-To: <20240605083008.891170-1-ranxiaokai627@163.com>

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@zte.com.cn wrote:
>>>>> From: Ran Xiaokai <ran.xiaokai@zte.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



  reply	other threads:[~2024-06-05  8:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04  5:47 xu.xin16
2024-06-04  7:57 ` David Hildenbrand
2024-06-04 13:52   ` Zi Yan
2024-06-04 13:57     ` Zi Yan
2024-06-05  2:56     ` ran xiaokai
2024-06-05  2:20   ` ran xiaokai
2024-06-05  7:25     ` David Hildenbrand
2024-06-05  8:30       ` ran xiaokai
2024-06-05  8:33         ` David Hildenbrand [this message]
2024-06-05  9:06 ` Barry Song
     [not found]   ` <20240605095406.891512-1-ranxiaokai627@163.com>
2024-06-05 14:08     ` Zi Yan
     [not found]       ` <c110eb46-3c9d-40c3-ab16-5bd9f75b6501@redhat.com>
2024-06-06  1:34         ` Barry Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=62c19f0d-4dfe-4bc8-99b6-c84583747093@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=ran.xiaokai@zte.com.cn \
    --cc=ranxiaokai627@163.com \
    --cc=v-songbaohua@oppo.com \
    --cc=xu.xin16@zte.com.cn \
    --cc=yang.yang29@zte.com.cn \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox