From patchwork Wed Sep 13 09:51:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13382703 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 5A593CA5531 for ; Wed, 13 Sep 2023 09:52:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7267B6B0173; Wed, 13 Sep 2023 05:52:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D6646B0174; Wed, 13 Sep 2023 05:52:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54F2B6B0175; Wed, 13 Sep 2023 05:52:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4354C6B0173 for ; Wed, 13 Sep 2023 05:52:09 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 18C541A0D13 for ; Wed, 13 Sep 2023 09:52:09 +0000 (UTC) X-FDA: 81231108378.04.228FACE Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf25.hostedemail.com (Postfix) with ESMTP id D3DC9A0022 for ; Wed, 13 Sep 2023 09:52:06 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 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=1694598727; 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=edCISLjT6+ZkLMLK7dCnKkIlBAZTUznn0Sy9MjDom88=; b=inePx/fgnL/h321IDu605/sm5/rGJv9HiDTJ6acXhxN7MpDhl3IncewBMnzI17haxjnQiQ 06oFN8R9d5PJ2RplygAkG0j/I+Ae+2S8ptExZa2HRnrm6MDO/KW9l6FapBrI/56YXWPTM7 8L72pVKoam/PIwjLUsWBSHh34JOxJgA= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694598727; a=rsa-sha256; cv=none; b=JSkth8ZkXPkooyJBrjWyT0LCWuEfsJfryztzW0itlwwor2v0NZit15ful6d5HlgZs9pb8g fJNIX5HtnsVlwFv/S+zdAWveBBalq5ue32YeMxuIf9fk4EVbHMSL7bHfm+Aj2OrzY7J36L G3a6a5tXuYex9xsNQqFZrbq4ZBIdtcY= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Rlwcy4tMkzMlLX; Wed, 13 Sep 2023 17:48:34 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) 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.31; Wed, 13 Sep 2023 17:52:01 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 7/8] mm: migrate: remove PageHead() check for HugeTLB in add_page_for_migration() Date: Wed, 13 Sep 2023 17:51:30 +0800 Message-ID: <20230913095131.2426871-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: D3DC9A0022 X-Stat-Signature: ju967n6w67wm4jofs1xas3nmk3no8ebd X-Rspam-User: X-HE-Tag: 1694598726-166742 X-HE-Meta: U2FsdGVkX18QtfCoxeYgXEjlDbUpne0NtbPa+NYXXH7BzWIZ3JisMfY0FkzdvJeSg2fL2x4h7zn3XIfWMlgy4B1nLNmYlgGQo4iI9aNanQMQQQEE5V3aP+AbbM0i0HmKep+xwismdhTJquO1HZGr9wg3PX87ll+h8D5boKwO+Gv4d6GuuXgx7EyUyz/E7Zcr8uM5go5hp/J6KMj+tOd9sy9ZzuwwLR4WgkGEbWyVKAHdQ3aIPeBWdtW2Hc2OSLWH2eDVWv+4zP9FQgsUlSZpaxwON8nClKaOL40V6uRsEpnDssiHFKpxkPnFuHFtCZmItV2WVMkYQvy0ZyO94izxQtssQqId7m0qkv3nqJTaaIwFyU9g+nkf5eeZi2j1pFlbeVvcHzNMnjqqp6zsy2DcaCs1/WEPMH3OF8vvnujm6+8QMr1Wi6Ob24vA56GJdW4zI7zAoYFfAs30A/JHIIcqq3rqJVJFDHKzCHJPzlNv1pM0YeScuENyMo1tdLim5LsMtPy2/DL3y9d0CegCO+iRz+kDppX7kjQEGb2vsRbW8S1FhL3OIpDWFTw0oSEBzu45lA6iXYQ0mllXkiYM980i9cSbV4Dzp6os8/r6A1LRXH/VFlKct5MqSd2b9FhnJuMLfVCJfCOdNtwjaAs2Y828SQMdkEOAuPebECu4rcIJwGuJQccv//DCTUTlXFagjGIrh/ZqwG4AujD4zm2pGccjYWSMGhnabPCt/2qr06VzewW1eY4l/AH4MtcEHKhjJcRdCZVjdsYI05f75f1UUl/QlQROB1zDZ7LUZHz3kv5EoTa/i81KmBt/6Nx6bBLBtp7WTBVc+MRH6Jcm4rnCv9Txa9SWILoPnIQSwoJWdtUa3Y3CYnI3irfkl/K+yim0JDMkaBIUnwkh3LCztNc8b2nsEPhDY8R63ebL/pyllxSGENlKHYMobbPFIQsUM74E3YmyXQ1bqcFpbpSKxqihqWj MKCxDHoH fueMVyvPMl949yZA+9yoXGXCBsEpadzIbPObE+MOOOjXn8nnF+Iv1CCnPYdxouv/LzvyKt0fB5jLL2JvBjN42QEFVZeQgTAJh6z7EGki8E9OAeMbOkcRD/wYK9D3aay2cRKbnTCNADar9MYnWOAR5+sCm+1F/1sdDPRW/vvLRIv3eQAJGPnxjUa+EDu499cgLTRvNrCbDGeFeulT0Xl63xQmCdeonOxsQSBCj3Lm13bEPfOpUl/V0FDNWQgnaJw5ERJBbVpHkvryebeNvF9iqPoJqQQRMGghmv0L/XrRIYD4ruUGWpDSIYF+aVQetCytjd4kp 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: There is some different between hugeTLB and THP behave when passed the address of a tail page, for THP, it will migrate the entire THP page, but for HugeTLB, it will return -EACCES, or -ENOENT before commit e66f17ff7177 ("mm/hugetlb: take page table lock in follow_huge_pmd()"), -EACCES The page is mapped by multiple processes and can be moved only if MPOL_MF_MOVE_ALL is specified. -ENOENT The page is not present. But when check manual[1], both of the two errnos are not suitable, it is better to keep the same behave between hugetlb and THP when passed the address of a tail page, so let's just remove the PageHead() check for HugeTLB. [1] https://man7.org/linux/man-pages/man2/move_pages.2.html Suggested-by: Mike Kravetz Acked-by: Zi Yan Signed-off-by: Kefeng Wang --- mm/migrate.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index cf5c9254fdad..7b07c97f5a6f 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2093,10 +2093,8 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, goto out_putfolio; if (folio_test_hugetlb(folio)) { - if (PageHead(page)) { - isolated = isolate_hugetlb(folio, pagelist); - err = isolated ? 1 : -EBUSY; - } + isolated = isolate_hugetlb(folio, pagelist); + err = isolated ? 1 : -EBUSY; } else { isolated = folio_isolate_lru(folio); if (!isolated) {