From patchwork Mon Jan 29 07:09:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13535066 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 638ECC47422 for ; Mon, 29 Jan 2024 07:10:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CD936B0095; Mon, 29 Jan 2024 02:10:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F1CC76B009B; Mon, 29 Jan 2024 02:10:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD32C6B0098; Mon, 29 Jan 2024 02:10:01 -0500 (EST) 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 ABC3C6B009B for ; Mon, 29 Jan 2024 02:10:01 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7B1B11A030E for ; Mon, 29 Jan 2024 07:10:01 +0000 (UTC) X-FDA: 81731474202.03.45EEC57 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf07.hostedemail.com (Postfix) with ESMTP id B6D054000E; Mon, 29 Jan 2024 07:09:57 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.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=1706512199; 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=xgsxhf5sjocA88FA6d4ppu3Kj0tKOqf0r0HmqGCZCng=; b=bOPIOe7jVWsQoL+xBUnFmVeRBObyhkGtsyvnEklL/4b/P6VPaIVfejcTbDTWGmqILfAnoW trFJ2vWMOgeCDdAgytayTHKrQ8X3neJ9dVUEpdd3UsqXWDJ6ryVk8dNTWRjtUdsDQpY4Va SBRClOU0YsTwEdukw8oPlkmLDcW3w+k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706512199; a=rsa-sha256; cv=none; b=n1/NrGXzqyDqMDTPFiRMweZp+NhggbRNVrQJDFMl1v8Lrg0bLaqHUxxlxmz27R5pGiUQ4V PtjBm6gC8NXbk5bk08x5dWlzgeHvNJFXGCmOg+tRfawHXgoXqvgq5l/bxa6UTiw4XcJwFB mEwxmiarpOxdtZ2fIiW0tDR3Jews1zY= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.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 Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TNfSy54GRz1FJfX; Mon, 29 Jan 2024 15:05:22 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 757FE140336; Mon, 29 Jan 2024 15:09:49 +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.35; Mon, 29 Jan 2024 15:09:48 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Kefeng Wang Subject: [PATCH rfc 5/9] mm: add folio_mc_copy() Date: Mon, 29 Jan 2024 15:09:30 +0800 Message-ID: <20240129070934.3717659-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240129070934.3717659-1-wangkefeng.wang@huawei.com> References: <20240129070934.3717659-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: B6D054000E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: c5efb1pcd3zk3qtymbb3fkamrreedcus X-HE-Tag: 1706512197-194447 X-HE-Meta: U2FsdGVkX1/TEocCTWPwyME4ivmCYiRuObmbpKUb21sV5J10VnBhz/228Tr27ZIPyLYp4qCsXqEG4MGF/+FZS2p+uJacposocbcBEaUNlfV0Q7zgxeqsxSYDyzAmZeMpAo2qajqtygxNAABqNCSsTnKSM1QoXZMLHNXllQ/kcCb7jsLOzxppRdAJvnVP2TeiKoSBe93eAzFdwR42KKsgkRuZOhG1wlU/LScE8t8YP/9J8ah6dmXrwMVSyaFqqsLMP0mq33poZp7+e3bawK4Tma1ve+F4sAamORbV6TXcPwQqkcHFhp3EYGrLY/IOw128Q8hpbgTlOJ4w9yGzm8/iZ7xdm2JiBJCiA4ISfOAPFMOf4EZNohU3fw7T+Kckd7nQAYm4l+6LF3Xy7IOzIBgPPaoqkEhX2Fa9Y1c2Pbfm7sBYSmrA+0sY38FQX82codbuYoerblRqzVBEEr/y7wDM9uEwH5/x3QzC1zr/fZAQNGVdvuG7AokrVW1lSRKsi+4jKIc/1VOcct1wRBfYXn1DRLZDXdBCMPgq0nkoZhX9/DbRRsA8elBTvmaMIIpzTcZt0uIEIddlWM1eHvyhBuqSDbJBhjNAfZHIkp9iI//FDC6+KqovlrbgmAB3WMjyjryBgV0i6Wwfl7UldlGeHBQXQm211Z7zBMxjEIYcCGwMFNb63MAQpHz03kzGLpVCFLjyNilo5S4UBZPMAqcGV1XgzBIPeGkZoyCR0mxbs/jL3AUxIozXi06rEb80mqB3pIC+7hM9VMLfE9xufCBN7YGfaikPqgmWFE8OvJlXscoe3bWPQrVfOD61sr4IZMlZVU6DnU4eraUkIGjFon/1LECc9wDPuOEixJjbYbGJoPq2bEN17YMWAwM3cheATbFnOWmoGK1jdl39eC1h/+wPpNCF3PGjkRt8e9ZO7WDDHqov9EcJJ9O5QKOXLcUNzevrlAX0DHkLlzCr6gkepQD+NUe 67IrT898 bAGkbzTBLJdI+9PbiyABunccztU/SbqGPfEOyyckxydoGgV3ATTygV0VdXRb54VmJWwt3dg5zHII7dQJ7031Ta0+g9UUDrWOS0rDStWXDP9knnVUTzaVZX21WoQi0c+PECuB69e1EDVfKU98eqSlLf/RRE7JGKEbWpSBJaTktees9RGsfvzS8iAaqroeXU/99xfu4 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 ac6b71cbdffb..fffa6025d8f9 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1300,6 +1300,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 5faf3adc6f43..63e6e644eb5a 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;