From patchwork Thu Mar 21 03:27:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13598368 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 284CCC54E58 for ; Thu, 21 Mar 2024 03:29:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB8BE6B009E; Wed, 20 Mar 2024 23:28:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C27A66B00A3; Wed, 20 Mar 2024 23:28:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F1D46B009E; Wed, 20 Mar 2024 23:28:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4C8496B00A2 for ; Wed, 20 Mar 2024 23:28:59 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id ECF75121542 for ; Thu, 21 Mar 2024 03:28:58 +0000 (UTC) X-FDA: 81919614756.07.0AD7472 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf05.hostedemail.com (Postfix) with ESMTP id D4E04100009; Thu, 21 Mar 2024 03:28:55 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1710991737; 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=WAp9l1SynGAVFxR2Mu9+GL/AxCEm7zrX917MWkYFaNA=; b=KlRC7++wmXj+sIIGy8RGHsHVeQGLIwQAZxVhEzF6y/1JX1Av+Nj499R6ADvZs7lhyUsh2S LJDjfHkBVZpT3WgNMdib8TLqzJfGKBZMPuiTmv212p6s8Y6xQAnwrLE/5Blg3qOyeIfnnr QqUMRJkyooKVMT7R623LHd8w7fx1J4g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710991737; a=rsa-sha256; cv=none; b=hyHXE3MTbdoglJeb4eNyPsE/SjLMwCJX4cmJS/VT+OgxNyfwl0IDOFYw8Xm2E/ruXYThMg eSNT8ZKiJxhKhO4P20ca8TqTR2Z39WqKcu42hk+gXAR0r40yIMI/J6gUD+ZR2SgAaYMJsP HWrMr5EkdyiD+YQP4/aTXlY0VQo3Drs= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4V0W8z1R7Qz1xs0W; Thu, 21 Mar 2024 11:26:59 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id CCADA1400CB; Thu, 21 Mar 2024 11:28:52 +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; Thu, 21 Mar 2024 11:28:52 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Kefeng Wang Subject: [PATCH v1 07/11] mm: add folio_mc_copy() Date: Thu, 21 Mar 2024 11:27:43 +0800 Message-ID: <20240321032747.87694-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240321032747.87694-1-wangkefeng.wang@huawei.com> References: <20240321032747.87694-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Stat-Signature: ggtisbex1h7myo7ickmckcf6iorwie57 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: D4E04100009 X-Rspam-User: X-HE-Tag: 1710991735-610360 X-HE-Meta: U2FsdGVkX18jnarXEQA0boFK5hWAUz6YNRkjlIONkZr8aCgf8MQlUJ+f6JlSxj19Blp512kqeIIVrZOzcD+wD+URBOloR5rH3S5ZvMLRsZiPzPEzIqZoJ5bH8uzU2R27xbwdgPSkz22ouM0HTIVcGtp5rNkXe2CrCQKjgn3ZmWCkK5lW/WkFajrEBz0SbnmDFej93tSUqwiLXCN1Trhg+v5mC6k2rBFAsfI2pcWZAclft57fRXjK4W8Qii6KPMx7RMDN5UyXjpKrIQlQFPgkLs3oXyTJPyUrZ4AUaDi6zMu+qAhgs4BO8Bu4qONu8jovtgVibkHKY7e+1C+j8uAUyWWjg8YhcqxhGJzZ62lpNwyGfYjKrTvgONR3jRtW3DlPgkogBc0h6cKClIaErAtGpYuSLUJZXzLWE95B+Sin4db82LBull3SPCFBuEkTM1lkgNd00KS//dUeMA03waObsz4rOTx35scuJ3A7gwf0XWwN6iyzmDcv7CTC/lHW81/BOkQNO/twtJMr2VzLXTHH7y3Fa6GiidEt2+QNyJdKkqhk67S2ecW+md/0/vpO9S7lNt21G7ko+vAZ6tPzWmMdkasY6jKdYx9oLL2+IDffTKGiKA2xYbEkvnulrMedB83PicHksxaKOnjhC2ZVtF5SQwQJlXP5evE4D131N7pYBE2b5fsbhYhFwzZwbb9MVsPlqCfHBJrCf5My5DTTJ72xjgskEnJS5wDBNf6GHodKdiwnORl1Nqs9DhiuSt0rAZ/IsphoE5ICXez77V3Oy4cV5B1iFpUH95CbKXzVuc6Xmcc1nVwQFv552R2bdzbpefhGXVHnh+3EkKGaNWNQ9d+goeD77r8zdDQdtXAG7V9teX4sim0J8hEPSKWyTp8b+ctr1PEgywfpJd8= 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 0436b919f1c7..bd1bc29c38e2 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1312,6 +1312,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 669397235787..b186d84b28b6 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;