From: David Hildenbrand <david@redhat.com>
To: Shivank Garg <shivankg@amd.com>,
akpm@linux-foundation.org, willy@infradead.org,
pbonzini@redhat.com
Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
linux-coco@lists.linux.dev, chao.gao@intel.com,
seanjc@google.com, ackerleytng@google.com, vbabka@suse.cz,
bharata@amd.com, nikunj@amd.com, michael.day@amd.com,
Neeraj.Upadhyay@amd.com, thomas.lendacky@amd.com,
michael.roth@amd.com, Shivansh Dhiman <shivansh.dhiman@amd.com>,
baolin.wang@linux.alibaba.com
Subject: Re: [RFC PATCH v4 1/3] mm/filemap: add mempolicy support to the filemap layer
Date: Mon, 17 Feb 2025 20:52:31 +0100 [thread overview]
Message-ID: <f880cf51-8703-444c-ac7e-b89cc5816931@redhat.com> (raw)
In-Reply-To: <d504979a-3f25-4a57-9632-5c17cbc2acda@amd.com>
>
> (1) As you noted later, shmem has unique requirements due to handling swapin.
> It does considerable open-coding.
> Initially, I was considering simplifying the shmem but it was not possible due
> to above constraints.
> One option would be to add shmem's special cases in the filemap and check for
> themusing shmem_mapping()?
> But, I don't understand the shmem internals well enough to determine if it is
> feasible.
>
Okay, thanks for looking into this.
> (2) I considered handling it manually in guest_memfd like shmem does, but this
> would lead to code duplication and more open-coding in guest_memfd. The current
> approach seems cleaner.
Okay, thanks.
>
>> Two tabs indent on second parameter line, please.
>>
> ..
>>
>> This should go below the variable declaration. (and indentation on second parameter line should align with the first parameter)
>>
> ..
>> "The mempolicy to apply when allocating a new folio." ?
>>
>
> I'll address all the formatting and documentation issues in next posting.
>
>>
>> For guest_memfd, where pages are un-movable and un-swappable, the memory policy will never change later.
>>
>> shmem seems to handle the swap-in case, because it keeps care of allocating pages in that case itself.
>>
>> For ordinary pagecache pages (movable), page migration would likely not be aware of the specified mpol; I assume the same applies to shmem?
>>
>> alloc_migration_target() seems to prefer the current nid (nid = folio_nid(src)), but apart from that, does not lookup any mempolicy.
>
> Page migration does handle the NUMA mempolicy using mtc (struct migration_target_control *)
> which takes node ID input and allocates on the "preferred" node id.
> The target node in migrate_misplaced_folio() is obtained using get_vma_policy(), so the
> per-VMA policy handles proper node placement for mapped pages.
> It use current nid (folio_nid(src)) only if NUMA_NO_NODE is passed.
>
> mempolicy.c provides the alloc_migration_target_by_mpol() that allocates according to
> NUMA mempolicy, which is used by do_mbind().
>
>>
>> compaction likely handles this by comapcting within a node/zone.
>>
>> Maybe migration to the right target node on misplacement is handled on a higher level lagter (numa hinting faults -> migrate_misplaced_folio). Likely at least for anon memory, not sure about unmapped shmem.
>
> Yes.
Thanks, LGTM.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-02-17 19:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 6:32 [RFC PATCH v4 0/3] Add NUMA mempolicy support for KVM guest-memfd Shivank Garg
2025-02-10 6:32 ` [RFC PATCH v4 1/3] mm/filemap: add mempolicy support to the filemap layer Shivank Garg
2025-02-12 10:03 ` David Hildenbrand
2025-02-13 18:27 ` Shivank Garg
2025-02-17 19:52 ` David Hildenbrand [this message]
2025-02-10 6:32 ` [RFC PATCH v4 2/3] mm/mempolicy: export memory policy symbols Shivank Garg
2025-02-12 10:23 ` David Hildenbrand
2025-02-13 18:27 ` Shivank Garg
2025-02-17 11:52 ` Vlastimil Babka
2025-02-18 15:22 ` Sean Christopherson
2025-02-19 6:45 ` Shivank Garg
2025-02-10 6:32 ` [RFC PATCH v4 3/3] KVM: guest_memfd: Enforce NUMA mempolicy using shared policy Shivank Garg
2025-02-12 10:39 ` David Hildenbrand
2025-02-13 18:27 ` Shivank Garg
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=f880cf51-8703-444c-ac7e-b89cc5816931@redhat.com \
--to=david@redhat.com \
--cc=Neeraj.Upadhyay@amd.com \
--cc=ackerleytng@google.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=bharata@amd.com \
--cc=chao.gao@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=michael.day@amd.com \
--cc=michael.roth@amd.com \
--cc=nikunj@amd.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=shivankg@amd.com \
--cc=shivansh.dhiman@amd.com \
--cc=thomas.lendacky@amd.com \
--cc=vbabka@suse.cz \
--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