From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BFF6C83030 for ; Tue, 8 Jul 2025 02:51:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E3C568D0002; Mon, 7 Jul 2025 22:51:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E13D78D0001; Mon, 7 Jul 2025 22:51:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D50988D0002; Mon, 7 Jul 2025 22:51:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C63D08D0001 for ; Mon, 7 Jul 2025 22:51:51 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E9E711289C9 for ; Tue, 8 Jul 2025 02:51:49 +0000 (UTC) X-FDA: 83639572338.18.C818D41 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf04.hostedemail.com (Postfix) with ESMTP id 6C03940019 for ; Tue, 8 Jul 2025 02:51:47 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1751943108; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QUntnnXjUSszCZ9B7hG3D+3ZaPGPCFKZI+uNzx9YALg=; b=P3pmYVUJKmwZ+qAGWmV/sWO1bPXvFkjcHX8SRm8ty/XbB2jgMNg/apXesIX/yYtFXrqN9g iDpK1fhKF+IUeLYgZW0sv0dMkE0iKWzfHQpqoqaqC9bs5blOhAA9FejwICDF35OqME/+Mf NnmHRDzzO6xuBlG7LkuIJq3k9xgpOVc= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751943108; a=rsa-sha256; cv=none; b=FFHBoxAGsEmNm9OyzQ2NnejM3Y3raEToj/vU+yf4cRqGGC9dVG6eHHeEdn5kyalvhw0rhL ZH+pqxzhJcJJDK+91HEyD1BeqtZRUpWxNGo+HKVn9dpr9MyrEa4XYsKPns5VtPSJFxDwt+ EmmPcd3KegkPvoI4K90lzlbyOemjwV0= Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4bblrP5yZgzWfwK; Tue, 8 Jul 2025 10:47:17 +0800 (CST) Received: from kwepemo200002.china.huawei.com (unknown [7.202.195.209]) by mail.maildlp.com (Postfix) with ESMTPS id 0B43F140156; Tue, 8 Jul 2025 10:51:43 +0800 (CST) Received: from [10.174.179.13] (10.174.179.13) by kwepemo200002.china.huawei.com (7.202.195.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 8 Jul 2025 10:51:41 +0800 Message-ID: <12881493-93db-56a6-471c-888051fd94fb@huawei.com> Date: Tue, 8 Jul 2025 10:51:41 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [Question] get_vma_policy() isn't compatible with {pin, get}_user_pages_remote To: "Huang, Ying" CC: Andrew Morton , David Hildenbrand , , , Peter Xu , Zi Yan , , , , , , , , Kefeng Wang References: <94a3d35d-0872-5696-0333-7273f4a69979@huawei.com> <87cyabxxau.fsf@DESKTOP-5N7EMDA> From: Jinjiang Tu In-Reply-To: <87cyabxxau.fsf@DESKTOP-5N7EMDA> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.13] X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemo200002.china.huawei.com (7.202.195.209) X-Rspam-User: X-Rspamd-Queue-Id: 6C03940019 X-Rspamd-Server: rspam09 X-Stat-Signature: cy1ref7r9mouz4pxasonnkfxsktca67w X-HE-Tag: 1751943107-927994 X-HE-Meta: U2FsdGVkX19qhOyOgLRj6FvcYWR0b7gvkYEFe3SNaDnKlhkNjreJbhkXF+3KE05MQSeXIuYGTJbE+nzLjdNpDeIa2gZrVpsdKag0SQn3aWb3xMyo91Ifmq2MTjti+vfAnArkP2GSEmaAsQUy0ebnMXGOA5TiyyOI3GA22wcdol7+vDw3JctXoSzFCAhrbHL4hfWqzg38nXUcC5M29H2QqETlh7CpRn3CuyRd8H5juuHMUAT4czQZZ8f6BMxByzv9Ra88F8kT+1/MOawxV8w5sTOGEJdwqvKKeSB8Ksk5fdfLazn5RYsg0A1eGACY1DCCbAscmDtmZ7Dg/lXrMhtXfLMUxg5HPTlGPeoNDlnR1fFZ1TdTenhzlBUtV6tywcOA2fvjOtVgVd8mOGophoCiDMMdDY1qH5soYshq3BBMdf8MXpJRqH6hNY/UDST5mh/DTjFo240h763jSLN1gvrTbiwXzDrLTt/uf3AvqERp8fU+8cjsibPZZL4dZZ5jBJJaHCjg6E3hrH9+P5zFR0D+bHN+B9GkIWcsiTSSxAnFGNVQ65yXiIT6kjR2ADsOlU+OGoplZfKMUv0b2LhFSJEYXPssORNhH//nAPMS8Iu+g6Y3yb5XCx6IQYqXjuew/oI0wkDRqxMeBJzs22VoXajorEqZOngLcdhXXyzUmiFeT3E1PSS+rtCgytVYB5tvMvWONe6w3xQIATL6RPDSJnZGxAFi8yTQyhgW7nCt8DjlRjhLMvFqy8hoLbqrl7EGaKaUWAO2QxQcMhqa65zIRti8jubHnZH66y19h+2NvOGfkKmwAy/2MH+ZHuCJ2pO6Eah0UlSKS3BXd0TGkV22/+5q1d+zYVW/GUQqDdmPSY1GkbUuVwubFk70vuua7BZCWvypxgVUv5I45H49tk/V8N/NvXIa0LscNMgg5yW6wwTXWYnqTKxBwAs4TTsYOfthKb/E1kw5MbLT9NEhN14cibj HBuZ7kg6 /uR32 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 在 2025/7/8 9:53, Huang, Ying 写道: > Hi, Jinjiang, > > Jinjiang Tu 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