From patchwork Thu Apr 18 02:20:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13634077 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 E1BA0C4345F for ; Thu, 18 Apr 2024 02:22:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B4036B009E; Wed, 17 Apr 2024 22:22:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 764286B009F; Wed, 17 Apr 2024 22:22:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B60C6B00A0; Wed, 17 Apr 2024 22:22:32 -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 341B26B009F for ; Wed, 17 Apr 2024 22:22:32 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DF388A1337 for ; Thu, 18 Apr 2024 02:22:31 +0000 (UTC) X-FDA: 82021053702.18.8E8D293 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf23.hostedemail.com (Postfix) with ESMTP id 3FF5314000A for ; Thu, 18 Apr 2024 02:22:28 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713406950; a=rsa-sha256; cv=none; b=yfCeIFBVn0f2WbpHgEVA4/7nUb29AvDmwavCobPzGtbj/ZrnmqkokJHvOF4B8euBCd1s+4 oj1Pb9OcmQEqI/vYreVwwkGgaiFhfTkNiXfnA5nQRFkL8gTO6eQPWkZ4fjmyVeObW2WMNx AH7b5X1UGffmo/NeNASBf3hNmi0PEO4= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@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=1713406950; 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=q02p2w5jpA2AwmVBj3D+nNGqMtL/d/6nvpH1p8kh7I8=; b=HNb2CloJArW+8shWWF0cjwMTrEryZ2TBDFOQlTlJrtF//jNqs5f/T+haDpEqWEaKkvazcq fgvB0E+7AwrHAUw0V3LkwgfM9P/mdpqX8b1xdEVUcj9ao35DXJS7h5jB8iusZgGUb4r6FU IvJiWu+OIrFwiA5Y4G14QbbJLm/tpkk= Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VKhL10tW4zwSxx; Thu, 18 Apr 2024 10:19:21 +0800 (CST) Received: from canpemm500002.china.huawei.com (unknown [7.192.104.244]) by mail.maildlp.com (Postfix) with ESMTPS id EB9C01800C5; Thu, 18 Apr 2024 10:22:24 +0800 (CST) Received: from huawei.com (10.173.135.154) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 18 Apr 2024 10:22:24 +0800 From: Miaohe Lin To: , CC: , , , , , Subject: [PATCH 2/2] mm/hugetlb: fix unable to handle page fault for address dead000000000108 Date: Thu, 18 Apr 2024 10:20:00 +0800 Message-ID: <20240418022000.3524229-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240418022000.3524229-1-linmiaohe@huawei.com> References: <20240418022000.3524229-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.173.135.154] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 3FF5314000A X-Stat-Signature: c3x73sisn85nr9egruincmk35d1wedtr X-Rspam-User: X-HE-Tag: 1713406948-565713 X-HE-Meta: U2FsdGVkX1/135giihSe2pmy8VDgwtC2yGtEgB2DvLKpjVevNdKohifbraH0dF2/SkwS1SIBbSpyKYpO+cQws4OSyANJWSp+5DVKmvRLrAGZ3ZFwBROQfZLDcwvglczX7ALrHdhxIc25Am3Jou1+Llqtwy2WwBGOQBGhfzq+Xe7Zka9Jwq3qaaYKjhNZkYVeJQoqEX0Hjh25AlxzUSVorNs37O6Eunow5N/YDb3ooXLPNfRl5Y9VKFGNcttihXUoofzk3v96TnJaQ+QP2+JrRT5oUmW/PaOaU2imKgsApfe6lIbzrwWvUVOkMErIfNwa2U/L0815N+n82z1EBP8FMIBvMMLgFD0pDq7Yx+lKns3d3Gg3Jns295zWgn4v/F2fPkKZfVtr8culh8f+4gXhoxvAf/p0R8K39mwJPxkPhRcX8USCRdg9q3yAG7OPk92DyGcciZiXPaEwLY6NHoPkJUfk1iXJNyZbXd8ac9V64xWscrfiuM0PpeoZjp/1bnxaODWzFdrCO9AGsOIOtAVbwRFaGNnmlCHd+5/s7YE5mZwI+m/nOwfgDYCmlRvrw6UR2JOmVP2/qgZIsFuhaKLoMitA3tBe4IrWfzynCC/biO4YRgC9ORIu5IqIBUPKwPXJlE0xCk7kznSLYJAzJ6VYXGfHMkVqV5HED0kSD+DaUFKQleuFRb/k4H03JJ/R34cRhzAFsv+EDlcsBTBxgvkv8ksub5f7BTY5fyHdJGxdB0hdDPvlDieB6owbpFPjxu9kkQeikoHIB0h/9bFQhtTDcCAlINOWE8XrC6i9XU5fqHc90+rhIP/Oioav27p6PeaVt4oMv0Zc6nfl6pqGrOOmuyahNLXgjydlQS5palFc0JO+Z9S4DUOQISKvlOzdViapv3v+1yZKofem6x11mTJnbh71cQWZfXvaHk6yjCrlWiPLArjH7nDig2A2k7Y7INpQ5nAjPUBhfX8Iy8f+8VH kc6oGLJ0 bo1qMsHu/Wzgl8K/tMyhaP5HI2UdPo71BXHyU8L0j8hdvVSqn1Ho7BXhkAnZhkAsdhP0rOOGfQyAVkxbJZCFP/Z9s7gNxcE9RodGYq8lLy53COpQHFXb/PzCWMTrwegrCwZLw5mZefhLf9VUxkdcRgtB6yqaVO85hcCL+hPGN8wEPzkkQS7+iBVI+uVMs55mOh2/1hIeKwxWhfTk= 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: Below panic occurs when I did memory failure test: BUG: unable to handle page fault for address: dead000000000108 PGD 0 P4D 0 Oops: Oops: 0001 [#1] PREEMPT SMP NOPTI CPU: 0 PID: 1073 Comm: bash Not tainted 6.9.0-rc4-next-20240417-dirty #52 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 RIP: 0010:enqueue_hugetlb_folio+0x46/0xe0 RSP: 0018:ffff9e0207f03d10 EFLAGS: 00000046 RAX: 0000000000000000 RBX: 0000000000000000 RCX: dead000000000122 RDX: ffffcbb244460008 RSI: dead000000000100 RDI: ffff976a09da6f90 RBP: ffffcbb244460000 R08: 0000000000000001 R09: 0000000000000001 R10: 0000000000000001 R11: 7a088d6100000000 R12: ffffffffbcc93160 R13: 0000000000000246 R14: 0000000000000000 R15: 0000000000000000 FS: 00007fdb749b1740(0000) GS:ffff97711fc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: dead000000000108 CR3: 00000001078ac000 CR4: 00000000000006f0 Call Trace: free_huge_folio+0x28d/0x420 dissolve_free_hugetlb_folio+0x135/0x1d0 __page_handle_poison+0x18/0xb0 memory_failure+0x712/0xd30 hard_offline_page_store+0x55/0xa0 kernfs_fop_write_iter+0x12c/0x1d0 vfs_write+0x380/0x540 ksys_write+0x64/0xe0 do_syscall_64+0xbc/0x1d0 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fdb74714887 RSP: 002b:00007ffdfc7074e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 000000000000000c RCX: 00007fdb74714887 RDX: 000000000000000c RSI: 00005653ec7c0e10 RDI: 0000000000000001 RBP: 00005653ec7c0e10 R08: 00007fdb747d1460 R09: 000000007fffffff R10: 0000000000000000 R11: 0000000000000246 R12: 000000000000000c R13: 00007fdb7481b780 R14: 00007fdb74817600 R15: 00007fdb74816a00 Modules linked in: mce_inject hwpoison_inject CR2: dead000000000108 ---[ end trace 0000000000000000 ]--- RIP: 0010:enqueue_hugetlb_folio+0x46/0xe0 RSP: 0018:ffff9e0207f03d10 EFLAGS: 00000046 RAX: 0000000000000000 RBX: 0000000000000000 RCX: dead000000000122 RDX: ffffcbb244460008 RSI: dead000000000100 RDI: ffff976a09da6f90 RBP: ffffcbb244460000 R08: 0000000000000001 R09: 0000000000000001 R10: 0000000000000001 R11: 7a088d6100000000 R12: ffffffffbcc93160 R13: 0000000000000246 R14: 0000000000000000 R15: 0000000000000000 FS: 00007fdb749b1740(0000) GS:ffff97711fc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: dead000000000108 CR3: 00000001078ac000 CR4: 00000000000006f0 Kernel panic - not syncing: Fatal exception Kernel Offset: 0x38a00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff) ---[ end Kernel panic - not syncing: Fatal exception ]--- The root cause is that list_del() is used to remove folio from list when dissolve_free_hugetlb_folio(). But list_move() might be used to reenqueue hugetlb folio when free_huge_folio() leading to above panic. Fix this issue by using list_del_init() to remove folio. Signed-off-by: Miaohe Lin --- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 1da9a14a5513..08634732dca4 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1642,7 +1642,7 @@ static void __remove_hugetlb_folio(struct hstate *h, struct folio *folio, if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) return; - list_del(&folio->lru); + list_del_init(&folio->lru); if (folio_test_hugetlb_freed(folio)) { h->free_huge_pages--;