From patchwork Tue May 28 13:45:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13676755 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 D9D1DC25B78 for ; Tue, 28 May 2024 13:45:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 717BE6B008C; Tue, 28 May 2024 09:45:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C6716B0095; Tue, 28 May 2024 09:45:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5661E6B0098; Tue, 28 May 2024 09:45:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2F23A6B008C for ; Tue, 28 May 2024 09:45:24 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D5DD9A36EF for ; Tue, 28 May 2024 13:45:23 +0000 (UTC) X-FDA: 82167926526.05.2D52266 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf28.hostedemail.com (Postfix) with ESMTP id 1B24AC000D; Tue, 28 May 2024 13:45:20 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1716903921; 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=7CyCxgFL5sWsE6YxjtmjcFxTknfzj8Tyb+DRwDQBFwo=; b=26jkmu3RTkR8ao3IyoTBno+ZaJXKRhVD5tU3S8TCkN/E3+JCf8U+d9jQSjHK8W/0Tj8/CK H+1MSfvJ5eLg0XP8dR6XMIC6kBMm5aRdBfScptuNl3jLYkEHf+hu8bfjAgmZQL3lO+6JH/ hh/fSZQiLnWuYDY+5bV/8yg4eQ3hC88= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716903922; a=rsa-sha256; cv=none; b=kXadptQKZuQJd4JU3WIHkCk1oxDwELTLx16sKKWeBSk85pq4cbWOu8NrCfycEUpokxxZ4g 4oVloqQ5nfV1pZ6LHOGI0k1xos45XrODODtc2vgdgIWKhD6a/SMZcYKHeQc/zwDMSkAmQN r6DxQ6bppCVqn3U9zu/tN2qBzcFtgDA= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VpYdS6mn6zckSf; Tue, 28 May 2024 21:43:56 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 65FB018006E; Tue, 28 May 2024 21:45:17 +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; Tue, 28 May 2024 21:45:16 +0800 From: Kefeng Wang To: , CC: Tony Luck , Miaohe Lin , , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , Zi Yan , Jiaqi Yan , Hugh Dickins , Vishal Moola , Alistair Popple , Jane Chu , Oscar Salvador , Kefeng Wang Subject: [PATCH v3 1/5] mm: add folio_mc_copy() Date: Tue, 28 May 2024 21:45:09 +0800 Message-ID: <20240528134513.2283548-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240528134513.2283548-1-wangkefeng.wang@huawei.com> References: <20240528134513.2283548-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-Rspam-User: X-Stat-Signature: oaph3nruguujyd19ukazk8aptq6wwsy4 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1B24AC000D X-HE-Tag: 1716903920-256434 X-HE-Meta: U2FsdGVkX1+QS90wC7pEozpsi2Ze2mXTs4qZ+G6ePSM8XD0MoCl+AT0aAaDBEGMJ4r5rUdSYzkDoOE5dw9ETUBp8W89kvAVgh4yisGWTHrJBRU9ZmDZ0UQO1K2ki5m9yHTYiHfOWdU0yHV22Y3CH2uiaqrqmpJrvXj8QaPq3YBJlvcW6UBzAkAZK42pQRTSDJu0yZ2QqwEhL6ZtK/xZD8CAVi86bfVNwvHfJSxHnLQoDmJwd+oa9GkaSQ2Wa1wbIdPFQtSrD4PHc1LkQUQyrBJLw2Tg8K7eZJwRf+jZW+5HgLbg7vuVpl8Cs5WVbSpVGPHlZUukdYbdmmrHlAW9djNVVRkeqEkkEwyJGclyuU+xrC8bKk7npH+x63BQyUl45CP06t+1XeQx4pA/Lr85mI/4Kb4qFemiZi0gtrd8MHRabPAs2vd9rj4+hsWa8SAW1mL/O5LAzrknDVxU6jEZGLE2JnVjyq673DeoyktfW9ykHgHOJSJmJsOfgA/CP1ig0sQIea3KWmNDPrRmYOGCJ08rai99ZCWf7EfOpmHeNdsqqGrsV88tVEf4oZWzakz+P93xUlrHXwQHZ+ZxjMRysNkw6vjTdFhLAjzJ5u2QVNJtPBmyIwyC7aW7VGxhArp4l7zSPTC7aIwW35vJCu24LEgYYPqa1l/okKtJj17wLDsGygrbarGChg4dbYONaYwTAllkTZ8/pZ3aaDyXFK18iaHykhaaQAf7S29PGWh/m4Nm0BXU6+Hk9Q2uxm0sN8nDzzQFyNDXByLtimoCdLn8Y8j36lFxzYmVqgUCZId4x3iYWOUnKe0BIFQ2MYY3ua1DsK5bh50IdrNxfkO//kygYgQvcCOs9pOR/3fFeBwXht4/7X7O2EknjEkwPiUaDnHmHEYplH/mUxRMBMAa/6sGK7cquOd/2ekBY1U+7q4wjrxQg8htuGguILsruf1fmrYGehftpPbViUC85T0rqkdI diqpdAC9 B31Kvl/2tIggoUM/MG/9D9i3HYmUYY08umNEFWcbAxQIb3HXibEW3ijUeq+Y7JpYAjRQiNZShvboIYhpZ7QnSagcoAux7C8WW9dV1kQzGrBcp8mkwNQF6P/CpFoe6gE8QWUZiYLCeoHRSHFmgmxxSoAM7XbFpjPoVBC6UelNsaWMqSh1/65gG+RC6EN9Ww+X+0QhAPjuaL97qCalILcckGEOZnm4j3WmKrwl3VaEoCGoGzj6M39qMuA6/0p8toiSCkXfX9AbD9QmBels= 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 --- 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 12bf20ebae5a..0c78d67f787d 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..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; From patchwork Tue May 28 13:45:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13676758 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 345FCC25B7C for ; Tue, 28 May 2024 13:45:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C6EE6B009A; Tue, 28 May 2024 09:45:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74AD26B009C; Tue, 28 May 2024 09:45:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5904A6B009A; Tue, 28 May 2024 09:45:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3294F6B0098 for ; Tue, 28 May 2024 09:45:26 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id AE9341416E2 for ; Tue, 28 May 2024 13:45:24 +0000 (UTC) X-FDA: 82167926568.19.B79E46B Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf09.hostedemail.com (Postfix) with ESMTP id 952D3140021; Tue, 28 May 2024 13:45:21 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1716903922; 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=NIlQH8BolWvIKyx3dCT2okUV2IPP2oITPYQWwW2wQYQ=; b=WZ67bLbZ1kMw3McHOCICd8IZXqdaKg5I/ZMWKbv2NxRaWuK5XNIbQnDIfVC5pXPEaw8dpJ kJC5qZvaM8A4mVfSDMqnJfkslOGpDMY6xBJwRBN/4iBav8L4sMDq/R2vuHRTmSc8JA5wBy hHdm8ubOugeJAnxQCJp7JsQFU4FN3IY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716903922; a=rsa-sha256; cv=none; b=0lC6cqyULRwQIYJkyQ/GDJ5y71xPTxPcku67hMIUPCGCDMf1w4YJba0fKQyrYtYoe/MXG4 XoFJuVXwcByHL95+66DyXQ1FwXe848VwZMyjcKa9C+Uu7F3ezc8+J8iiO5o3okaUod3Wmc dStGBdgGzq82ExoRFBm59HlI0qBTcNc= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VpYZh0Dctz1S8DC; Tue, 28 May 2024 21:41:32 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 25AEF14037F; Tue, 28 May 2024 21:45:18 +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; Tue, 28 May 2024 21:45:17 +0800 From: Kefeng Wang To: , CC: Tony Luck , Miaohe Lin , , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , Zi Yan , Jiaqi Yan , Hugh Dickins , Vishal Moola , Alistair Popple , Jane Chu , Oscar Salvador , Kefeng Wang Subject: [PATCH v3 2/5] mm: migrate: split folio_migrate_mapping() Date: Tue, 28 May 2024 21:45:10 +0800 Message-ID: <20240528134513.2283548-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240528134513.2283548-1-wangkefeng.wang@huawei.com> References: <20240528134513.2283548-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: pp5941ws49yqpz9mos8srrwcdr4me6wh X-Rspamd-Queue-Id: 952D3140021 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1716903921-897572 X-HE-Meta: U2FsdGVkX180BBDFfut+nTfdjX5jsyKzv2r5jscm58ULzzHKrqtFuzgru80irjFD7d9LomIStAEH2jNEGibWfxw7TMOfTf7Dw1CL7F76Q4TJ+x4x75Mfpaw8ZOq5vDQ6uScFNwIGGHdc9Cyn+iNJ4lf1lqD5JMEr0h0GmxnNcCrxIQgGuCwrnYg1Tz+A6sxSdO92/xN/EGTv3hEOC3PtncKjEICOcwy97ubPo3bOBX8BCDWuNfrsvRqNXvJSYU7Sd60EjbOenc9oA4b7Ck2inJlDr3OCXjBd8L70I7j6OLjIcIzaAvf1P2rCHgBTDC0fEeMJC+YNM6BxsHLZeZ09Uy7mFyhK5hB5e/TXgzLjipUXc9ZXXA7S+GeMD4IQ9mmpTEGoBLVeEPcvAWOZf5aeUD7IKE0YeyVWCK6CV644bDaEeu/cPXVZGpMOTtdzAKccJzwSSXe7uUkXRghYC2+elRbixqsJfnjdrbVyDlNj9Xb4k7EuGFHHJidre8mfAAfjlMvGewQ939wM8eh3Z7HWwFZSbsMCXpUux0d58XDH4nBrKajjyZxmgACu+vCcRiQYGWL8VdbAgUHTuWZGinRI61v8/QOFeKzQKofODjTZGIiBnMKlYbvT09QyxBne/tAvsM6US4njfoSwE5FX7MPVTRKycuHB9mpWVq4zXmXFYz4PRobl2KrK1XnckujoV3xrdnUEkyWR06IpzhYO0eEn2HXPZH1MCU0XBn0f6Js1V6ubulF8C5qKxD9YTfEg0wt0uOMWgZRDqMIkWHCUi+xQoJPft3LXo7wH6fgKfqfkMG9JrTg4EeOK8aAQGG+dHwLmG0D4MDq9CmoinUhyqx2igGyFTwJHInajB42FncjCIxyg5HDU9lwN5noOmsXGvrq/79CzhxYxG+/mAmjdU7jucsc+8gxS0CzLT0ER+dtItf/SFUrSO4TBScZQKI2C7pZuB772FwuIATghQ+r8Nqt KSiH7EPL hrP/6trI6aXbFPT/LLRzcErAKTscmTq5cCv7wp/EJyoSS4ulpeC7cgPdchsE8+PCj7ppu56BY9slJyb+V926ALwHcDFReqnQiA7K0PI0/g4hG2BzAGjr890X1xeDmEyNZXbDTfCl6v5mXPUprRwHgHkjELZy1cv+ACUwmvACjnjLe4kHrodzdo0wUNXiOn1Bm9f7mD4c6Gzlcgj+reXuLRhXNKXslBECZIYz4BMAQUGY6VF74In0bPPWtO7hHzgFTvOG/lXzFRgKXA9c= 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: The folio refcount check for !mapping and folio_ref_freeze() for mapping are moved out of the orignal folio_migrate_mapping(), and there is no turning back for the new __folio_migrate_mapping(), also update comment from page to folio. Note, the folio_ref_freeze() is moved out of xas_lock_irq(), Since the folio is already isolated and locked during migration, so suppose that there is no functional change. Signed-off-by: Kefeng Wang --- mm/migrate.c | 63 ++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index e04b451c4289..e930376c261a 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -393,50 +393,36 @@ static int folio_expected_refs(struct address_space *mapping, } /* - * Replace the page in the mapping. + * Replace the folio in the mapping. * * The number of remaining references must be: - * 1 for anonymous pages without a mapping - * 2 for pages with a mapping - * 3 for pages with a mapping and PagePrivate/PagePrivate2 set. + * 1 for anonymous folios without a mapping + * 2 for folios with a mapping + * 3 for folios with a mapping and PagePrivate/PagePrivate2 set. */ -int folio_migrate_mapping(struct address_space *mapping, - struct folio *newfolio, struct folio *folio, int extra_count) +static void __folio_migrate_mapping(struct address_space *mapping, + struct folio *newfolio, struct folio *folio, int expected_cnt) { XA_STATE(xas, &mapping->i_pages, folio_index(folio)); struct zone *oldzone, *newzone; - int dirty; - int expected_count = folio_expected_refs(mapping, folio) + extra_count; long nr = folio_nr_pages(folio); long entries, i; + int dirty; if (!mapping) { - /* Anonymous page without mapping */ - if (folio_ref_count(folio) != expected_count) - return -EAGAIN; - - /* No turning back from here */ + /* Anonymous folio without mapping */ newfolio->index = folio->index; newfolio->mapping = folio->mapping; if (folio_test_swapbacked(folio)) __folio_set_swapbacked(newfolio); - - return MIGRATEPAGE_SUCCESS; + return; } oldzone = folio_zone(folio); newzone = folio_zone(newfolio); xas_lock_irq(&xas); - if (!folio_ref_freeze(folio, expected_count)) { - xas_unlock_irq(&xas); - return -EAGAIN; - } - - /* - * Now we know that no one else is looking at the folio: - * no turning back from here. - */ + /* Now we know that no one else is looking at the folio */ newfolio->index = folio->index; newfolio->mapping = folio->mapping; folio_ref_add(newfolio, nr); /* add cache reference */ @@ -452,7 +438,7 @@ int folio_migrate_mapping(struct address_space *mapping, entries = 1; } - /* Move dirty while page refs frozen and newpage not yet exposed */ + /* Move dirty while folio refs frozen and newfolio not yet exposed */ dirty = folio_test_dirty(folio); if (dirty) { folio_clear_dirty(folio); @@ -466,22 +452,22 @@ int folio_migrate_mapping(struct address_space *mapping, } /* - * Drop cache reference from old page by unfreezing - * to one less reference. + * Since old folio's refcount freezed, now drop cache reference from + * old folio by unfreezing to one less reference. * We know this isn't the last reference. */ - folio_ref_unfreeze(folio, expected_count - nr); + folio_ref_unfreeze(folio, expected_cnt - nr); xas_unlock(&xas); /* Leave irq disabled to prevent preemption while updating stats */ /* * If moved to a different zone then also account - * the page for that zone. Other VM counters will be + * the folio for that zone. Other VM counters will be * taken care of when we establish references to the - * new page and drop references to the old page. + * new folio and drop references to the old folio. * - * Note that anonymous pages are accounted for + * Note that anonymous folios are accounted for * via NR_FILE_PAGES and NR_ANON_MAPPED if they * are mapped to swap space. */ @@ -518,7 +504,22 @@ int folio_migrate_mapping(struct address_space *mapping, } } local_irq_enable(); +} + +int folio_migrate_mapping(struct address_space *mapping, struct folio *newfolio, + struct folio *folio, int extra_count) +{ + int expected_cnt = folio_expected_refs(mapping, folio) + extra_count; + + if (!mapping) { + if (folio_ref_count(folio) != expected_cnt) + return -EAGAIN; + } else { + if (!folio_ref_freeze(folio, expected_cnt)) + return -EAGAIN; + } + __folio_migrate_mapping(mapping, newfolio, folio, expected_cnt); return MIGRATEPAGE_SUCCESS; } EXPORT_SYMBOL(folio_migrate_mapping); From patchwork Tue May 28 13:45:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13676759 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 EA72EC25B7C for ; Tue, 28 May 2024 13:45:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BACF96B0098; Tue, 28 May 2024 09:45:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B22D66B0099; Tue, 28 May 2024 09:45:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C3526B009B; Tue, 28 May 2024 09:45:26 -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 62DA66B0098 for ; Tue, 28 May 2024 09:45:26 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1B8D31605E8 for ; Tue, 28 May 2024 13:45:26 +0000 (UTC) X-FDA: 82167926652.30.24EC49E Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf02.hostedemail.com (Postfix) with ESMTP id 2A71380004; Tue, 28 May 2024 13:45:22 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1716903924; 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=NRuIUy2fMFhIcDljkycbP3YyA5GHegENarFTanSw40A=; b=WaoT4p2Qk4wZ0IAudblkBvi//0EiWoetz3nSjWYMx9SssWdGeNsELMFFbYnBUTa9gUgn6f c1Bh4TN2xKkFUqcr+qLnB8tDdpRA5IJ+7Rr2ZKao/B2KufbN5bSCIW+hAZPGUJ6LC0kDV/ KlsHbeBGJ9r6F3jIh3DuQEeJSH21Uco= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716903924; a=rsa-sha256; cv=none; b=Em4KgKr1k1tzSo5SuYhLUGI0NV4j9uiLduTNnEIezhx2Me0DyiQRJElVCldDfxxyje29ks 99fNJfnOoqaa7i6758l6nBZ3fJI1ey9iBanDL6FyRW5f5LGUbT6EX9+ZLXBV/pXuc9T2+0 NasE7Rsuh0eJQ1xnr/uO+phst4OP53M= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VpYZh5b0sz1S8Hg; Tue, 28 May 2024 21:41:32 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id DF25618007F; Tue, 28 May 2024 21:45:18 +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; Tue, 28 May 2024 21:45:18 +0800 From: Kefeng Wang To: , CC: Tony Luck , Miaohe Lin , , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , Zi Yan , Jiaqi Yan , Hugh Dickins , Vishal Moola , Alistair Popple , Jane Chu , Oscar Salvador , Kefeng Wang Subject: [PATCH v3 3/5] mm: migrate: support poisoned recover from migrate folio Date: Tue, 28 May 2024 21:45:11 +0800 Message-ID: <20240528134513.2283548-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240528134513.2283548-1-wangkefeng.wang@huawei.com> References: <20240528134513.2283548-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-Rspam-User: X-Stat-Signature: 9hspnsweyp75xch93oxjw381c9c84sx3 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2A71380004 X-HE-Tag: 1716903922-270402 X-HE-Meta: U2FsdGVkX1/1o9JqL9RIVbEzDvcvb26OoJlhNbzzh5eZNy3IOTLOOgWc3dhPSAvQT6QoxBUz5mMKVTXmWUcessulFtGAcSgqtRI6K0DCyw5PSJCCXlS2IsIlohiB1yFDw9NtF5bkHEvkmtT8yN5kdhbVl3g7yfMx3XfTph4jOLSDYasvPh8DXxnLgEirZ+zuRZ6NdTU2RcDIqsHouSLIPR12J2DLC+MFWL5Px4kosNTeuSpejSKOH1W/h+MU4Pa5H45YNj19HxyIp4NOi1BoiBAek5pPiLkLmEQ1TSD+9QBq9GlinIs5iB44Yt9vjveaPx8YTLBxiJds5XeniVbya2hQ/Mz0Q0J7Vox8YwnGQETdQfQpRRj/zye6Aedlv/AOwR7NtUw/mpl4zRIw8+5pKmNO8VlYcizy2RMP5nD5EnG/VUZepcapfXs3BOa2pFnKGb5MzpLGsl7X0GWJhMXOtHAEvtWL+juACjx+Johg6ScARnueUd6QPADNfl1NstQq3HGMsrhpWtXyvdqNQS27bCK1GU4GfMxijUJYbKdSMlgj1Tsa/3GcBnHdqHCHM964qSgPpgJ/c6BQqSocO3e8uEqA7R0et775eapVxLfJtJbfIBEHruvn8+ZO4B0yJesfuRIOTzrLxCa8Ui1kB4jjqJrvVbHsyhSYlSJDwLJ4/lOSffBfyOJDO7Z9uGvLXGfZrnVrv/uGpGvXamJbKx678JKZIkMMj1hiUS7QMhT5l4DZy4mBgBgdaWVvacYA4DYmGaXO6ji9/YgTULAKi7kMfJY0dojBit1bBRUEi0NkbC2Wek8PHbJti6ThNLE6EtFSleiqJhTNg6N/QGOU3WezUuco5boNfij2Hpzgh4DLENdDdtIkpqRetlad8cMHc9I0GTxIG9MoHxh1QM28Qi1E/CtWAm+ZlK3ef4I8NVpTm4NYfFIcX0xrBk8lMy3tWBb7HPAEOBtA/nRMLqBcWNp U2hdCYcq dmSx61FAeXMLPnG76rnnt/aJr7y8VW4D5oBmkZQ12+4aCljdghkhndjXy5tmwlF7kRPC5Vv1KMalBH/IF6mT5WngUlmnPhb0wjt9zKt61xomk/GpS2CRT8Tx2N7YMM37g+1uyuEDdAqa2HVGHF84WAXrzMoWzPOyXZ36T4vTYPsRQMcb2PQAGgXbOWgHoWbl250Hm2aXbAULogD7T04Cfk+cSUg== 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: The folio migration is widely used in kernel, memory compaction, memory hotplug, soft offline page, numa balance, memory demote/promotion, etc, but once access a poisoned source folio when migrating, the kerenl will panic. There is a mechanism in the kernel to recover from uncorrectable memory errors, ARCH_HAS_COPY_MC, which is already used in other core-mm paths, eg, CoW, khugepaged, coredump, ksm copy, see copy_mc_to_{user,kernel}, copy_mc_{user_}highpage callers. In order to support poisoned folio copy recover from migrate folio, we chose to make folio migration tolerant of memory failures and return error for folio migration, because folio migration is no guarantee of success, this could avoid the similar panic shown below. CPU: 1 PID: 88343 Comm: test_softofflin Kdump: loaded Not tainted 6.6.0 pc : copy_page+0x10/0xc0 lr : copy_highpage+0x38/0x50 ... Call trace: copy_page+0x10/0xc0 folio_copy+0x78/0x90 migrate_folio_extra+0x54/0xa0 move_to_new_folio+0xd8/0x1f0 migrate_folio_move+0xb8/0x300 migrate_pages_batch+0x528/0x788 migrate_pages_sync+0x8c/0x258 migrate_pages+0x440/0x528 soft_offline_in_use_page+0x2ec/0x3c0 soft_offline_page+0x238/0x310 soft_offline_page_store+0x6c/0xc0 dev_attr_store+0x20/0x40 sysfs_kf_write+0x4c/0x68 kernfs_fop_write_iter+0x130/0x1c8 new_sync_write+0xa4/0x138 vfs_write+0x238/0x2d8 ksys_write+0x74/0x110 Signed-off-by: Kefeng Wang --- mm/migrate.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index e930376c261a..e8acc6c38574 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -663,16 +663,28 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst, struct folio *src, void *src_private, enum migrate_mode mode) { - int rc; + int expected_cnt = folio_expected_refs(mapping, src); - rc = folio_migrate_mapping(mapping, dst, src, 0); - if (rc != MIGRATEPAGE_SUCCESS) - return rc; + if (!mapping) { + if (folio_ref_count(src) != expected_cnt) + return -EAGAIN; + } else { + if (!folio_ref_freeze(src, expected_cnt)) + return -EAGAIN; + } + + if (unlikely(folio_mc_copy(dst, src))) { + if (mapping) + folio_ref_unfreeze(src, expected_cnt); + return -EFAULT; + } + + __folio_migrate_mapping(mapping, dst, src, expected_cnt); if (src_private) folio_attach_private(dst, folio_detach_private(src)); - folio_migrate_copy(dst, src); + folio_migrate_flags(dst, src); return MIGRATEPAGE_SUCCESS; } From patchwork Tue May 28 13:45:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13676757 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 AE7EDC25B78 for ; Tue, 28 May 2024 13:45:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B5D036B0095; Tue, 28 May 2024 09:45:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE5446B0098; Tue, 28 May 2024 09:45:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9861C6B0099; Tue, 28 May 2024 09:45:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6B8C36B0098 for ; Tue, 28 May 2024 09:45:25 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EF2A6C13FD for ; Tue, 28 May 2024 13:45:24 +0000 (UTC) X-FDA: 82167926568.24.D83A01A Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf12.hostedemail.com (Postfix) with ESMTP id 275524000C; Tue, 28 May 2024 13:45:21 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1716903923; 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=Y2fMGTKXsKF/unYtc8SmHywjl8cuLlulk8RrcBKmUDI=; b=RajuZePwByrLtIGDsooyqV5JYuGf4OxWz0oiR9+VXG1OmJc2/znzetoR/tErckazOCh7He G+jakH/02+PcSr7QJa/sIB8qUOx5GfXOqE1wPb5Ds16rZ9mQBeC4nlUcjPueduPfnj914x 3Den+vQ/ZG4I+da0wgraV+qXRd9Q6t8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1716903923; a=rsa-sha256; cv=none; b=z7BK5TptdYHgPyP9rRlhlXXnyUXiYAXSMTuasfrdZrxXHNdSzQFm5PGUnVPGL1BZpnxsE8 jMeq4iEJtuN4GlXvet9ax3yYXdlrOVm0V8kg6IgakhoSgvF1vdubJjm7wm7kwpqbmz8qZm vy2prQlSQpjzVJoluA19np2NFqGiwuA= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VpYdW1Tk0zckRB; Tue, 28 May 2024 21:43:59 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id A48211400D1; Tue, 28 May 2024 21:45:19 +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; Tue, 28 May 2024 21:45:18 +0800 From: Kefeng Wang To: , CC: Tony Luck , Miaohe Lin , , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , Zi Yan , Jiaqi Yan , Hugh Dickins , Vishal Moola , Alistair Popple , Jane Chu , Oscar Salvador , Kefeng Wang Subject: [PATCH v3 4/5] fs: hugetlbfs: support poison recover from hugetlbfs_migrate_folio() Date: Tue, 28 May 2024 21:45:12 +0800 Message-ID: <20240528134513.2283548-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240528134513.2283548-1-wangkefeng.wang@huawei.com> References: <20240528134513.2283548-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-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 275524000C X-Stat-Signature: 8qjdoo3ews9sdtwbjmaop5au5sa8k3np X-HE-Tag: 1716903921-493133 X-HE-Meta: U2FsdGVkX19zgO9qockjBJBhYmwgkFFNuHv5zqTcpT5dcKLb3ypNIGXILfARwylFkwfJlHL9WHjZPoGxJLDdAzKssRHHvyHZ/4k5Se5gxbRBN3UCk3Per5wHJblROPK5Fl4mwLfW9Mjb2lor7dC+EkWUOMl0OSCnIA1K+3+slDVZpzARCI8FE59MNMX1YSMkASCj86oDcaz87+wRhAXKyJLtecXnEJEhJUczfNAVM/fra5dNcqPUJufjzZKaqcRYLA5jEvwsYHRMHuCDRbyK9hqCPSZwwQ9gYJwYwuSgSqYTP3yPVpSll8JhN4ys2x09OnwqTaYAnQKiadeS5G/zEKPNxBVdNYiHz/+PWx4Go7H8xKf7nOaKXKlmWMB/TwBRIwqmFzmtSmhnot9UqGMNRf6Ps1abHcezcqyPnVp/993orjw3t2SUFDgfx+zSy+LMdBQEde8jqsBgisMNe02xOsE8g2ebSNeCixyu7QGIHm/FRFWG0YirsMk+bFu+1rBDJeSN0WgtrvWvbyHMtL2p7US0Squ0Sja6gip2x4yM+4NmUx/4CdRyPpqSrklDNS8QCHo50KlNHtbaykILjl9tLjUWWTXtISH8BTFW862fAFoHBcmCaMUKE3NPejNgIlXDSPj7R60PS3FBcIZl3xE8oQ7tydXkPjju6NR4mai1Ub6Yu0S5HFsbzm+xRjsLrQFibp4M/93Ae1ymYLNorhPVWnL7Mt51H2wQ80d+Lb0AmpGh48WvR3RDWfX68Np9u99RueSkLNWrJP0W8+ei/Krxc6HuJauC1ceL0CadsPw1SbDLj8fr6CmLe1ttvCoJTaPfcDBPfOY6QCLMgAr3B9egd4317rlvhM3HhG7KeaCq2GlAU4sC/EKV63p24r3AZ8pqSZd0Ct0tGpKvkuCn87ZVYj769u/aDytBJe0qs7wU3qyCgtDf+7VB5HhyLYeMStYBf8YKKrJLOfGlcYO2fIl D/xXsw4M IAEUpJ2fAuy244dTdqMfbVLaj8GHMKOjR6G8MAZid8qyi0VKk1tqu6ZMwrmzsyp/aQht3TrYEaUgNydJmWzd78j7Jf7jqV8kL4Jmm7+Ip+ox3SSAi6ddhRfpsN44qBNFIO3igCMhuUZ+07LjUNYruC8gWlJHDpk1qiMm4LgE7pbxCVxa4oBsx/F93SOdDai8DY3WSgHemRwfrKpCwpL9TdhmsQdxnmuUsqHH9jUrdTGa4z6YNJXDrh8q7ixLIEfwfzptUEdG/HDhxjrU= 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: This is similar to __migrate_folio(), use folio_mc_copy() in HugeTLB folio migration to avoid panic when copy from poisoned folio. Signed-off-by: Kefeng Wang --- fs/hugetlbfs/inode.c | 2 +- mm/migrate.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 6df794ed4066..1107e5aa8343 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1128,7 +1128,7 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping, hugetlb_set_folio_subpool(src, NULL); } - folio_migrate_copy(dst, src); + folio_migrate_flags(dst, src); return MIGRATEPAGE_SUCCESS; } diff --git a/mm/migrate.c b/mm/migrate.c index e8acc6c38574..78cfad677789 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -532,15 +532,18 @@ int migrate_huge_page_move_mapping(struct address_space *mapping, struct folio *dst, struct folio *src) { XA_STATE(xas, &mapping->i_pages, folio_index(src)); - int expected_count; + int expected_count = folio_expected_refs(mapping, src); - xas_lock_irq(&xas); - expected_count = folio_expected_refs(mapping, src); - if (!folio_ref_freeze(src, expected_count)) { - xas_unlock_irq(&xas); + if (!folio_ref_freeze(src, expected_count)) return -EAGAIN; + + if (unlikely(folio_mc_copy(dst, src))) { + folio_ref_unfreeze(src, expected_count); + return -EFAULT; } + xas_lock_irq(&xas); + dst->index = src->index; dst->mapping = src->mapping; From patchwork Tue May 28 13:45:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13676760 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 DB788C25B78 for ; Tue, 28 May 2024 13:45:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCDA16B0099; Tue, 28 May 2024 09:45:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA5C76B009B; Tue, 28 May 2024 09:45:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C45706B009C; Tue, 28 May 2024 09:45:27 -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 9F0286B009B for ; Tue, 28 May 2024 09:45:27 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5C7AEA35A0 for ; Tue, 28 May 2024 13:45:27 +0000 (UTC) X-FDA: 82167926694.12.E9F5D76 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf18.hostedemail.com (Postfix) with ESMTP id A273D1C0014; Tue, 28 May 2024 13:45:23 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.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=1716903924; 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=2ERo7fs/VL13wl1oZ7vh0gekVyJ93jqSyuHHJZLw1AE=; b=2/ueFSwDXJ+l2W0UUVWo+A37N4uS3jv8hB+SHBjfoEzCtY9jpPkLfpBMyZZXVhQvpkucmt CiCVQwjntkYpvZJ5JhKNR4nzhQN09OzCGFRuI9qHYH29nvIsveF44ssTgwHkzXIJK3xXJ7 sxHgaDBBr2xqVpX0wfYXwdoC9qbDLNg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716903924; a=rsa-sha256; cv=none; b=uKPXNUQK7Isu36cjQAEDcqg14bKwyFKcY/df+o1Py01S6Y8N22IgLoy7kzeboqDq5jNExj vduxv3feu9c4F1B5fCvZZvsMP+KOur+vsKY2RMH9HPh0agFhSnGTqiUcuoyNIx6gQAm66I Bgo8bnd0TAyjJv5mJPt835MdFexeaVw= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.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.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4VpYbS0Zsrz1yscx; Tue, 28 May 2024 21:42:12 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 6925A140158; Tue, 28 May 2024 21:45:20 +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; Tue, 28 May 2024 21:45:19 +0800 From: Kefeng Wang To: , CC: Tony Luck , Miaohe Lin , , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , Zi Yan , Jiaqi Yan , Hugh Dickins , Vishal Moola , Alistair Popple , Jane Chu , Oscar Salvador , Kefeng Wang Subject: [PATCH v3 5/5] mm: migrate: remove folio_migrate_copy() Date: Tue, 28 May 2024 21:45:13 +0800 Message-ID: <20240528134513.2283548-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240528134513.2283548-1-wangkefeng.wang@huawei.com> References: <20240528134513.2283548-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-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A273D1C0014 X-Rspam-User: X-Stat-Signature: wgiap8j9ah969pjih4onfbbun8unhysn X-HE-Tag: 1716903923-281184 X-HE-Meta: U2FsdGVkX1+mVu/iH8GltEqdoF6Zw4QhrX6Ru5P1XCndjDZrv6Tcld77947s9AmO98kq8TmdcWodrjQ8oQ0IGhnrmPz4HlbJHUOafs7zxNnp1WKRJJjUIph1/jfvxRBbkcCpkQq05Rk9a1xg2lKp14EKc3tR72HG39B/mVzyjD7jgHjWUxuopo3lhsDyxUbqJHZpGCnySeKX7HNza1LS+evGxTWisjdkXHtDvWiZ5+61Wv6MRvGiLtbPy8/TIveVunCjW/Oo0NWA9SpT702nfz6nzGbHx35f/bjt+DFpeqCWQROM1qXeO+X8JCAfVhfBufJ0hSmVszQJJOWrQvP9XG2fvzEK4Y7H9dhWYxJUJb8fYjbf3ZO2Z1NNYfKomA3szI6zpE+9DOx7XGKHzGBA4d1YpXfROWDwJWlHCSj+zfIQBW7pt1+h50JIk17aqzXS+hVqPEpPucgm6FOuwcwSCGY37Zqb65r9JYA4ZwX/3PvwfvF0Jv4pIW5LIj5E9XqOrf8NMo3BcXMOv8qMDx46LHwBTpabWbzg7mw+KzHwvQH1U/nMF7UeebY8JfnmsEf8xkI4BXKLF9kDZU8k6bQ/lboO7aZG/gZ/I5EW3pt6YAlmD1TioocdWkJ/wyL903sG5AMa4/N2Zbjj8PfUuKXk7IhcxKYguiQXU6h+LOrSxhC6P3AM9ja8ko0vRr8BVbTvBGFD1v36a6seNpExaEalHuD3KEihvmwegylzpvsTcmM4lidagvF7U6b26ND6IAQnE0wJeddCD6PDq0gIzgkw2hD+3WyVExooqproCIPGYDBJi6wZ1yNvD5KKAnb+qQCPeyi1egcuQv2VA1mAE6IEYg4goHpayh1YANSeacmyGlgxBJhT8XhMn4GEBd+oONxXfQGgi9crD3QhqBipkWKywexO5A9V3DUGHuc2YTgMDWVweTiMDbmPmjRS6BMF0Q6c1wl+mQe9tqkP5lPMnJ0 voWfJvt7 S6r/RpzB1odCY+ImSmeggdyn/XOLUkB8ekttN9RTG0fhVj5LRlPCjDxW2pd8jAAs/u8bB9ar3/MHVwbFxcqYDdo6iALBbROc1Mc34JvgozmHV8RPnGlFegE2uWhrZX8HHiqApSYRCV++OGQGMw2nm+CNGhJem+2EDHOmGP7LgeKP7RwOO03DVJmsBQOdPi61Y2+SPQToNlQFHxHQUxtsa2w7j+4Z+bdGJiLjE/bTIn2/9EJ2p1krHSuV9FKVX5nqnZbcOCDjpB4xs7Fk= 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: The folio_migrate_copy() is just a wrapper of folio_copy() and folio_migrate_flags(), it is simple and only aio use it for now, unfold it and remove folio_migrate_copy(). Signed-off-by: Kefeng Wang --- fs/aio.c | 3 ++- include/linux/migrate.h | 1 - mm/migrate.c | 7 ------- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 07ff8bbdcd2a..bcee11fcb08b 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -455,7 +455,8 @@ static int aio_migrate_folio(struct address_space *mapping, struct folio *dst, * events from being lost. */ spin_lock_irqsave(&ctx->completion_lock, flags); - folio_migrate_copy(dst, src); + folio_copy(dst, src); + folio_migrate_flags(dst, src); BUG_ON(ctx->ring_folios[idx] != src); ctx->ring_folios[idx] = dst; spin_unlock_irqrestore(&ctx->completion_lock, flags); diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 517f70b70620..f9d92482d117 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -76,7 +76,6 @@ int migrate_huge_page_move_mapping(struct address_space *mapping, void migration_entry_wait_on_locked(swp_entry_t entry, spinlock_t *ptl) __releases(ptl); void folio_migrate_flags(struct folio *newfolio, struct folio *folio); -void folio_migrate_copy(struct folio *newfolio, struct folio *folio); int folio_migrate_mapping(struct address_space *mapping, struct folio *newfolio, struct folio *folio, int extra_count); diff --git a/mm/migrate.c b/mm/migrate.c index 78cfad677789..6404239938be 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -651,13 +651,6 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio) } EXPORT_SYMBOL(folio_migrate_flags); -void folio_migrate_copy(struct folio *newfolio, struct folio *folio) -{ - folio_copy(newfolio, folio); - folio_migrate_flags(newfolio, folio); -} -EXPORT_SYMBOL(folio_migrate_copy); - /************************************************************ * Migration functions ***********************************************************/