All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Huang, Ying" <ying.huang@linux.alibaba.com>
To: Jinjiang Tu <tujinjiang@huawei.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, 08 Jul 2025 09:53:45 +0800	[thread overview]
Message-ID: <87cyabxxau.fsf@DESKTOP-5N7EMDA> (raw)
In-Reply-To: <94a3d35d-0872-5696-0333-7273f4a69979@huawei.com> (Jinjiang Tu's message of "Tue, 8 Jul 2025 09:21:57 +0800")

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().

Do you have some practical issue with pin/get_user_pages_remote()?

---
Best Regards,
Huang, Ying


  reply	other threads:[~2025-07-08  1:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-08  1:21 [Question] get_vma_policy() isn't compatible with {pin, get}_user_pages_remote Jinjiang Tu
2025-07-08  1:53 ` Huang, Ying [this message]
2025-07-08  2:51   ` Jinjiang Tu
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=87cyabxxau.fsf@DESKTOP-5N7EMDA \
    --to=ying.huang@linux.alibaba.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=tujinjiang@huawei.com \
    --cc=wangkefeng.wang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.