From patchwork Mon Jan 29 07:09:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13535067 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 B2240C48285 for ; Mon, 29 Jan 2024 07:10:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61F416B009B; Mon, 29 Jan 2024 02:10:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 55C116B0096; Mon, 29 Jan 2024 02:10:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DCF906B009A; 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 916666B0095 for ; Mon, 29 Jan 2024 02:10:01 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 860331C0C1A for ; Mon, 29 Jan 2024 07:10:00 +0000 (UTC) X-FDA: 81731474160.13.0EA55EF Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf12.hostedemail.com (Postfix) with ESMTP id 1D34F40014; Mon, 29 Jan 2024 07:09:54 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 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=1706512198; 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: references; bh=zP8Y5eg9e8UR/kDcSxjV4rRyUiFi9gvISTw0Ch39K5k=; b=j9/41hWhbWwYDwBdmkLTf++QaAW+m+LlBgIO2BKmydnD50ajOn6slvjlIcouxDbzB6tRdX A0q9yIHc2S9upSsFPI1sUK1ckqgw2fBGqOtbDSodFB6xGTB1F1Xu13OWbc+wOwFhjBSvX9 5Nt0MK/TVWBQbTqowL7ZlT4N05OD468= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706512198; a=rsa-sha256; cv=none; b=RdeWYaExtmwKaS0IghS7tAU+E9XrIn7JgfljrLvaMIICOmLRBKfHBR5jhZBvxezKasrN+I p5j9vaElc323EvianItpxNsLINKVyP8b/5DEwAHyKpq/8QM2tV0OLAFDeigy9PLUzDIXds vgBx/UKEuctfG3dtZ6ixuFBbGJSrl6k= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4TNfXw1Nt7zNlmY; Mon, 29 Jan 2024 15:08:48 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 40E1D180079; Mon, 29 Jan 2024 15:09:46 +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:45 +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 0/9] mm: migrate: support poison recover from migrate folio Date: Mon, 29 Jan 2024 15:09:25 +0800 Message-ID: <20240129070934.3717659-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 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: 1D34F40014 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ge775nncsbew3n5913695g65bko8r3dn X-HE-Tag: 1706512194-634804 X-HE-Meta: U2FsdGVkX19hklgRrXKY7K493EJVGA/jM5XwUsBCyYwUrdhNavHBy8J0tXhw1hfnMrpyX+nbqb82lORNs1Rv7zEmx0PsBq5GnVHaImdnoze0Bt5J8kRGyKqskn2agbNtzLI6g2QgcPMxII9dcX7TaX+VN+rMIPn1hz9QWZdvCmmZt/cuun2bP5+V2a4rgG9/9ZvPboyi7xkcb2he1xT3qVLyN3THV/R6qdgmqSs9Ftspo15RTeuT4ee3fHiIA547nkBs1Uj6LuSxfOXM2857nH6HPxe7gXVH6EopBvHdstWYetiCTsIatXI/84tJeYBc4f5i5ZrG1vQSxyZcj8a8R7eZZ/Zn2M0wEmMMpFpjUThisY6xTmtQ3wuejey0lpHp5DYAVV94KFOGvt49vJVACJh4lblSPcUDI9EfVvbR4y4DP9DA4MbuoFYcnklUzV6mZMAgiiYCKWCD7347Gz2WLJ/Y5vBug8ezgysQNfTSLySfNbimD2A+p4sITdIaktGmNX+XbZNvA0v8OudYhxQIklBv2EYJOyDfAwO03T23GSFUI21efBn4/dz+TOfG1Ke/KYZk5mpVbZ52puHq8//8dcwkqQrBiIfuE+XeB4mBApvAWWoTgkUVV/msO96n0oKvQrBZUqYkjXwDafxhXB0FCcT8Cx4UtNMPMnAdQ8AETzReF2dAOxu/7sEh1SKjDqgZakj3eXptOqP7VFxGIDdA8c8f6K2oQtI7H8uE1NQhOP3zktDrDqevmFozfSHT4FPmyC2qZZquusZxEpqsblo8NkEpDQhER7Wd3j7lDNTqskBQMZDLIv/Cf73pSDCadMj6XU1obd1m/F4RPj6Zb0PhYkn0b/jLYhivSMuJ+SC9PCa2yPZHX6K5ONjNKGrApbW2gAkWvvKNJTPyN0oHGyfV4Hf0T6Nrj1zCp8OnxfOS3Df5ATR/QZ3bzA0WY4trifRSaGzdf5/dZWrKQ4suKVT RSr+f+b4 cuSqJIEdjEmx4uyydKNTfaQNxQjU5bKRj3lGUGjAOwnrCI4JA0skHzHQmwTuYK7V19QxwVuR81AS4b95sn/7jyNszmmvJ48TTMv7mmibet69+CKr2ASjEDQ73YA== 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(Machine Check Safe Memory Copy), which is already used in NVDIMM or core-mm paths(eg, CoW, khugepaged, coredump, ksm copy), see copy_mc_to_{user,kernel}, copy_mc_{user_}highpage callers. This series of patches provide the recovery mechanism from folio copy for the widely used folio migration. Please note, because folio migration is no guarantee of success, so we could chose to make folio migration tolerant of memory failures, adding folio_mc_copy() which is a #MC versions of folio_copy(), once accessing a poisoned source folio, we could return error and make the folio migration fail, and 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 Kefeng Wang (9): mm: migrate: simplify __buffer_migrate_folio() mm: migrate_device: use more folio in __migrate_device_pages() mm: migrate: remove migrate_folio_extra() mm: remove MIGRATE_SYNC_NO_COPY mode mm: add folio_mc_copy() mm: migrate: support poisoned folio copy recover from migrate folio fs: hugetlbfs: support poison recover from hugetlbfs_migrate_folio() mm: migrate: remove folio_migrate_copy() fs: aio: add explicit check for large folio in aio_migrate_folio() fs/aio.c | 15 +++------ fs/hugetlbfs/inode.c | 13 +++++--- include/linux/migrate.h | 4 +-- include/linux/migrate_mode.h | 5 --- include/linux/mm.h | 1 + mm/balloon_compaction.c | 8 ----- mm/migrate.c | 64 +++++++++++------------------------- mm/migrate_device.c | 26 +++++++-------- mm/util.c | 20 +++++++++++ mm/zsmalloc.c | 8 ----- 10 files changed, 69 insertions(+), 95 deletions(-)