From patchwork Fri Dec 29 08:22:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13506387 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 5EA54C46CD4 for ; Fri, 29 Dec 2023 07:59:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6148D6B010C; Fri, 29 Dec 2023 02:59:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C5236B010D; Fri, 29 Dec 2023 02:59:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B32A6B010E; Fri, 29 Dec 2023 02:59:49 -0500 (EST) 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 39E626B010C for ; Fri, 29 Dec 2023 02:59:49 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C3FE81C094F for ; Fri, 29 Dec 2023 07:59:48 +0000 (UTC) X-FDA: 81619106856.02.E5492F4 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf21.hostedemail.com (Postfix) with ESMTP id B0AB41C0003 for ; Fri, 29 Dec 2023 07:59:45 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 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=1703836786; 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: references; bh=DoYgI1wINoQrI0vyfKQ7WpAFqe9D5NXE428okDCJWlQ=; b=BCUf2CRVBTYugWy3hv7XYGQ8VLjg3jkAZk4xk3DyPYXPI0KItYG0bDNSc0RFShrTn5KvCn GcYZaA1B6j3BdxKV4dQMyiMe/aS8cgHpm140BEQ+lsw24lc3gVBAxSEN28wYnJEdM+TGGo Z765ukL9NlXHcR5Y4qfPCzCbkgui0WE= 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 wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703836786; a=rsa-sha256; cv=none; b=X1JYoOCX69pnmWWAbpv2PdFeLRN2GThxUOqqk77ZhnTD4/6kD129SY6XHNsp4OIJHdKumF YvpVaIVK2No1dbpUJi2fUMmb8kIW9x0OHKpYFTkacRIrV5JFgeRduejySy1Txg01R3rLl4 IAyHaGqwDIJda/tOSrM3v54f/1qyaxg= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4T1d6M0w5jz1g19t; Fri, 29 Dec 2023 15:58:19 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 473A41800B8; Fri, 29 Dec 2023 15:59:40 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) 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.35; Fri, 29 Dec 2023 15:59:39 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Kefeng Wang Subject: [PATCH] mm: memory: use nth_page() in clear/copy_subpage() Date: Fri, 29 Dec 2023 16:22:07 +0800 Message-ID: <20231229082207.60235-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: B0AB41C0003 X-Stat-Signature: xuy8qtkwa6az9j3rs1grd1suur9jnzgd X-Rspam-User: X-HE-Tag: 1703836785-353849 X-HE-Meta: U2FsdGVkX1+RDbk9Pk5WZ3WlN7txcVJK53RLH6Bfmf+Db/CHfABen2qdTb7O5VyKomecPKUCJr9OoPlyuH/WeRTLX7pRcAXMlGxkmgXs8Ek5E71mtvn2htIOOqUNs0RZZNlJBlAkmcvRCWiL2Mef4IK2Egv32R7azDCuaEPBf4bSZSTcjMtFeqMe37u7WenKLteOqEny0wXkVfJClkva4/FAGHtOoMQmBqDomS7cLktTELgeD1LPQfMXkrl+wdsn/0gSTtflsc/1P8hxC53MdnqiAr3kh6CvfOArZJudqJl0XGco5LgIK9gX8SNDedq1CFPQgdjkVNl8dzT6QIUSgzr+/IwBIZzGs5F73EPXJb6fox+YvC3r10F2Wy2lcGYsZ5nRZq/hghqNJ3HHWApIgObA1JO6mnANXZOQo94lLYcy6xypwNkuBPioCSEPuFibyngg0Uhz5/fDbSgLMQKg8RH8oxMkH46vleRtlb6OEJ9+ED8u8GPxD76ngr15YvxjdvUHfmS6usV5fSKj/lHKBTIv5qf3ebJr2d1VWW5Bynahxy9T46Ii0beyTZOaW7JtYap+q7VksWKUpCjJ4V5uSAsnnC5lFIisJbYgVnQ1KYQrsfjMjjPrcz4YnCOpuLVNOpddHKG33RLpbg/1XWECZMmLTyWEbuax9J05EAzE+KBPRSxY5ShQ5Rx/CY0iE/xQOR/RD2DNKBIarwTHRffa6xTpseT3la0ZZocEktnN8SHzEgaFkM0onSWmveRINAauEKonrHcTmAWgT0b0ZrJeTrRSIJ37SQ2DSW2YISmiSG3DcA+j0GQu3D9VeFhreuCQbsjGgBjC/JRKMFI6e7SyLww66UC5S+CNjvG8la8cop8JdfRAOj4eRbWaf+7qqGj0bCETbWHM4RjcuWdJCpulku+dUFmog+AKjYh3iCx2VOs5vCRQaPRtYDKQ9GR2sf+1fKyvKOPbvIwAuWZSjUY TgM6QTCm lGoMvtp0Uh7hCO5dNOCYOk4BIq4riFeNxKeI4Ze/DO/OcY42kZPsiOmOJWKo3P2NyX3EPlbwMAzSI1Ijd9cdKcbZzIFgaKH9mFcsd3JCc5HUYlgAvapZnLh1/qxPCIgbwEraqKFpE1G/dGE9W22a3FhHtlslJo3tgrZreMsa8ASq4WbiZ2YuzuJRG2xFDVnLVdpgQ 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: The clear and copy of huge gigantic page has converted to use nth_page() to handle the possible discontinuous struct page(SPARSEMEM without VMEMMAP), but not change for the non-gigantic part, fix it too. Signed-off-by: Kefeng Wang --- mm/memory.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 5c757fba8858..173b9b696230 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -6039,7 +6039,7 @@ static int clear_subpage(unsigned long addr, int idx, void *arg) { struct page *page = arg; - clear_user_highpage(page + idx, addr); + clear_user_highpage(nth_page(page, idx), addr); return 0; } @@ -6089,10 +6089,11 @@ struct copy_subpage_arg { static int copy_subpage(unsigned long addr, int idx, void *arg) { struct copy_subpage_arg *copy_arg = arg; + struct page *dst = nth_page(copy_arg->dst, idx); + struct page *src = nth_page(copy_arg->src, idx); - if (copy_mc_user_highpage(copy_arg->dst + idx, copy_arg->src + idx, - addr, copy_arg->vma)) { - memory_failure_queue(page_to_pfn(copy_arg->src + idx), 0); + if (copy_mc_user_highpage(dst, src, addr, copy_arg->vma)) { + memory_failure_queue(page_to_pfn(src), 0); return -EHWPOISON; } return 0;