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 D0FFAC83F03 for ; Wed, 9 Jul 2025 04:25:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EEBCF8D000F; Wed, 9 Jul 2025 00:25:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E9C738D0001; Wed, 9 Jul 2025 00:25:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8B678D000F; Wed, 9 Jul 2025 00:25:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C410B8D0001 for ; Wed, 9 Jul 2025 00:25:53 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1EE5B12895F for ; Wed, 9 Jul 2025 04:25:53 +0000 (UTC) X-FDA: 83643438186.25.6B2B7ED Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf21.hostedemail.com (Postfix) with ESMTP id 3881A1C0004 for ; Wed, 9 Jul 2025 04:25:49 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752035151; 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=jl0V/TJCSEO4d4R1W7zsaUoNIS0Ag5+kVn3c3NCnqM4=; b=VzBHFJUfoLEzLnZQf9jHUDEzFMcFjfjONKZ5ED7PFDEQFY+u7twQ0iDJuEIHI9cAILLoQV fza+66QnDX9X0CxR8p9JOH4Gw7bNNOLX+8IutgFxVvLGQDXW8ndUIGD+XcjOgLBmh3kYBS r8bNcIs0lAW9lo7457sH5vm/LaEz7kw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752035151; a=rsa-sha256; cv=none; b=gkg1EVgwbblfGgxLzSDezyZ4VG1hh3ohPzhzVOG1/TzV3jbnMcBnaaN5iXNvTNpzKsT/jc R/qPpYJrVxerF12wGpdZQ69ZV8/mslR5tug8V4S0YAH/i72QaGGFysAwORTXgpKqBCs5ke jEK0tDynlTxXJDFUN/6YGiZRwTmc774= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4bcPyF5kzgztSnl; Wed, 9 Jul 2025 12:24:37 +0800 (CST) Received: from kwepemo200002.china.huawei.com (unknown [7.202.195.209]) by mail.maildlp.com (Postfix) with ESMTPS id 5DBE9140276; Wed, 9 Jul 2025 12:25:44 +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; Wed, 9 Jul 2025 12:25:43 +0800 Message-ID: <571f741b-2612-2304-0c15-517d4777d157@huawei.com> Date: Wed, 9 Jul 2025 12:25:42 +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> <12881493-93db-56a6-471c-888051fd94fb@huawei.com> <875xg3wff2.fsf@DESKTOP-5N7EMDA> From: Jinjiang Tu In-Reply-To: <875xg3wff2.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: kwepems200002.china.huawei.com (7.221.188.68) To kwepemo200002.china.huawei.com (7.202.195.209) X-Rspamd-Queue-Id: 3881A1C0004 X-Stat-Signature: d6rbuweimujrcznm6n6mwgfyypbj57gm X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1752035149-519726 X-HE-Meta: U2FsdGVkX18RY0tJu/cu0wL/ta13iXjKocnGffBbt1zoc8LiPUpxUpZoiZctlABCKXs8XU+OrcO2aOgsJZ4/J7kPfFAk8YmwRcXSGEK6B+RNm+8otvI6BMwws34Inn0auqbvldqwYmqmcsncpQNfKZCk98LwnX3596+IrysYIqBmu0jCLKX1SrsWCpXyg04qOhYcAAb+E8tsJiUg5shDqmXBJxJopiszEeGhELWPyZFRJ+KDQbLQ/WLY/wwOcC3KrU9XlZV7W2dPdaNFNGFhEhurFaD0Cywq43mCwGN2W+pJ7MumZLbvGmfFJ6Ec8XDyRSmenCgWeXI6ePP07nUr27SeVVJuEk4vR90idWEHltb1aOVacmE6JDs4Q2dXKW76MIdPEvp8MkWa8LLTmt0zIYPQjapDrRU3dsNxgZV/1rj6IpFWyzA5U5q11q/E8+Bpwt9RKomA6VA2Ol2y8JjKUof48ye4/SWsiXH7H6XVBWBudbHa2uUa5PB74lq7pgBQ1kh/mL6+CjMT+GvbeYWChOh4fL9GXeRBzXRXYUvxkjtRpaNWKiIXTBkj07Txo0AD/BT2Rrb5lUiE2YfBbABq+/jvaezDYl4tVgyx+5F3qyXe5klE5/iN1Ipnw7kx8ljWWN67qYGj4h52dshrMP+bxPe71lVafUNT3GwggALaYvkeyff1EDJ9gx0XRHVbQcRVJ5K57mc+ffU/+B1Jx+R3B6GD4wq9ZX9Bv+7tHi2aX7SUPR+ELcNqX0wCUVG3eylHaN2yLJbVAQiePpYABz6+rI+lXE29Qjf0vZEWBH8amWLkTvflfLnUo9P1MZ5WklRCW/5tQYq2bvYKDbfxORBDHDG9NitCRq5jYWlG6WFu/rXijwst0NjvleX7HV9ZWdVl8lqq+NSDOntnVzzu+djX2hwwFgxzVK0U9mdwwcJyrw+oTJ1+QBF7KqZWRaJTZW5PUWU7j+ekCfRvZdNFl+S GyqC4fpc zo52UJMzWSKdYtyEp9AMEOLEa1JQJxg5AOwkyug/BrMnmislGiVzNjcdogD81GYvq7WzYB/wXbvW8nGRcUm/ma1ulW1LTlCvRyFbnkBW/SPxJHaACmy+4yvDV+YrOdtpQKxVi+0ABUL3JvgUZgLcjJZG+0n7NHU9EXuIzbplDSgQodoeq/eNZWVgVNFxNAKoR11rpQiqQWxAKHPg5hLLRY4+5uienABvIHQMcPsd2zpE5CQBDC1Jc3nutAgeGpM7RBQOTr6M2t6VBxVX1SvU6zgZVEIfPSsguMCwTyUo6lqmBMH6unLqCfsenulAEj+QH1SoklXMnxTpdaZQu9qVWN1bP8w== 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 11:05, Huang, Ying 写道: > Jinjiang Tu writes: > >> 在 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. > Please give more details of your issue to help us to understand it. For > example, why cannot you use pin_user_pages()? + CC Ruilin, he understands the usage scenario better. RuiLin, could you please explain why we couldn' use pin_user_pages()? > --- > Best Regards, > Huang, Ying