linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "David Hildenbrand (Red Hat)" <david@kernel.org>
To: Kiryl Shutsemau <kirill@shutemov.name>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Vlastimil Babka <vbabka@suse.cz>, Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>, Qi Zheng <qi.zheng@linux.dev>
Subject: Re: [PATCH v1 1/2] mm: move pte table reclaim code to memory.c
Date: Wed, 21 Jan 2026 13:08:00 +0100	[thread overview]
Message-ID: <fccb971f-3c7f-4bad-8c2d-6399985eefea@kernel.org> (raw)
In-Reply-To: <aW9i3Er3HXzg9V7C@thinkstation>

On 1/20/26 12:19, Kiryl Shutsemau wrote:
> On Mon, Jan 19, 2026 at 11:07:07PM +0100, David Hildenbrand (Red Hat) wrote:
>> The pte-table reclaim code is only called from memory.c, while zapping
>> pages, and it better also stays that way in the long run. If we ever
>> have to call it from other files, we should expose proper high-level
>> helpers for zapping if the existing helpers are not good enough.
>>
>> So, let's move the code over (it's not a lot) and slightly clean it up a
>> bit by:
>> - Renaming the functions.
>> - Dropping the "Check if it is empty PTE page" comment, which is now
>>    self-explaining given the function name.
>> - Making zap_pte_table_if_empty() return whether zapping worked so the
>>    caller can free it.
>> - Adding a comment in pte_table_reclaim_possible().
>> - Inlining free_pte() in the last remaining user.
>> - In zap_empty_pte_table(), switch from pmdp_get_lcokless() to
>>    pmd_clear(), we are holding the PMD PT lock.
>>
>> By moving the code over, compilers can also easily figure out when
>> zap_empty_pte_table() does not initialize the pmdval variable, avoiding
>> false-positive warnings about the variable possibly not being
>> initialized.
> 
> mm/memory.c is a kitchen sink as it is.
> 
> I think you miss opportunity to introduce mm/zap.c and move all zap
> code.
> 
> It can be done for code from both mm/memory.c and mm/huge_memory.c.
> Line between THP and non-THP code gets more and more blurry over time.
> 
> The same can be done for copy and fault code. I think it is going to be
> more maintainable this way.

While agree that memory.c contains too much stuff, I don't think zap.c 
is the right abstraction either. And actually, I think basic page table 
handling is well kept in memory.c, or moved along with other stuff 
(fork()) handling somewhere else.

So I won't do any of that as part of this patch.

-- 
Cheers

David


  reply	other threads:[~2026-01-21 12:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-19 22:07 [PATCH v1 0/2] " David Hildenbrand (Red Hat)
2026-01-19 22:07 ` [PATCH v1 1/2] " David Hildenbrand (Red Hat)
2026-01-20  3:30   ` Qi Zheng
2026-01-20 11:19   ` Kiryl Shutsemau
2026-01-21 12:08     ` David Hildenbrand (Red Hat) [this message]
2026-01-19 22:07 ` [PATCH v1 2/2] mm/memory: handle non-split locks correctly in zap_empty_pte_table() David Hildenbrand (Red Hat)
2026-01-20  3:32   ` Qi Zheng

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=fccb971f-3c7f-4bad-8c2d-6399985eefea@kernel.org \
    --to=david@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mhocko@suse.com \
    --cc=qi.zheng@linux.dev \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    /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