From patchwork Tue Feb 6 11:21: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: 13547062 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 D2CD1C4828D for ; Tue, 6 Feb 2024 11:22:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA07E6B0087; Tue, 6 Feb 2024 06:21:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 928696B007B; Tue, 6 Feb 2024 06:21:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D2F96B0096; Tue, 6 Feb 2024 06:21:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DF8086B0095 for ; Tue, 6 Feb 2024 06:21:53 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B0548409CE for ; Tue, 6 Feb 2024 11:21:53 +0000 (UTC) X-FDA: 81761139306.06.2AFE761 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf17.hostedemail.com (Postfix) with ESMTP id 5B33D4001F; Tue, 6 Feb 2024 11:21:49 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707218511; a=rsa-sha256; cv=none; b=ZscjJV3i72UG82WSQBGkdjzIBloUgWSYbtISP3eAUGy6SbHSGjulQWzXRoyHDXd9/ygpXs TL7B/3N5zR6I7Cucy0x95DASHwtFLBAPZoEYTRf89OYi5yUuY3Sy9CXNXa3C7fSgYyzt+U s/B4nP3enhsANgWhUhhe3BXH6YuYOK0= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.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=1707218511; 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=iF6MDgF2GbY/72iRE4woHgUFzOKCWCddvElGXSXr1+Y=; b=B/6bwx9ncGlgiErD7NVVpBTw+rPObfMO5EQSTZ44MAOeTGoPiFkx1DRDC1uVK5pud49XL1 +Sg/9PvBXrW+rSFSm2A8Bl+qI5N+eyUMfAnhjY6QNd4oXIrW0DKzVkDDI000RCAynTQQ0L otOgG4bB+3ZWWB/8at4EwckQHCXqB2I= Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4TTglM0YqtzXh8Z; Tue, 6 Feb 2024 19:20:15 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 0644A1400D5; Tue, 6 Feb 2024 19:21:47 +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; Tue, 6 Feb 2024 19:21:46 +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 rfcv2 07/11] mm: add folio_mc_copy() Date: Tue, 6 Feb 2024 19:21:30 +0800 Message-ID: <20240206112134.1479464-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> References: <20240206112134.1479464-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-Server: rspam08 X-Rspamd-Queue-Id: 5B33D4001F X-Stat-Signature: gsujt3x6imi8mbhfycfiup87pytqb8sm X-Rspam-User: X-HE-Tag: 1707218509-914210 X-HE-Meta: U2FsdGVkX192hZMYBE93ldXsVnZ0FCSw2hMLI9h591gykXW8GC7q6NwmmBo+2FG//z77KJeP40Lfiq+5M8mAlGpisnzMqHnUBW8Fl3tU3NZX9iAV8bpWgR/lh/cXgkl/8NqkIRksEzf7n7dGdEIgKCawVgrE/v1sczb0Np8AicyWTPa+ct1tlMDvxhmquZd7GO/t2mdq+ZUJVVPywdVN7uC9ovVEZ/7kaWONmVSg2mShSJgDqnKCt7HLSN+PW3xYtY/WMY+I4po0pSw6jVepZdexpq6w8ApeOvF82HNcjhRrMdSEUHxVBMk8byts5yx7wGLiZv60sVRu2WtOC9xWxAl7WHn6unja2B0e2+txBIL6DzEKLkqT1kBW8RW95SnhFRpbeTT5c/aPx/9V8YiVmzIio41UQrXUmFMXiM6w2hVyil20wodcoePvQZB7kz+BbuzVKDHzrUwVb9Bd6FPH9YF164zamcSjxgexYdZYDdKUQLJoVLe4vgCH8OMr6t1FJy5cb2tt4LZzUrkjknr2TyWDGrbwlyLqgs5uTDUMQ7kXuGmr/XVxYHUMmJQzdhQsfF471G9mv6/UbLfnJXaEO1YMcKRK6Ff+v0nSxHddXe0L26nq6GjMsa++XszzwaFxYZTTKkfGx8gy3dhEoglYoMeYQZHo6+dOHlUWky+5EyoYrBWpccwogTi0tyaCizXa6Th9v9Jq7Lf14XAJAi4lz7VP4UbvVGEAj1dtG0VHC1VyVs+ut/GOIPlczWcOhRttep1T5hXrn0K5qnTPZHjnspFWQXg9CrvgaHUZ8Iwlol6rwhh+HT+Jqzys/LfTLkE7DvgLxZM9PJNCdRSuboYfiYfR1ponl6A3dvXhzU24ySw9fNPsyW3d89vytfMx4Cq/8CcN23HGnuNpaXsBBLnqdqb9gi/FDnO7rcNFa/H1csImW0DF1VfDR7oU0tyvJdjDWFFP/AbODMj2xT1B/eu 4JgjccbP vnIPKvcXe8izJhCJFc3+59qL/OniDfmLeVJVCAXsV1wPT9z6mDAM0KwDIJnqGj2N3DAbr4R2u7DjP1mXHcCHHmHzzbxaBw6qF0rlftNh3nE6u6NIH3x1lXuvBL2Vp3yYftNRGzXFkSa0iSDhlMqUKu0f9+SGbAmDkClz9p1D9hag1rPewcTQVE14D31eHBGYEezpHvjDN3qkorN1MjyrM8MGYLk+5n/PeJXrM 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 68ca71407177..8818aa5a1755 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;