Re: [PATCH 02/10] mm/ksm: skip subpages of compound pages

Alex Shi
2024-06-05T06:14:18Z

On 6/5/24 11:52 AM, Matthew Wilcox wrote:
> On Tue, Jun 04, 2024 at 12:24:44PM +0800, alexs@kernel.org wrote:
>> From: "Alex Shi (tencent)" <alexs@kernel.org>
>>
>> When a folio isn't fit for KSM, the subpages are unlikely to be good,
>> So let's skip the rest page checking to save some actions.
>
> Why would you say that is true? We have plenty of evidence that
> userspace allocators can allocate large folios, then use only the first
> few bytes, leaving many tail pages full of zeroes.

Um, that do need tail pages...
Is there some way to use more folio in ksm?

>
>> @@ -2660,6 +2662,9 @@ static struct ksm_rmap_item *scan_get_next_rmap_item(struct page **page)
>> cond_resched();
>> continue;
>> }
>> +
>> + VM_WARN_ON(PageTail(*page));
>> + nr = compound_nr(*page);
>
> And this is simply wrong. *page can obviously be a tail page.
>

Got it. Thanks a lot!
Alex