From: David Hildenbrand <david@redhat.com>
To: Alex Shi <seakeel@gmail.com>,
alexs@kernel.org, Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
izik.eidus@ravellosystems.com, willy@infradead.org,
aarcange@redhat.com, chrisw@sous-sol.org, hughd@google.com
Subject: Re: [PATCH 02/10] mm/ksm: skip subpages of compound pages
Date: Wed, 5 Jun 2024 09:40:24 +0200 [thread overview]
Message-ID: <4a354a51-96d8-4243-a977-3ebdc58fd8bc@redhat.com> (raw)
In-Reply-To: <cf5a0d4a-5291-4d4c-92e5-9340dfa4e8ac@gmail.com>
On 05.06.24 05:58, Alex Shi wrote:
>
>
> On 6/4/24 9:14 PM, David Hildenbrand wrote:
>> On 04.06.24 15:10, Alex Shi wrote:
>>>
>>>
>>> On 6/4/24 6:43 PM, David Hildenbrand wrote:
>>>>>>>
>>>>>>> @@ -2680,7 +2685,7 @@ static struct ksm_rmap_item *scan_get_next_rmap_item(struct page **page)
>>>>>>> }
>>>>>>> next_page:
>>>>>>> put_page(*page);
>>>>>>> - ksm_scan.address += PAGE_SIZE;
>>>>>>> + ksm_scan.address += nr * PAGE_SIZE;
>>>>>>> cond_resched();
>>>>>>> }
>>>>>>> }
>>>>>>
>>>>>> You might be jumping over pages that don't belong to that folio. What you would actually want to do is somehow use folio_pte_batch() to really know the PTEs point at the same folio, so you can skip them. But that's not that easy when using follow_page() ...
>>>>>>
>>>>>> So I suggest dropping this change for now.
>>>>>>
>>>>>
>>>>> Hi David,
>>>>>
>>>>> Forgive my stupidity, where I jump over normal page that not to belong to the folio?
>>>>
>>>> IIUC, you assume that the folio is fully mapped by all PTEs that could span it, and that follow_page() would give you the head page, correct?
>>>>
>>>> As a simple example, assume only a single page of a large folio is still mapped, which could be any tail page. You couldn't jump over any PTEs.
>>>>
>>>> Or am I missing something?
>>>
>>> Uh, thanks for explanations. for what's we concerned, the following code could take care of the FULL or ERR pages. And it still keep the step of single page.
>>> page = follow_page(vma, ksm_scan.address, FOLL_GET);
>>> if (IS_ERR_OR_NULL(page)) {
>>> ksm_scan.address += PAGE_SIZE;
>>> cond_resched();
>>> continue;
>>> }
>>> And after the above code, step folio_nr_pages on address should be safe, isn't it?
>>
>> Not sure if I follow. Let me try explaining once again:
>>
>> Assume a PTE maps some tail page of the large anonymous folio. The other PTEs around it map some other anonymous folios, not pages of that large anonymous folio.
>
>
> Sorry, David,
>
> Do you meaning there are 2 folio pages, in a same vma, in their address, 'ksm_scan.address', would be overlapped in a folio size space?
> If so, that do out of my expect. I do have no idea of this thing. Could you give me more hints of this problem or how things work on it in current kernel?
We do fully support partially mapping of THPs/large folios. That means,
you could map a single page of a large pagecache folio and the other
PTEs could map anonymous folios (due to COW).
Simply because follow_page() returned a page of a large folio doesn't
generally say that the PTEs around it map the same large folio.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-06-05 7:40 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-04 4:24 [PATCH 00/10] use folio in ksm alexs
2024-06-04 4:24 ` [PATCH 01/10] mm/ksm: reduce the flush action for ksm merging page alexs
2024-06-04 8:07 ` David Hildenbrand
2024-06-04 10:26 ` Alex Shi
2024-06-04 10:45 ` David Hildenbrand
2024-06-04 13:02 ` Alex Shi
2024-06-05 7:26 ` David Hildenbrand
2024-06-05 9:10 ` Alex Shi
2024-06-05 9:14 ` David Hildenbrand
2024-06-05 9:49 ` Alex Shi
2024-06-05 10:00 ` David Hildenbrand
2024-06-04 4:24 ` [PATCH 02/10] mm/ksm: skip subpages of compound pages alexs
2024-06-04 8:12 ` David Hildenbrand
2024-06-04 10:31 ` Alex Shi
2024-06-04 10:43 ` David Hildenbrand
2024-06-04 13:10 ` Alex Shi
2024-06-04 13:14 ` David Hildenbrand
2024-06-05 3:58 ` Alex Shi
2024-06-05 7:40 ` David Hildenbrand [this message]
2024-06-05 3:52 ` Matthew Wilcox
2024-06-05 6:14 ` Alex Shi
2024-06-05 7:47 ` David Hildenbrand
2024-06-05 21:12 ` Matthew Wilcox
2024-06-06 7:11 ` David Hildenbrand
2024-06-04 4:24 ` [PATCH 03/10] mm/ksm: use folio in try_to_merge_one_page alexs
2024-06-04 8:19 ` David Hildenbrand
2024-06-05 3:38 ` Alex Shi
2024-06-04 4:24 ` [PATCH 04/10] mm/ksm: add identical_folio func alexs
2024-06-04 8:25 ` David Hildenbrand
2024-06-04 4:24 ` [PATCH 05/10] mm/ksm: use folio in stable_tree_search alexs
2024-06-04 4:24 ` [PATCH 06/10] mm/ksm: remove page_stable_node alexs
2024-06-04 4:24 ` [PATCH 07/10] mm/ksm: use folio in unstable_tree_search_insert alexs
2024-06-04 4:24 ` [PATCH 08/10] mm/ksm: use folio in try_to_merge_xx serie funcs alexs
2024-06-04 4:24 ` [PATCH 09/10] mm/ksm: calc_checksum for folio alexs
2024-06-04 13:18 ` David Hildenbrand
2024-06-05 3:44 ` Alex Shi
2024-06-05 7:53 ` David Hildenbrand
2024-06-04 4:24 ` [PATCH 10/10] m/ksm: use folio in ksm scan path alexs
2024-06-04 13:28 ` [PATCH 00/10] use folio in ksm David Hildenbrand
2024-06-05 3:46 ` Alex Shi
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=4a354a51-96d8-4243-a977-3ebdc58fd8bc@redhat.com \
--to=david@redhat.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=alexs@kernel.org \
--cc=chrisw@sous-sol.org \
--cc=hughd@google.com \
--cc=izik.eidus@ravellosystems.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=seakeel@gmail.com \
--cc=willy@infradead.org \
/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