From patchwork Mon Jun 3 09:24:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13683601 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 09E0AC25B76 for ; Mon, 3 Jun 2024 10:46:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7078A6B009C; Mon, 3 Jun 2024 06:46:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F0756B00A0; Mon, 3 Jun 2024 06:46:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 328076B009A; Mon, 3 Jun 2024 06:46:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 128006B0095 for ; Mon, 3 Jun 2024 06:46:09 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9C4491C15B5 for ; Mon, 3 Jun 2024 10:46:08 +0000 (UTC) X-FDA: 82189247616.15.1CCB6E6 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf08.hostedemail.com (Postfix) with ESMTP id CE500160005; Mon, 3 Jun 2024 10:46:05 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717411566; a=rsa-sha256; cv=none; b=nunD6SWzeg9vNi66WNQdnFOzCLQ3rsNlrPxRrkKZTCxdxTj4dvVj/kDeUONq/4QTdCFzDD 1Yu5P+9o37UD+l9WlPmISaIZZAAAilkQdZmyv3XvZTmbfKr6GYcPVjzUtMqjkF24nIq6W1 Qaa96cA1RsuyTLbOfWI+8HFgkp+AOY8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717411566; 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=zb1QdBy78P5/D4Zv5f0vFADJA8vdcgU0jUJCMqW60/A=; b=2PWyW94WNjIbrd0DnrjL1F/p+6bv+2ljgVlkhCE14mIXn0vnOstgqYNLvIdnOScGRymjEs 4jBLEuRa+a0WDdgquAj75sOTUQXFVmhOofALv0t36t81wiel7Ti/bFI3jcpCODfoAyezX9 UEG+g0USUVkm7Z+IWwxSag4Z92BKp1s= Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Vt9K852LPz355Z4; Mon, 3 Jun 2024 18:42:20 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 259391A016C; Mon, 3 Jun 2024 18:46:00 +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_256_GCM_SHA384) id 15.1.2507.39; Mon, 3 Jun 2024 18:45:59 +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 v4 2/6] mm: add folio_mc_copy() Date: Mon, 3 Jun 2024 17:24:35 +0800 Message-ID: <20240603092439.3360652-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240603092439.3360652-1-wangkefeng.wang@huawei.com> References: <20240603092439.3360652-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: CE500160005 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: ia3iwd8prn83xmrsbfnxjkacuaj896ye X-HE-Tag: 1717411565-294039 X-HE-Meta: U2FsdGVkX19E+8KMM6bo9EcF5N4YPDV7jrl3Oc63aLN7WnA3fn3iGSzyP8MurkmbSS36d/ghQy4ZglmqXm5FaerwFC+y4BlqBTO026od4n2XLjZ+kVPZROHZgx3cGDkt/IIP0QETOLEuTZIzJVfxupReDSwLpfwcYeUFyP1uDBcAi1CAEq2SQXifZSvsaih5sw7YWr0ppQH0AuZXzRu4qPmX66S+a/VDEU1GkYVE6zPR6CBTecbKxxorlCS5NBA75i2OZr1U33UJ4LPyBq5xbAuGsirUGM5hP3fYT3blPtLX6/l/90KcskZqwlJqRiVTAk1TuVwOnNPRtViTKM4emOpTFVNTt6KIOANKziXBC6bIxxpahCj2kcnWe+xzOlhl8LdHFr+9EMURshOkGrbtvG4y2keXJby56lPj7iTNhVh2BMrTOBsMIji7Q9dEVi3eqBQK9yAmjwcnqgKaNVeZnnQTi+HQULyxNkyjAQzfAV5376LjhBmqQqv4N2NgRGlcYpwOcK8SqJcvwsETRoC99EgPvi18NklPGs4MK+W78jg4rrlFPeD1dW6AsiCcBV7o02PumVwdziDGY1FOmBT0Yd1q7tV4UhuH17WXWVK7UDvVJxIOAKNTneDST8fG/SVlcjChTIEu6RvGLulW+GTfO4sA0Jgk+3+dLotkzD97ApoOFeOj6q9Z8+ebyF4KSWYeGLczZF15dZJ9Zvy3Di0YFYTIYfUrs+Xl9OAvNOKwAV5wwRFDdJtqz05WcJTMJHAwFcjle9V6vAGICWorIj2p7CrBdtg2sH4P5alugQOE16VB/9qOrq6VMTtXwML7w7J6Cl9jwp6+yUtmFXkYK+jwn61DuBm00YI9Oa/+Y16BAf5Zu1wxtyDgWRbg8GOrGO5r0uaoha/SBjMZFgFFC+JeprZfVPIo5Okh2MabO9QLa+1urER4KiKXs6r2lmQHn4GONOGPNa/fISqXF0EkG5r 7POt+Sda LqLgHpQFD6EqIJnDVh/JsEEQ2AE+Y5jkkEHF6nOhr5vmpQgYPvH7xG7JW6NESYHcj6jAIO2fiObRZuARaJQmszz/CxOSezjGD5jfFeV1H2qBUrrg8mvutLbUdqtXJBemFJdBnpfi5j7fBdOFevjaCshgsrFkv/YLhi1I2TQc2wMchVzfR2YuwNq0cnUgoFE6BvQ1TkmEPqhF8WQWTMmhz87ntRs6XLnmoqsrbHhqaTsxdh1K8mJmsJg7dhjltnWA5kesS9PbKACAE74o= 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. Signed-off-by: Kefeng Wang Reviewed-by: Jane Chu Reviewed-by: Miaohe Lin --- 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 c499d5adb748..cc21b2f0cdf8 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1321,6 +1321,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 c9e519e6811f..90ea0c0f10d3 100644 --- a/mm/util.c +++ b/mm/util.c @@ -828,6 +828,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;