From patchwork Mon Jun 3 09:24:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13683604 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 26BD3C25B75 for ; Mon, 3 Jun 2024 10:46:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A3626B0095; Mon, 3 Jun 2024 06:46:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E77F36B009B; Mon, 3 Jun 2024 06:46:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7DE96B00A0; Mon, 3 Jun 2024 06:46:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 587856B0098 for ; Mon, 3 Jun 2024 06:46:09 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D905E1C0DC2 for ; Mon, 3 Jun 2024 10:46:08 +0000 (UTC) X-FDA: 82189247616.16.1F5DB41 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf14.hostedemail.com (Postfix) with ESMTP id EA163100014; Mon, 3 Jun 2024 10:46:05 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1717411566; 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=gwSPhmkkIOKfH+OEGxsgxRPTgKSYi8a9uVM17S8Pvu4=; b=rm0nedq0C9Cn12Jmd9Ql4+RhmpULaUKap+lDTc1Q4IIVyC30qn4cZjjJGps5jAT/JZisOX Th0saBVTwqnhzIdVnaPipCLBKsGM8w+0IKJDlt9LcjYKBHykK/qeA1kD6Fj44IqFHMQ7dJ e0kkUM1H64xSwoc1Ve+zpqWnVYngAE8= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1717411566; a=rsa-sha256; cv=none; b=iPrd7jSw6yr9Xi9VB+bvcxZr6lli/nvduunoRMLWZcMjbh8e+nlqM78BYzhRCJy/BbksNk T2nWKZ7i2nGKEqHGjK7JIxE5BoPAaCN2rTW0RxQFaEs4cH/h69AnIM2KchIpnewSDraFrQ Gy1HryAvDctwF6NsKCuC7H4YaGpARSY= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Vt9Jv6pLRzxPtp; Mon, 3 Jun 2024 18:42:07 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 8692D140417; Mon, 3 Jun 2024 18:46:02 +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.39; Mon, 3 Jun 2024 18:46:01 +0800 From: Kefeng Wang To: , CC: Tony Luck , Miaohe Lin , , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , Jiaqi Yan , Hugh Dickins , Vishal Moola , Alistair Popple , Jane Chu , Oscar Salvador , Lance Yang , Kefeng Wang Subject: [PATCH v4 5/6] fs: hugetlbfs: support poison recover from hugetlbfs_migrate_folio() Date: Mon, 3 Jun 2024 17:24:38 +0800 Message-ID: <20240603092439.3360652-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240603092439.3360652-1-wangkefeng.wang@huawei.com> References: <20240603092439.3360652-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: EA163100014 X-Stat-Signature: ryku4rwa5a1pg91d7wnqmkeosud9fox3 X-HE-Tag: 1717411565-662172 X-HE-Meta: U2FsdGVkX18CfqA7dadh8h74HDgdq45I3ckyJoteb8Idk+JWREoGYO2Y/iU1Kfo2FvyR2RrcmbuM+RP6OBLPoAusdtZ8Fw3G5nlPxCCzFfBeJL/YV4yAb745PJDLW8Zgc0zhd4gUZC87Wc6HsW8D246etDapBl/MW00ghTuS5hehSUo0G7bq2zdU/A1rQtNlntZkPCdaZureTjwZuTrnPRpvG+XCnZvuAgZ0242noQUlj79WMoEgUuCtWcUaSRV8STeFl87pk5STiSoQ+ZCtzuhClAP6RPUT+Ic8HYf1KJIIAz/7jQKSOSthOCVIvBertPKpzKDEbr4iK3loG4EWXG3o5/fXN+5jVrB6iDwy6RaYPCp/I2DnniOtnQOU2CJ83TaxA8lwQ3vxaO0xnv72IsOX7pGWxeg5zivrm9rt2ynTXlGD3eVBwjO7wV1P9vaXmOkyqh8aXaaoX6b52aImdt5XG2O+BJ031ctE4K/i4HL0M4dwNVskZJkuO3fNclv75ph6Gf/mpQj4WZIM7HerqHf+hnHF+V74mHQDVar9A40ecD/Wi6T+QmHex9ogfMnkgQ7rkWvfJVRSjBjeZIAfhGQfy8Mt+xv+5CZslCzCrkxSEETzkHFp4yTOztCIaiIhwZiU0IVxY0cNsAkfoGn8PPz0lsZjCvWs9A9bt0gtUVKQPI63vXiAj8y5+xXXVR5kdfsjSQdea3PDICs2ZSkhxB1a9f5EpQbAdJtEkGjffXRLzch75UeOmPw2Zj9BEsG8gqHZrRmVA69dHYY3x8MbvtI4CYLxwqvRyfKLQ9YaSRtZ89ztgs4khbxRzyU9CfczcYlMovwzIe/r0Nqde7OLBLhaLaIzHCGDXi7JmCb+uSt+xg44gAG77nLBob5svd3lBbLzlMOn1Y32vYv7myyj3myi0CKWna+QKdwM78iRmwdzAec+Q/fFg0GflIW+VQj0S4zdojrDe/Ni1GwBqQI n06PDNeP 11+nc9A9uL/gjF74/k21Z3BQ8ulO2TiyMbBiMDsXyivJU77/s7PbyDPkej9wmoRRYoy6bOviGYQtqCL4xyNyuQNO5WQ3xktdl5CGx6FuhqAHp56Q94nBt+q7ZdhYl54PQ1Co8qs9BN4cEo7r/LtrJd5EXBXWmabqnpBjx+lnxny/1Y/bIZMUpm5eLo5yeszUISXDaW1+7y49HV/Q9pZCBR4e+Z9U7PYUQxRNlCIsfATqjqJpTOuWM8ECW8eVoekb9ralkqkl+UOyuYn0= 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 Reviewed-by:  Jane Chu --- fs/hugetlbfs/inode.c | 2 +- mm/migrate.c | 14 +++++++++----- 2 files changed, 10 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 28aa9da95781..e9b52a86f539 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -532,15 +532,19 @@ 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 ret, 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; + + ret = folio_mc_copy(dst, src); + if (unlikely(ret)) { + folio_ref_unfreeze(src, expected_count); + return ret; } + xas_lock_irq(&xas); + dst->index = src->index; dst->mapping = src->mapping;