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 1A1DCC001DB for ; Fri, 4 Aug 2023 05:54:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D9762802C8; Fri, 4 Aug 2023 01:54:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 589F22802BC; Fri, 4 Aug 2023 01:54:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 451282802C8; Fri, 4 Aug 2023 01:54:23 -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 328452802BC for ; Fri, 4 Aug 2023 01:54:23 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id F2A298080D for ; Fri, 4 Aug 2023 05:54:22 +0000 (UTC) X-FDA: 81085357164.01.0ACBB24 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf08.hostedemail.com (Postfix) with ESMTP id 887B9160003 for ; Fri, 4 Aug 2023 05:54:19 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691128461; 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=qtkyhys1ablfoLdqea9MB1WHl8KRWS/U5/LKpB/9M/8=; b=cwYCq3jAI/5rXcElWt+Zo/wK1L/dlUg+sUhNvX4216SFAM3qPJmHA9oxCxH+FNF8HsTPfQ RBuU3uBsgdEtWnQJshNLa8qKQFuNO6MheAGEtIpXviV8Q4dj3pj7Vbwwh9b13QjbecFQ9A T5GaCHsyQCAtjAEkMuVoQacnmFDmalM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691128461; a=rsa-sha256; cv=none; b=2eGQEAyrmx9v82LCjw8yx4m3axaYyx3DFitUKFNtoIAFeKkO5AMS0Ms/lQ0yZZ+AKwW147 /Oq8SlxgrAVDr1WkIW2pDuB1dbTrOMWdoCmtDBAqQ7H/PZ1mm1SUxXGlgZ9Tsdny7CAIiP qCDSzRY7kw40/ferZb0627BggeZrB1U= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RHFHm5Ztbz1KCDj; Fri, 4 Aug 2023 13:53:08 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 4 Aug 2023 13:54:12 +0800 Message-ID: Date: Fri, 4 Aug 2023 13:54:12 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH 1/4] mm: migrate: use a folio in add_page_for_migration() Content-Language: en-US To: Zi Yan CC: Matthew Wilcox , Andrew Morton , , , Huang Ying , David Hildenbrand References: <20230802095346.87449-1-wangkefeng.wang@huawei.com> <20230802095346.87449-2-wangkefeng.wang@huawei.com> <001ee9b0-ea25-a896-e3ae-9a9b05a46546@huawei.com> From: Kefeng Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 887B9160003 X-Stat-Signature: g1w6qfpnfuzgxj9e8uw8uwrjwj9q65h8 X-HE-Tag: 1691128459-62992 X-HE-Meta: U2FsdGVkX1/pqkYqjLraK9sMfoNZsdfmHwHJ1eYkgDEMtgRFd55UE5dPzVPJ2segmuR9NugyxjE0vVswKzeGKJ6vpdL0Ymqq5q+QUVtVo/yksXpPq+WqxUKbZqqcKpKjP1ErCrsuI1nMtEJDn97V2eXMtcqrqaiuhrtncv5TksOdXFiPX/aZMgz1WzSpA9s6KB34ObVaHZRsNghtwfTukg1CK+D0230qHRQsUDheCFcPh4KRGs6kcM2SfM/s0KdFqYdRzbCHnOnPxj0EEPIwxTXBUZz0DDkjwA//EzE44H9vLBKhcZDL7UOrLRtJGz0lfprYZkSSPuKVEQXRlNQmMARQoDoLFtD3uwiUbPJbAbDqncayclb62IJ0RVB66KeDveDdp8XU3GJmzct9Z461e9bZeMYoTVAsB58myHIzXb0y03cBEnlLFy4crz4lAny5NHr885jXjWtcsYLJU4EEikVciiSEiBfLhcjGuBGc3Y9rPkFMjcmyoALx6OMtVWAPllkkSaLbJewvEDnLrdEOpqM3jhAfjSLxZziYCYP1/pepDTQeP1W22+EQGJ27GfvRmaKrYbSbJNhSpFg0zzLTwQPwFKBJLksqvxYLHZmCNlT3zszYPYgqcMARTJbX1NlvON1Dm4BBttPvDtIqJIvLLqrf7YMovvMf09G/Ipqdni1+HkfHS/yaqBEjM7j63/YnWw+8oEWRaARL9nXCcDwnuNS7W8MWItpW7shoLRjjAMR6ZITcRSCf1HmpUt3eJMYGcFTkHQrlpOdC2JtVZrsHejmKpSxqdfZQYr6yGJQk8dB4xjMbKaosGh7CkGtdwgk1UZ2WapePN9aaCuQM9xYvXTDIDTGr+kY5WnBeALze6N6G9FqQGRrSVTJf2zl9qsu0PdgebP3mF1PMmshKyHdn/HC1wJBAxMz3rtWhfmAUpuFcAM/4j3k1iV+WDLhmP+y62/6VTvfUsfhEm/FnZAG 7NcKtpNE hH8HOgQfy5AL+9Cvm+x7/tImCcTxMlDqoXljqp7EYE/5jtQXdaBUI9rVM9itTWoOMRhRxa6+aKRdK/pv3pf21jOkKOj1ypzNOrs8grcyk/2MsJtmmzHfhbq6yXEafJGu6Rhk3ASrBexGK1LGM+udu4zCm6O0V4AJye1FsHvZfIoFvfIb0a9zZyUPUuqQd3Fn69kuqaxvFEtcd6y/mFKt40e0jgRvN7iea0TraB+SlVFRKIlh7v4yk5jqvE0ZxE7fZD2xwQOP/RZ0sau4= 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: On 2023/8/4 10:42, Zi Yan wrote: > On 3 Aug 2023, at 21:45, Kefeng Wang wrote: > >> On 2023/8/3 20:30, Matthew Wilcox wrote: >>> On Thu, Aug 03, 2023 at 03:13:21PM +0800, Kefeng Wang wrote: >>>> >>>> >>>> On 2023/8/2 20:21, Matthew Wilcox wrote: >>>>> On Wed, Aug 02, 2023 at 05:53:43PM +0800, Kefeng Wang wrote: >>>>>> err = -EACCES; >>>>>> - if (page_mapcount(page) > 1 && !migrate_all) >>>>>> - goto out_putpage; >>>>>> + if (folio_estimated_sharers(folio) > 1 && !migrate_all) >>>>>> + goto out_putfolio; >>>>> >>>>> I do not think this is the correct change. Maybe leave this line >>>>> alone. >>>> >>>> Ok, I am aware of the discussion about this in other mail, will not >>>> change it(also the next two patch about this function), or wait the >>>> new work of David. >>>>> >>>>>> - if (PageHuge(page)) { >>>>>> - if (PageHead(page)) { >>>>>> - isolated = isolate_hugetlb(page_folio(page), pagelist); >>>>>> + if (folio_test_hugetlb(folio)) { >>>>>> + if (folio_test_large(folio)) { >>>>> >>>>> This makes no sense when you read it. All hugetlb folios are large, >>>>> by definition. Think about what this code used to do, and what it >>>>> should be changed to. >>>> >>>> hugetlb folio is self large folio, will drop redundant check >>> >>> No, that's not the difference. Keep thinking about it. This is not >>> a mechanical translation! >> >> >> if (PageHuge(page)) // page must be a hugetlb page >> if (PageHead(page)) // page must be a head page, not tail >> isolate_hugetlb() // isolate the hugetlb page if head >> >> After using folio, >> >> if (folio_test_hugetlb(folio)) // only check folio is hugetlb or not >> >> I don't check the page is head or not, since the follow_page could >> return a sub-page, so the check PageHead need be retained, right? > > Right. It will prevent the kernel from trying to isolate the same hugetlb page > twice when two pages are in the same hugetlb folio. But looking at the > code, if you try to isolate an already-isolated hugetlb folio, isolate_hugetlb() > would return false, no error would show up. But it changes err value > from -EACCES to -EBUSY and user will see a different page status than before. When check man[1], the current -EACCES is not right, -EBUSY is not precise but more suitable for this scenario, -EACCES The page is mapped by multiple processes and can be moved only if MPOL_MF_MOVE_ALL is specified. -EBUSY The page is currently busy and cannot be moved. Try again later. This occurs if a page is undergoing I/O or another kernel subsystem is holding a reference to the page. -ENOENT The page is not present. > > I wonder why we do not have follow_folio() and returns -ENOENT error pointer > when addr points to a non head page. It would make this patch more folio if > follow_folio() can be used in place of follow_page(). One caveat is that > user will see -ENOENT instead of -EACCES after this change. > -ENOENT is ok, but maybe the man need to be updated too. [1] https://man7.org/linux/man-pages/man2/move_pages.2.html > > -- > Best Regards, > Yan, Zi