linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lv Ying <lvying6@huawei.com>
To: Shuai Xue <xueshuai@linux.alibaba.com>, <rafael@kernel.org>,
	<lenb@kernel.org>, <james.morse@arm.com>, <tony.luck@intel.com>,
	<bp@alien8.de>, <naoya.horiguchi@nec.com>, <linmiaohe@huawei.com>,
	<akpm@linux-foundation.org>, <ashish.kalra@amd.com>
Cc: <xiezhipeng1@huawei.com>, <wangkefeng.wang@huawei.com>,
	<xiexiuqi@huawei.com>, <tanxiaofei@huawei.com>,
	<linux-acpi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-mm@kvack.org>, Bixuan Cui <cuibixuan@linux.alibaba.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	<yingwen.cyw@alibaba-inc.com>
Subject: Re: [RFC 1/2] ACPI: APEI: Make memory_failure() triggered by synchronization errors execute in the current context
Date: Thu, 8 Dec 2022 10:20:26 +0800	[thread overview]
Message-ID: <e7d66b23-ce62-4a50-91c3-29aaa41d2e90@huawei.com> (raw)
In-Reply-To: <c779d666-4937-e2dc-2d52-da0e49d5d1ac@linux.alibaba.com>


> 
> We also encountered this problem in production environment, and tried to
> solve it by dividing synchronous and asynchronous error handling into different
> paths: task work for synchronous error and workqueue for asynchronous error.
> 
> The main challenge is how to distinguish synchronous errors in kernel first
> mode through APEI, a related discussion is here.[1]
>
Hi Shuai:

I'm very happy to have received your response, we encountered this 
problem in our production environment too. I spent a lot of time 
researching the rationale for synchronous errors and asynchronous errors 
to share the same process. I mention in my patch commit message: 
memory_failure() triggered by synchronous error is
executed in the kworker context, the early_kill mode of memory_failure() 

will send wrong si_code by SIGBUS signal because of wrong current process.

The challenge for my patch is to prove the rationality of distinguishing 
synchronous errors. I do not have a good idea of distinguishing 
synchronous error by looking through ACPI/UEFI spec, so I sent this 
patchset for more input. And I resent RFC PATCH v1 [1]add this as TODO.

>> @@ -978,14 +979,14 @@ static void ghes_proc_in_irq(struct irq_work *irq_work)
>>   		estatus = GHES_ESTATUS_FROM_NODE(estatus_node);
>>   		len = cper_estatus_len(estatus);
>>   		node_len = GHES_ESTATUS_NODE_LEN(len);
>> -		task_work_pending = ghes_do_proc(estatus_node->ghes, estatus);
>> +		corruption_page_pending = ghes_do_proc(estatus_node->ghes, estatus, true);
>>   		if (!ghes_estatus_cached(estatus)) {
>>   			generic = estatus_node->generic;
>>   			if (ghes_print_estatus(NULL, generic, estatus))
>>   				ghes_estatus_cache_add(generic, estatus);
>>   		}
> 
> In the case of your patch, it is inappropriate to assume that ghes_proc_in_irq() is only
> called to handle synchronous error. Firmware could notify all synchronous and asynchronous
> error signals to kernel through NMI notification, e.g. SDEI. In this case, asynchronous
> error will be treated as synchronous error.
> 

Yes, as I mentioned above, I do not have a good idea of distinguishing 
synchronous error. I agree with you that ghes_proc_in_irq() is called in 
SDEI, SEA, NMI notify type, they are NMI-like notify, this function run 
some job which may not be NMI safe in IRQ context. And NMI may be 
asynchronous error.

However, cureent kernel use ghes_kick_task_work in ghes_proc_in_irq(), 
there is an assumption here that ghes_proc_in_irq() are currently in the 
context of a synchronous exception, although this is not appropriate.

> Our colleague Yingwen has submitted a proposal to extend acpi_hest_generic_data::flag (bit 8)
> to indicate that the error is a synchronous[2]. Personally speaking, it is a more general
> solution and completely solves the problem.
> 
> 
>> Background:
>>
>> In ARM world, two type events (Sync/Async) from hardware IP need OS/VMM take different actions.
>> Current CPER memory error record is not able to distinguish sync/async type event right now.
>> Current OS/VMM need to take extra actions beyond CPER which is heavy burden to identify the
>> two type events
>>
>> Sync event (e.g. CPU consume poisoned data) --> Firmware  -> CPER error log  --> OS/VMM take recovery action.
>> Async event (e.g. Memory controller detect UE event)  --> Firmware  --> CPER error log  --> OS take page action.
>>
>>
>> Proposal:
>>
>> - In section description Flags field(UEFI spec section N.2, add sync flag as below. OS/VMM
>>   could depend on this flag to distinguish sync/async events.
>> - Bit8 – sync flag; if set this flag indicates that this event record is synchronous(e.g.
>>   cpu core consumes poison data, then cause instruction/data abort); if not set, this event record is asynchronous.
>>
>> Best regards,
>> Yingwen Chen
> 
> A RFC patch set based on above proposal is here[3].
> 

I'm glad your team is working on advancing this thing in the UEFI 
community. This will make kernel identify synchronous as an easy job. 
Based on your proposal, I think your work is suitable.

However, there are real problems here in the running production 
environment of the LTS kernel:
1. this new proposal has not yet been accepted by the UEFI spec
2. it will require firmware update in production environment which may 
be more difficult than kernel livepatch upgrade.

If there are more ways to distinguish synchronous error in kernel APEI,
I can try it. For example, in APEI mode, is it suitable to use notify 
type to distinguish synchronous error?
synchronous error:
SDEI SEA
asynchronous error:
NMI

[1] 
https://lore.kernel.org/linux-mm/20221207093935.1972530-1-lvying6@huawei.com/T/


-- 
Thanks!
Lv Ying


  reply	other threads:[~2022-12-08  2:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05 11:51 [RFC 0/2] ACPI: APEI: Make synchronization errors call and Lv Ying
2022-12-05 11:51 ` [RFC 1/2] ACPI: APEI: Make memory_failure() triggered by synchronization errors execute in the current context Lv Ying
2022-12-07 10:57   ` Shuai Xue
2022-12-08  2:20     ` Lv Ying [this message]
2022-12-08  3:25       ` Shuai Xue
2022-12-08  7:16         ` Lv Ying
2022-12-08  2:37     ` Xie XiuQi
2022-12-08  3:41       ` Shuai Xue
2022-12-05 11:51 ` [RFC 2/2] ACPI: APEI: fix reboot caused by synchronous error loop because of memory_failure() failed Lv Ying
2022-12-07 12:29   ` Bixuan Cui
2022-12-08  2:44     ` Lv Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e7d66b23-ce62-4a50-91c3-29aaa41d2e90@huawei.com \
    --to=lvying6@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=ashish.kalra@amd.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=bp@alien8.de \
    --cc=cuibixuan@linux.alibaba.com \
    --cc=james.morse@arm.com \
    --cc=lenb@kernel.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=naoya.horiguchi@nec.com \
    --cc=rafael@kernel.org \
    --cc=tanxiaofei@huawei.com \
    --cc=tony.luck@intel.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=xiexiuqi@huawei.com \
    --cc=xiezhipeng1@huawei.com \
    --cc=xueshuai@linux.alibaba.com \
    --cc=yingwen.cyw@alibaba-inc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox