Re: [PATCH 2/6] mm: memory_hotplug: use more folio in do_migrate_range()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27 Mar 2024, at 10:54, Matthew Wilcox wrote:

> On Wed, Mar 27, 2024 at 10:45:42AM -0400, Zi Yan wrote:
>>>  	for (pfn = start_pfn; pfn < end_pfn; pfn++) {
>>> -		struct folio *folio;
>>> +		struct page *page, *head;
>>
>> You could get rid of head too. It is only used to calculate next pfn,
>> so pfn = folio_to_pfn(folio) + folio_nr_pages(folio) - 1 would work.
>>
>> And the PageHuge(page) and PageTransHuge(page) can be simplified, since
>> their pfn calculations are the same. Something like:
>>
>> if (folio_test_large(folio)) {
>> 	pfn = folio_to_pfn(folio) + folio_nr_pages(folio) - 1;
>> 	if (folio_test_hugetlb(folio)) {
>> 		isolate_hugetlb(folio, &source);
>> 		continue;
>> 	}
>> }
>
> How much of this is safe without a refcount on the folio?

folio_to_pfn() should be fine, isolate_hugetlb() checks the folio
under hugetlb_lock, but folio_nr_pages() might return a bogus number
that makes pfn go beyond end_pfn and ends for loop early. The code
below increases the refcount, so it might be better to move this
part of the code after refcount is increased.

--
Best Regards,
Yan, Zi

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux