Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp261642iog; Wed, 15 Jun 2022 01:37:07 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tTA+L0Z7dEvbcziyfV8JE5vYAWqxJh+M3Iw0wxgS3Pi0H2OqSM3RiuInC2Z/H5rRu0mYJe X-Received: by 2002:a17:90a:7606:b0:1e8:9e2a:d87c with SMTP id s6-20020a17090a760600b001e89e2ad87cmr8977750pjk.226.1655282226808; Wed, 15 Jun 2022 01:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655282226; cv=none; d=google.com; s=arc-20160816; b=RyZCDiVnCiUTXfWsBuqzxTpR1g0Vgo6sXO0DA2zUPc1WXyk6CTzwpQxkI6vDouLWH/ 14DXxXKPqCAGCBHpCbjYO1hGc5HdLqob5D7Lnp5U/GaiSNfnv1urU9rh8vgEpwtAJbtJ 9D8P0hDVbo1vVOG9sEfyLMkslKhrrYKtomm2Z0d0MyFdSzB6vB2ABSU4zIkb7l/NbEkR Mp/D7Tbs/t7j0AyT8WS2PM9DxILtMw0bLj3JeScC+NtZtBycJ9NPsUPV3gQUb+JFvL21 0IlJa32CG2GEfZkpIhSKVRzHPsgGLXstzhHDPcakCad3bpMN9GwFQ4AihS9lnZgFbcE8 E+4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=81h1Uc0DDfOP7V1sbgrcsSnTyG++26Urw3Gv8Z70W2M=; b=kOMg8mXFGtGV3d07et/b/hOF/h19K6ENk+fXyfFzvpXfazle6+8JlbPzrywn/wfKYX ha6GEQH76O8BQqs1iDi0wuCPyjWul3Nauv53A4b3RFPmxdAVO2qy2jQIVPIHutJtaf87 wbIBt8knGcVTy2XXf6hZmItXDC+UKxOxC70t67fNnE//UGGJPVORTmJIjkme4+eE6CZD gClDRYSUlb01OINb3ezxSOqxkmvzYyea9bUOxrB7Wh6bhuTsGPjwghcNKiA8318hUr6C 8W8eBWj/blycuWVbqNgsbKWIo6xmJ2ltdMPX0bOlR/VIdEJ9ZQ4MkZbXhAHFCOzlBp5I fuBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=T+qtPXVU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d19-20020a63f253000000b003fc6a2458b4si1985516pgk.770.2022.06.15.01.36.53; Wed, 15 Jun 2022 01:37:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=T+qtPXVU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243934AbiFOIVR (ORCPT + 99 others); Wed, 15 Jun 2022 04:21:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243698AbiFOIVQ (ORCPT ); Wed, 15 Jun 2022 04:21:16 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 74A78286EE for ; Wed, 15 Jun 2022 01:21:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655281274; h=from:from: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=81h1Uc0DDfOP7V1sbgrcsSnTyG++26Urw3Gv8Z70W2M=; b=T+qtPXVU7Jf/JXD286dNspuHLQpqbo3Y2IQWaaJZzBJMmE3Sy7HebIjxEbtLAM8JoZZSYi HhsbzlPxs71+P0Q3R8VKKAdj5QtR8n5Wd2Hiyqjbe7Ud7whE8a+vhWQUoO1PlvmtLXm1tc zrTCnfYrZDfz/ADtIHoqDUREL+wbsps= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-29-aDxm7oAtOTeu2opLG9vImw-1; Wed, 15 Jun 2022 04:21:11 -0400 X-MC-Unique: aDxm7oAtOTeu2opLG9vImw-1 Received: by mail-wm1-f70.google.com with SMTP id p18-20020a05600c23d200b0039c40c05687so4795085wmb.2 for ; Wed, 15 Jun 2022 01:21:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=81h1Uc0DDfOP7V1sbgrcsSnTyG++26Urw3Gv8Z70W2M=; b=rqXSU4cZfAiwnz0IZQm5OWiOoTY6uECFTTark9r4G4PTw5WkyIuRmSqXz7ZqSmiFOZ grZt1ARJP2ot0sAKxT1EKQcxh6uj2XNOG59DQ4yBF9Zu92hx3kuDUtF1Qz0lSXPy+AnQ slyVrbLMxd2YPOiyEmuZposm0JDelH1FcKRJORUcpBdf3VOEwkxszpNW5+QgLZ8djzjV T8gyhTTpBOrfuIFMgGavNo1RiHTDzZrNRkUNcDFOTdCbHIOHQgVw+sdD3uAQst45SMVx Xmq4HjH3K+spKPFp7hSTbPXdQCcVUVoHkN2dcAJCwmj4Alng9l+kVuOgR9EotnDtrJDm JM5Q== X-Gm-Message-State: AOAM533jUGkidzZfk5ROn2Q+55BxaJglMUx4FYyfpVsHgqzMywCYex2r rEP+KMVrPMk8Vl6DyazveVZ/21UvsvHMNEBXZbZbPBauV2lejfz6YpnHjtoLuJzwWlwicQUJ8Ct 8DX4a1Qfm71OL420Ao31LefuQ X-Received: by 2002:a7b:c1d4:0:b0:39c:4176:6a16 with SMTP id a20-20020a7bc1d4000000b0039c41766a16mr8620509wmj.8.1655281270585; Wed, 15 Jun 2022 01:21:10 -0700 (PDT) X-Received: by 2002:a7b:c1d4:0:b0:39c:4176:6a16 with SMTP id a20-20020a7bc1d4000000b0039c41766a16mr8620483wmj.8.1655281270305; Wed, 15 Jun 2022 01:21:10 -0700 (PDT) Received: from ?IPV6:2003:cb:c70a:2700:1d28:26c3:b272:fcc6? (p200300cbc70a27001d2826c3b272fcc6.dip0.t-ipconnect.de. [2003:cb:c70a:2700:1d28:26c3:b272:fcc6]) by smtp.gmail.com with ESMTPSA id m5-20020a056000008500b00213d75491b0sm13817986wrx.48.2022.06.15.01.21.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Jun 2022 01:21:09 -0700 (PDT) Message-ID: <425e44e9-6ec3-9a87-3441-78881f561a06@redhat.com> Date: Wed, 15 Jun 2022 10:21:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v5 1/1] mm/memory-failure: disable unpoison once hw error happens Content-Language: en-US To: =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= , zhenwei pi Cc: "akpm@linux-foundation.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "linmiaohe@huawei.com" , "gregkh@linuxfoundation.org" References: <20220615020005.246295-1-pizhenwei@bytedance.com> <20220615020005.246295-2-pizhenwei@bytedance.com> <20220615081521.GB1663556@hori.linux.bs1.fc.nec.co.jp> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220615081521.GB1663556@hori.linux.bs1.fc.nec.co.jp> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15.06.22 10:15, HORIGUCHI NAOYA(堀口 直也) wrote: > On Wed, Jun 15, 2022 at 10:00:05AM +0800, zhenwei pi wrote: >> Currently unpoison_memory(unsigned long pfn) is designed for soft >> poison(hwpoison-inject) only. Since 17fae1294ad9d, the KPTE gets >> cleared on a x86 platform once hardware memory corrupts. >> >> Unpoisoning a hardware corrupted page puts page back buddy only, >> the kernel has a chance to access the page with *NOT PRESENT* KPTE. >> This leads BUG during accessing on the corrupted KPTE. >> >> Suggested by David&Naoya, disable unpoison mechanism when a real HW error >> happens to avoid BUG like this: > ... > >> >> Fixes: 847ce401df392 ("HWPOISON: Add unpoisoning support") >> Fixes: 17fae1294ad9d ("x86/{mce,mm}: Unmap the entire page if the whole page is affected and poisoned") >> Cc: Naoya Horiguchi >> Cc: David Hildenbrand >> Signed-off-by: zhenwei pi > > Cc to stable? > I think that the current approach seems predictable to me than earlier versions, > so I can agree with sending this to stable a little more confidently. > >> --- >> Documentation/vm/hwpoison.rst | 3 ++- >> drivers/base/memory.c | 2 +- >> include/linux/mm.h | 1 + >> mm/hwpoison-inject.c | 2 +- >> mm/madvise.c | 2 +- >> mm/memory-failure.c | 12 ++++++++++++ >> 6 files changed, 18 insertions(+), 4 deletions(-) >> > > ... > >> diff --git a/mm/memory-failure.c b/mm/memory-failure.c >> index b85661cbdc4a..385b5e99bfc1 100644 >> --- a/mm/memory-failure.c >> +++ b/mm/memory-failure.c >> @@ -69,6 +69,8 @@ int sysctl_memory_failure_recovery __read_mostly = 1; >> >> atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0); >> >> +static bool hw_memory_failure; > > Could you set the initial value explicitly? Using a default value is good, > but doing as the surrounding code do is better for consistency. And this > variable can be updated only once, so adding __read_mostly macro is also fine. No strong opinion. __read_mostly makes sense, but I assume we don't really care about performance that much when dealing with HW errors. With or without changes around this initialization Acked-by: David Hildenbrand -- Thanks, David / dhildenb