From mboxrd@z Thu Jan 1 00:00:00 1970 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 D3363C3A59D for ; Sun, 7 Apr 2024 03:59:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 167F76B0082; Sat, 6 Apr 2024 23:59:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 118BA6B0083; Sat, 6 Apr 2024 23:59:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0065A6B0085; Sat, 6 Apr 2024 23:59:42 -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 D70596B0082 for ; Sat, 6 Apr 2024 23:59:42 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7B0B18073C for ; Sun, 7 Apr 2024 03:59:42 +0000 (UTC) X-FDA: 81981381804.09.40BA18C Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf04.hostedemail.com (Postfix) with ESMTP id 0BC2B40002 for ; Sun, 7 Apr 2024 03:59:38 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712462380; 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=vZ2/9oo4sWmmDsWfo/fkEq4esDTob3nE5/Z/zXz9gIY=; b=qzGQZGAAfB4+/HqMJgA3SpMgpyeUupapB29nsLKw8IV1HUSFu70MLpFxWdWu3j+Got3nd1 8GkZefQjeBaKWm15L9mxYcgrHKqtWloOAXRTkHhphaCelqMP9FQs8A3GCiDIxLzta5lWbo JGQRoI4kx/Sben6tbRO1vNsmjZ8QZOQ= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712462380; a=rsa-sha256; cv=none; b=YtZ7KPs9uZh5AI6t1ceos813LECdlXn0TVntLQhihK+Cj8Dy069wdiODdBxsYTGsk4Rl1I g8QNTyIvlbwK/JYT0Z3cSb5flQMm5FVG+LeTFQB3EK2HRfBUJHEJ9NBTF08pRmDjMtY4N4 Wwfl+iUTublyF1yxmFpI/u4qcFVI35g= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VBz1g1dfvz1QCTH; Sun, 7 Apr 2024 11:56:55 +0800 (CST) Received: from canpemm500002.china.huawei.com (unknown [7.192.104.244]) by mail.maildlp.com (Postfix) with ESMTPS id 3D3B0180073; Sun, 7 Apr 2024 11:59:34 +0800 (CST) Received: from [10.173.135.154] (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; Sun, 7 Apr 2024 11:59:33 +0800 Subject: Re: Machine check recovery broken in v6.9-rc1 To: "Luck, Tony" , Oscar Salvador CC: David Hildenbrand , Borislav Petkov , Yazen Ghannam , Naoya Horiguchi , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" References: <1e943439-6044-4aa4-8c41-747e9e4dca27@redhat.com> From: Miaohe Lin Message-ID: <3e49dd21-0aea-c7ac-1633-91764e759bf7@huawei.com> Date: Sun, 7 Apr 2024 11:59:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.173.135.154] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-Rspamd-Queue-Id: 0BC2B40002 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: iihsmbe3z6cf4jkpk8w9s41depu67siu X-HE-Tag: 1712462378-685758 X-HE-Meta: U2FsdGVkX1/Z4KXw5/jKpQN63RmBkANtGyVJziFsQPRMLQe0uw4AFKJE9v0QX2Smo3FOVX/VpBWIq/lUm7HHj7gK0mLOR/HR5C6fkaLErP3Z5mZvXwkEYSLchQ2h+2EUG09Cv7YkdvYNZ1bMTdu0nVBxLORk8aK5J6tKxnG+EsxfWGPg70wciR0asfx07yoCIRNRlRl1biBTndJGpL7GxbeQ3mZQIsSp58oYQ3cXp8mLFT1gCVGUueYh0cor283FxXqSmE4lcqpBIDW9K2OojGZSaHaKWYIaOSSlsHL7rKv3uFRPsGhxf90VDutXl1U74OXCXqsCvO5wOF6NrjH5D14x6zFq3gjc6Sjd8XHswYVsvt0Uxg9tSnaFS+CJQOCuqWTr+3AmSaBF4SicktWa21qBYvkYxmcWuK+3BohJL0rNqfrPRfXT6IOcg9fmKpSLIPlaicuWHtRe6hnDKs0XWve6aOE1FzvDQQP3yDvuQJrUypu4zPyt5UfZuRoqst8n4XTG/kqGQHsnZ5SlrNgZofREeupH6wsPMnNa3MuhnCDOzD1BESGPS0AtXguy3O5TxaiYs58Jyp/QSUhJ0UhfziAQ3Ft9/1fFJcHMiufY96s60RDSf5P8y3UewJ2pCao9MOTaQ1XcNhw33yOKijlFcNxiQtJUnzHUgL8Wrl+tghfSdln9uk+JW407gRjr8iN7zUkkBz29ggVAuOl9D0fu/+WHSDwlJhI22pkd+QzfKqSQX0eg2S2McGFBeMRZxAKVWZNpt1tm8FQTYgCXDHFvZJLYLtS3z05Tl64kCZlqOTN+VGC+tJ8IkauX+A2fnZGJVVSCZM7Sz/KB8iJH7RSIrGctZPgvyZVV9CWJSyve93mqGrs3Bx5fcOIXGTH/reHcr2EASNJv/Z8AuMWW57QGmW+Ox5u5sg1F7Jq9LyCI2EDtzYTRpsfK263+rU+SxrgZwtWZrwGO+wrjvNRRKg7 r8sEYm77 UIjBZGLCW5PJWCGfnKlgryQBhf5E4MYihAwXChkUO4jvYKrXn9YShcrT6JHQebup/7OnNoRYK5hAEwqgKq1xCEe9hRATWoMRllJ678d6OhAR9mAVzuZ6Ee/KUacC53Yv4TlJ++8pGfbIqmfBf82uBtmQBEuzbeH1KlXHO5NFWRDziFcQ2JvPHgdYH3wdUK/Lf+5OQvfwjIzW4zDdpV54V1UxkeN0JE/+GZnJs 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: On 2024/4/7 8:08, Luck, Tony wrote: >> This one is against 6.1 (previous one was against v6.9-rc2): >> Again, compile tested only > > Oscar. > > Both the 6.1 and 6.9-rc2 patches make the BUG (and subsequent issues) go away. > > Here's what's happening. > > When the machine check occurs there's a scramble from various subsystems > to report the memory error. > > ghes_do_memory_failure() calls memory_failure_queue() which later > calls memory_failure() from a kernel thread. Side note: this happens TWICE > for each error. Not sure yet if this is a BIOS issue logging more than once. > or some Linux issues in acpi/apei/ghes.c code. > > uc_decode_notifier() [called from a different kernel thread] also calls > do_memory_failure() > > Finally kill_me_maybe() [called from task_work on return to the application > when returning from the machine check handler] also calls memory_failure() > > do_memory_failure() is somewhat prepared for multiple reports of the same > error. It uses an atomic test and set operation to mark the page as poisoned. > > First called to report the error does all the real work. Late arrivals take a > shorter path, but may still take some action(s) depending on the "flags" > passed in: > > if (TestSetPageHWPoison(p)) { > pr_err("%#lx: already hardware poisoned\n", pfn); > res = -EHWPOISON; > if (flags & MF_ACTION_REQUIRED) > res = kill_accessing_process(current, pfn, flags); > if (flags & MF_COUNT_INCREASED) > put_page(p); > goto unlock_mutex; > } > > In this case the last to arrive has MF_ACTION_REQUIRED set, so calls > kill_accessing_process() ... which is in the stack trace that led to the: > > kernel BUG at include/linux/swapops.h:88! > > I'm not sure that I fully understand your patch. I guess that it is making sure to > handle the case that the page has already been marked as poisoned? > > > Anyway ... thanks for the quick fix. I hope the above helps write a good > commit message to get this applied and backported to stable. Sorry for late. I was just back from my vacation. > > Tested-by: Tony Luck Thanks for both. This should be a issue introduced from commit: 0d206b5d2e0d ("mm/swap: add swp_offset_pfn() to fetch PFN from swap entry") hwpoison_entry_to_pfn() is replaced with swp_offset_pfn() which might not be intended to be used with hwpoison entry: /* * A pfn swap entry is a special type of swap entry that always has a pfn stored * in the swap offset. *They are used to represent unaddressable device memory* * *and to restrict access to a page undergoing migration* */ static inline bool is_pfn_swap_entry(swp_entry_t entry) { /* Make sure the swp offset can always store the needed fields */ BUILD_BUG_ON(SWP_TYPE_SHIFT < SWP_PFN_BITS); return is_migration_entry(entry) || is_device_private_entry(entry) || is_device_exclusive_entry(entry); } I think Oscar's patch is the right fix and it will be better to amend the corresponding comment too. Thanks. > > -Tony > > > > > > . >