From patchwork Wed Apr 24 13:59:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13641925 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 B0511C4345F for ; Wed, 24 Apr 2024 14:00:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2C328D0020; Wed, 24 Apr 2024 09:59:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DDB758D0017; Wed, 24 Apr 2024 09:59:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C04848D0022; Wed, 24 Apr 2024 09:59:46 -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 726318D0017 for ; Wed, 24 Apr 2024 09:59:46 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2A8301608B5 for ; Wed, 24 Apr 2024 13:59:46 +0000 (UTC) X-FDA: 82044583572.22.8ADC6FD Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf29.hostedemail.com (Postfix) with ESMTP id E6ED3120016; Wed, 24 Apr 2024 13:59:42 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1713967184; 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=upFkI2XpQGH06l4wc3gzZMhU250ficRWyophhap6ZXc=; b=6OESfR4ch60cwOza3QGREOVxRYbPnEk9zpijDhyv+FbZvH6lr9SnjbGBkiRyq7HBLl6S4E /oQWRM9hO+uEfS2XyLHKcEOEMo71P4b9jrJ4PCfrTTHoQ/gzA+LR7HJJqNDLz071DXLV5m PE/usSQCKzU3eHcDCHkdLtSDjA9/eeo= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713967184; a=rsa-sha256; cv=none; b=5HCUE2FjmMjZdOL2x6wjT2LeruD548LYRBhZ1q7WMZr/hdfJ954HgjD3rTcmBWFRoWfIy2 yuzvmR3tx5WvlcCcRNatIPSmzL8/mKf64JgZmC4Efseyh/EMTYIoEwVRND5JbRRDtgGLW3 +7jrQfCiQ1A8bKswo2k0YkpetYM07B4= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VPgWp2WqqzvPrC; Wed, 24 Apr 2024 21:56:38 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 39DE518007B; Wed, 24 Apr 2024 21:59:40 +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; Wed, 24 Apr 2024 21:59:39 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Miaohe Lin , Naoya Horiguchi , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Vishal Moola , Kefeng Wang Subject: [PATCH v2 09/10] fs: hugetlbfs: support poison recover from hugetlbfs_migrate_folio() Date: Wed, 24 Apr 2024 21:59:28 +0800 Message-ID: <20240424135929.2847185-10-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240424135929.2847185-1-wangkefeng.wang@huawei.com> References: <20240424135929.2847185-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-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E6ED3120016 X-Rspam-User: X-Stat-Signature: ko1aqfs7xrzpwaq3uueqqgy6se773h3s X-HE-Tag: 1713967182-397471 X-HE-Meta: U2FsdGVkX18nufQ9za1nzo4Ec6jSJAxBjIAAia9x4qbaBCer9PKvcOTevBsLEll7L5Z6JmlCkNZ/C3O4NW/cxFuogeDE2MpbuhMOehGHflKpswUoQilWHaihwIIALq+0am3S8btHFmFHB5cQodASqOv00gtYMJmQdZpCU5M1pskW2SOxQTuyE16OO6z3v7xBGAGnF6nLvF++djm4A5Y6Z0eix+PtK+xgZiyxZSyGZZtoyQlt5en5URAGFpB80u9Hukx9Tsb3DB7OJNH+YI2QADoCvXZ2dRKhqYOUY4HHg+RerHc+jmjWeyQpvhP7L2WVzFswDHkTAwQ6qG/g0PhODRCrgz6k/JVJa3j4S5Xea6EJEFsNSkZeg9qgEivvbVcW5etNuOU0KdnuY08eH5UrCA5cDYfmRhZLXOHfPR7DY+u6XTrHwr74c1atv9gK+DboQF5BG/8XaJxFpYsXbalUg6L77AnoGOGYETJXdUo4ejQyTQoBW2kX1GBzw6Zt1bsRCbMxY34JWTws7B8gSJ9RigyRErJbYKEV6id2K5R31DhujLCJoHm7BPtfCuniLBr0pE/UEMMI9d2YBzShUfO+C4BSb4I5Y17NIZ9xvVnnLfOx35IFkQGqE5fL7KbzAQfacCcoEZKYaZgkWJJtZoaEF0gaHofEEMnYWFdOjpi5TcJGKO0HBS6RP9kRuoO82l9dJ2J/ZhXs0cX4tXcpAKvOnbgV/KBypdNbDdjZE1YuhsoqbASMpwBeHHMTu4bYbl6OEQNaD4BA5uQOfyh9ZrBr1jRLldtFbPJK9zQPhlhI22YQIs0OLYKlNMW+tdYvcT1VuG034v7RLvhSidQZ6M90RGBG486cZtWU7HFYtmgvGDwkHl8cu30TG/oM2/p/cFSEP3Ru6HpgPfqqYUr98nkBqj8Poz4VSEjy6XLE/o/ubFncXG3+Op1aNnToAOui1CuJJK+AN781djOu8or+j93 ZGs0xv9v 2GXhzb9Kpwh1rIs1sln5l470W4AXTwbJlNM8in9vfmWFKQcc2tCmHii7ifoiOkSInrcqP2u/kCYuRxTVgPXVPYD/14A7ZxNsTBljMjqVDHM4t8F6tPV9IBeySYHzGcdwQei5veIIkWlsMMq7zRubAKm3i6xxRliE083fiUef5AbOMuTMi/nkBaXSKo3abhq6JRa+MIrS2DVVqhxnp8jYvghLaEJrVeO/AV3BZLHH8yCgnQ783eOKHj4xKOgvxL9z7pmuRSakK1hfG0YE= 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 | 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 60d4e29c5186..4493ef57c99f 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -567,15 +567,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 rc, 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; + + rc = folio_mc_copy(dst, src); + if (rc) { + folio_ref_unfreeze(src, expected_count); + return rc; } + xas_lock_irq(&xas); + dst->index = src->index; dst->mapping = src->mapping;