From patchwork Wed Jun 26 08:53:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13712426 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 3E368C30659 for ; Wed, 26 Jun 2024 08:54:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D10106B0089; Wed, 26 Jun 2024 04:54:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC02F6B008A; Wed, 26 Jun 2024 04:54:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B86D46B008C; Wed, 26 Jun 2024 04:54:43 -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 805856B008A for ; Wed, 26 Jun 2024 04:54:43 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3E99C160A4B for ; Wed, 26 Jun 2024 08:54:43 +0000 (UTC) X-FDA: 82272429246.21.F869781 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf25.hostedemail.com (Postfix) with ESMTP id 90E9CA001C; Wed, 26 Jun 2024 08:54:40 +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.188 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=1719392063; 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=MWVDevXksDIwh0FjeHi66IxAYHx+RIoPPrdEHW5AufM=; b=TMmqvHDzqqfqZhYQG3m8NKcBtWBitH0sv4sWgjjempb8v+jJWyZkijp8z2XtRSEPSQOhfg URZgx0+VGcyc7Zn0opzpMxEgYVofOGW73Hml7KZN7Fsqkljazql9gIE21TZwaTmZNw3NBa qRegHmNeRPJE64xH2k4+tXNmX5emKc0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719392063; a=rsa-sha256; cv=none; b=5ohyFlUmKhMWOREfyk09huSBjZtl1jbWGGceqlANW2MLNTyk9/bmjsH8A+B1d66B1u5pze OEiSK7WxWfw43Uj15Apruc3TNAg0tObtUK4u+e/hqmAnpPM8c1Dg7Dx9K7bfCvjWPE3+zE XCoSX4FreqUJ5Z/NOvPoaQqA3Cxa86M= 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.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4W8FpR0GbvzddvZ; Wed, 26 Jun 2024 16:53:03 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id DF18E1402D0; Wed, 26 Jun 2024 16:54:36 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 26 Jun 2024 16:54:36 +0800 From: Kefeng Wang To: , CC: Tony Luck , Miaohe Lin , , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , Jiaqi Yan , Hugh Dickins , Vishal Moola , Alistair Popple , Jane Chu , Oscar Salvador , Lance Yang , Kefeng Wang Subject: [PATCH v5 2/6] mm: add folio_mc_copy() Date: Wed, 26 Jun 2024 16:53:24 +0800 Message-ID: <20240626085328.608006-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240626085328.608006-1-wangkefeng.wang@huawei.com> References: <20240626085328.608006-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 dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 90E9CA001C X-Stat-Signature: zbc4xgw4w31x1epuhzrt7swawx8obeie X-Rspam-User: X-HE-Tag: 1719392080-264884 X-HE-Meta: U2FsdGVkX193zDLaoHWmxlqflEadULVX+dPr7effLT5pkaV5nzMcDkGvho0mu9AekKkoB7KCH5Rv/TTNUfkS6y0L7uEAYj+14O3h/5Q7YK+4hsq9ThnkrDsGsLBatBOVuoYCfJrCKSLBu4yM06Q92e0dcEaWdYt3tfRbPd9Y11ZLc8tZd+WQH9Y8/LzzPhTN5iddtAszItQ/Pk4/CNNV7NbNQD92PsED6vHnVsyWc2E2IYJrI6IVyvL657JX8vn18T/aUxKbSCtH7+dRNbkBwtg8IaMvBtMYvpMWXYM+hvsDphgA5YlMjRyWI42Rml7fzHggcrXmKNh10wofPX8qBE3u0P3ZAhWGqYttkpMKiEKI3SGRH32MMm8K5VqFx5k+qZJjBC05Kgp51+TqeK5OUDRQKBabH35Oi03vfCNVw9EjE38o11MPhl/NgIpHSYhOrcsbunfCj52JN1iVJG1cPICZtdvD493oosyU4P+hTvPBw5eEoiMIFPjxRjU0d/Ddf4sCC12hg7LP3HdLqcu7Lc3iCOjj+mJaOUylA9HEvEnojslJ2cw156hP0X7hqt+hkTST+OQUQKzY1GbJu/URICECwU3AcN73hQT80wSovCjSvidhqDlM+R/09aPYF4MxCZyYtFx9HEEG6NtnRgpoi3vf8Fbk9pgRbBKFJp+DM4CzREqtv4hDztvcOyvkXGambk/qbJQ3kSlegVdkbH/A9FzihcJ1fvWUSRkOJbnkNj6RIaD026saSIf9JQ6kSzU3OfLs4whq6M1wv6RRX3l2hVA8kzFC7OBkjTkm/h5x4TXu01WXDube0qCW6cV7ABVGNJL4Ox9T2N+1mGnixnY840EK6SVZOxU863XIXUOKLvkvzF5OB+ouoRgHhuf1CbebtJQYyvNpkPU2APNXDwVA3bJp4cQk4UuLl9g0cywHVDNmfyvUwaGSkK3uB1EtTACe0WnkFQcZG+8OjxQR3D7 /2RmyDPz n2qp4ktBCQlCihpCC//CWxxm71XZj56gOL7U8R5yLBOKdG4aNc1oFt3pnVWtt9FkjNOciclTQNtd7ag7AGx94L6YdNUwSrGgcdNQCMNOxVfvtjiXfxwi1SDARi3UGaEBiVYmRF/WlBb44gxPMu95YlbUjgg/VW70Zzq7eykdnCY2jAEYbEausaBFtmVebLqMuRL3aOdnsGPXkpCYFBE/Lh4IpUh+ctZg6w7537mvj4E5ainQaxWcI1dM1oibi374Ku/PrnLihHH0Lh+Qmp8U8dSM8oS16/T3QUc9T 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: Add a #MC variant of folio_copy() which uses copy_mc_highpage() to support #MC handled during folio copy, it will be used in folio migration soon. Reviewed-by: Jane Chu Reviewed-by: Miaohe Lin Signed-off-by: Kefeng Wang --- include/linux/mm.h | 1 + mm/util.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index fc07b5c6fa6b..60f42daf3be8 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1301,6 +1301,7 @@ void put_pages_list(struct list_head *pages); void split_page(struct page *page, unsigned int order); void folio_copy(struct folio *dst, struct folio *src); +int folio_mc_copy(struct folio *dst, struct folio *src); unsigned long nr_free_buffer_pages(void); diff --git a/mm/util.c b/mm/util.c index 1796bf46db17..10f215985fe5 100644 --- a/mm/util.c +++ b/mm/util.c @@ -831,6 +831,23 @@ void folio_copy(struct folio *dst, struct folio *src) } EXPORT_SYMBOL(folio_copy); +int folio_mc_copy(struct folio *dst, struct folio *src) +{ + long nr = folio_nr_pages(src); + long i = 0; + + for (;;) { + if (copy_mc_highpage(folio_page(dst, i), folio_page(src, i))) + return -EHWPOISON; + if (++i == nr) + break; + cond_resched(); + } + + return 0; +} +EXPORT_SYMBOL(folio_mc_copy); + int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; int sysctl_overcommit_ratio __read_mostly = 50; unsigned long sysctl_overcommit_kbytes __read_mostly;