From: Jinjiang Tu <tujinjiang@huawei.com>
To: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>, <jgg@nvidia.com>,
<jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>,
Zi Yan <ziy@nvidia.com>, <matthew.brost@intel.com>,
<joshua.hahnjy@gmail.com>, <rakie.kim@sk.com>, <byungchul@sk.com>,
<gourry@gourry.net>, <apopple@nvidia.com>, <linux-mm@kvack.org>,
Kefeng Wang <wangkefeng.wang@huawei.com>
Subject: Re: [Question] get_vma_policy() isn't compatible with {pin, get}_user_pages_remote
Date: Tue, 8 Jul 2025 10:51:41 +0800 [thread overview]
Message-ID: <12881493-93db-56a6-471c-888051fd94fb@huawei.com> (raw)
In-Reply-To: <87cyabxxau.fsf@DESKTOP-5N7EMDA>
在 2025/7/8 9:53, Huang, Ying 写道:
> Hi, Jinjiang,
>
> Jinjiang Tu <tujinjiang@huawei.com> writes:
>
>> get_vma_policy() returns the mempolicy for the vma. If the vma has set
>> mempolicy, the policy is returned. Otherwise,
>> call get_task_policy(current) to get the mempolicy of current
>> task. However, it isn't reasonable for
>> pin_user_pages_remote() and get_user_pages_remote() cases.
>>
>> Assume task A calls pin_user_pages_remote() to pin user pages from
>> task B. If the [start, start + nr_pages) isn't
>> populated with pages, handle_mm_fault() will be called by task
>> A. However, if the vma doesn't set memory policy,
>> the mempolicy of task A instead of task B is used to allocate. It
>> seems to be unreasonable. See
>> dequeue_hugetlb_folio_vma()->huge_node().
>>
>> We can only obtain mm in get_vma_policy(), but we couldn't get the
>> task, since a mm can be associated with multiple
>> tasks(threads) and the task mempolicy is at thread granularity.
>>
>> Is this situation reasonable? And if not, how could we fix it?
> Yes. This sounds like an issue in theory and it's hard to be resolved
> if possible. Please take a look at get_user_pages_remote() usage in
> exec().
IIUC, exec() replaces current->mm with new mm, and the task_struct isn't changed,
thus task mempolicy is same, so it is reasonable to use get_user_pages_remote() in exec().
> Do you have some practical issue with pin/get_user_pages_remote()?
Yes, I have a driver to pin_user_pages_remote() for other task.
> ---
> Best Regards,
> Huang, Ying
next prev parent reply other threads:[~2025-07-08 2:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-08 1:21 Jinjiang Tu
2025-07-08 1:53 ` Huang, Ying
2025-07-08 2:51 ` Jinjiang Tu [this message]
2025-07-08 3:05 ` Huang, Ying
2025-07-09 4:25 ` Jinjiang Tu
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=12881493-93db-56a6-471c-888051fd94fb@huawei.com \
--to=tujinjiang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=byungchul@sk.com \
--cc=david@redhat.com \
--cc=gourry@gourry.net \
--cc=jgg@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=joshua.hahnjy@gmail.com \
--cc=linux-mm@kvack.org \
--cc=matthew.brost@intel.com \
--cc=peterx@redhat.com \
--cc=rakie.kim@sk.com \
--cc=wangkefeng.wang@huawei.com \
--cc=ying.huang@linux.alibaba.com \
--cc=ziy@nvidia.com \
/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