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;