From patchwork Wed Apr 24 13:59:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13641923 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 61D4DC4345F for ; Wed, 24 Apr 2024 14:00:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6C3E8D001D; Wed, 24 Apr 2024 09:59:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A08638D0013; Wed, 24 Apr 2024 09:59:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FC098D0017; Wed, 24 Apr 2024 09:59:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4AA1C8D001F for ; Wed, 24 Apr 2024 09:59:45 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0B0E214036A for ; Wed, 24 Apr 2024 13:59:45 +0000 (UTC) X-FDA: 82044583530.01.FC669DE Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf01.hostedemail.com (Postfix) with ESMTP id EA33E4000A; Wed, 24 Apr 2024 13:59:41 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1713967183; 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=SCexoy3QOIvE9h0oQt70L02W57GetfdhfaowtDPnZ3E=; b=fW/R5WMU259FtVbVBEnpQaLNUNcT/U5yGqSbR6AKn3ggS9/z8XGKHnd8pflrijthvkuO8o 5WKbp3rMVNb5xPciGBsGMfyRs0culBWDauvHWpM3tn252PoTbBXAnlCmnJ8pKZXDIHoRFu 3S6EIPl7dbwgspM9blgsq8zPgrya5C4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713967183; a=rsa-sha256; cv=none; b=zxocv+UdgCWIansSzxD0/YeirSxjuRY5vtFC1h2wlXYhsUm99mIcgpKL0h91SHgcTQPxpm WkgnwXJLij5A4Ix6rp0aLWPhn0mpYeovt0+UMezlGSogw3ev3JFQhMxXJSYT/plLwXr2k+ wK5K8eGakaHOBOuvVTs+0M3+bubvNaA= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VPgWb5tC8zwSJR; Wed, 24 Apr 2024 21:56:27 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id BBADA14011F; Wed, 24 Apr 2024 21:59:38 +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.35; Wed, 24 Apr 2024 21:59:37 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Miaohe Lin , Naoya Horiguchi , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Vishal Moola , Kefeng Wang Subject: [PATCH v2 07/10] mm: add folio_mc_copy() Date: Wed, 24 Apr 2024 21:59:26 +0800 Message-ID: <20240424135929.2847185-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240424135929.2847185-1-wangkefeng.wang@huawei.com> References: <20240424135929.2847185-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-Stat-Signature: wpcfxcko6ep8ccbzmspbci1556jecupo X-Rspamd-Queue-Id: EA33E4000A X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1713967181-758772 X-HE-Meta: U2FsdGVkX18Y4EgZ0nAz1ATpGpbypRBfP1g21GYLUH0lf2mhgWNCwqj2ipxs5PYFL1UcT5IP5hej/3JtuPVSmYgIkq+IjfsQ7Q7zhb0C8f6Js2eUBjLUOipUqZQGmDvzzLkmzc01OrMb1npEBUySxVcbRk8O5UIQmcY6JNiQ6ELUG/nDD1ycAIQnppD9Jjx28Ymt5NsMqp2xue36dxbMJP/sAIIThSupaIl3dPgDTUCViDRXHJNwt3LURxX5YjSlXvWDu9K1W9HVanEiw+GXJvNwwAElOYIcigMZpx4ad9y/yAdEAThb8yLr82f8mmy+Pv5wK5Vig8Cyw8sAfvltulx+gW0T1Y8g5bxeSPE/S4eXo7z+IrhYWCKWIWV+Kxp8hUE6msFbQ9w3fDyeddjZreEfA9i7WTCV4dUMUxoU+Ox1g2FQw26ellttQXdNuNw3yS9Xxw1VMeHCfuLTOQb6j04k3blDm5L1czc4DmWmvdt45JRQTViBnxqotz30tUcFIrEJAXRHRHdyhQBHt0wNkYxZtJrBlkbUuHJCN6+wGyCCRIOsKiF4FkqqSNUKbiF8/kdHIhUJNxtq5HdlX4gj4C+4hO2auYLGwiuMn/2ZQlST8W2W5NMlZOoxoEztmC7w0Ek1CM3jBTF/FL/Mbyo/FE9jgZVa6KZOoqXx46OaIrFxO1X8TGoPXnFq9reGhzV8dOueGeWkyNivQ4TgsTQHff5mlJuJ/4GA8rGVnF4BMt2esB7Jqcx2+et1yl/2hG5DDqJ1o7i45i0sK9DIVNX/teqJNCwQcQ2BdGiXl9NFkHp8MTgz8DcS57yVCqeiTYqy+kKaQ5wVcLvwHZ5OSllGk3FcDOQwkXv6qNa63/AMeDpDsl0K08gfbmy1EGYnpUyk8MA8FFypC3Bmvu4gNsu7A8K+R9UKP2FwJ5nhvWnyR7T+luL7gCrh6iDmEs+5viaR86+JWSWm49vde0obd83 6eLbzo4s 7qRF/gH3hmzfIJ2QtcOKeMnUPDD3aIqPT3AubcNW5CXeuSw0EwYF5kGsZCUvzcO/zePTOpQu0PtSCSWoD60wCXsw6OgNJSVLPSQOTUXjINqRUH1toLtowPzOjN83RYm7e929anrmYb303HL4Dh08lkm7FM21RiNJ/nju8Jjf5qGis0Y1QCG+ZsgB10RZ8kMJr0k36Xtnhs1SpQ0A3ayfzjEFpdjOkyiwA/DEXQ7aqK9NL9fq+Xn1JDpz9AfZzYJLby4Q7CRj4SSdabj4= 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 variant of folio_copy() which use copy_mc_highpage() to support machine check safe copy when folio copy. Signed-off-by: Kefeng Wang --- include/linux/mm.h | 1 + mm/util.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 326a4ce0cff8..89bbb2064a97 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1317,6 +1317,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..9462dbf7ce02 100644 --- a/mm/util.c +++ b/mm/util.c @@ -828,6 +828,26 @@ 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; + int ret = 0; + + for (;;) { + if (copy_mc_highpage(folio_page(dst, i), folio_page(src, i))) { + ret = -EFAULT; + break; + } + if (++i == nr) + break; + cond_resched(); + } + + return ret; +} +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;