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 5A572C61DF7 for ; Sat, 25 Nov 2023 06:45:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A814B6B0171; Sat, 25 Nov 2023 01:45:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A07B96B0174; Sat, 25 Nov 2023 01:45:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 880C16B0176; Sat, 25 Nov 2023 01:45:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6F3156B0171 for ; Sat, 25 Nov 2023 01:45:05 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 465ADA014E for ; Sat, 25 Nov 2023 06:45:05 +0000 (UTC) X-FDA: 81495539370.21.F77C012 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf05.hostedemail.com (Postfix) with ESMTP id B29A410000F for ; Sat, 25 Nov 2023 06:45:01 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700894703; 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=hcPyQe2QUY7mBcBNeTxC/x/O1Jwo7YD4AKmTODb+oPU=; b=lS34gwYZjUvTkO8fhg4UWzujzFzyRVkErhpdqZXWqxNLA8+pcqpTPPgQzUd17t518HzTK0 ERpUyR2AjFIOfAqyxH3BGxfpwTY7T6vIud3OINbrjehrhTr3PWcvEK22/0nTzW3cN8mMWk iQE6OqQUlTokxpiTFWThayYofS8k93A= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700894703; a=rsa-sha256; cv=none; b=w6RQjmV9u3+5yYGKAvVx+O6q8DslJgI3VV/JtzxjXxH/VTZcr419JARKifNkaRcryhYDCE 47AIckrNq+x2g49vZfFs+DrdL6eTNa3tcw8PD25VJfYOkc++kC98XaUXYYpwo/QeQWz7Dn 5h1cwHUAA1p4ZqolGmqdsKGVp6LrVu4= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=xueshuai@linux.alibaba.com;NM=1;PH=DS;RN=34;SR=0;TI=SMTPD_---0Vx3Rwaa_1700894693; Received: from 30.240.112.178(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0Vx3Rwaa_1700894693) by smtp.aliyun-inc.com; Sat, 25 Nov 2023 14:44:57 +0800 Message-ID: <9e92e600-86a4-4456-9de4-b597854b107c@linux.alibaba.com> Date: Sat, 25 Nov 2023 14:44:52 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 0/2] ACPI: APEI: handle synchronous errors in task work with proper si_code Content-Language: en-US To: Borislav Petkov Cc: rafael@kernel.org, wangkefeng.wang@huawei.com, tanxiaofei@huawei.com, mawupeng1@huawei.com, tony.luck@intel.com, linmiaohe@huawei.com, naoya.horiguchi@nec.com, james.morse@arm.com, gregkh@linuxfoundation.org, will@kernel.org, jarkko@kernel.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, linux-edac@vger.kernel.org, acpica-devel@lists.linuxfoundation.org, stable@vger.kernel.org, x86@kernel.org, justin.he@arm.com, ardb@kernel.org, ying.huang@intel.com, ashish.kalra@amd.com, baolin.wang@linux.alibaba.com, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, lenb@kernel.org, hpa@zytor.com, robert.moore@intel.com, lvying6@huawei.com, xiexiuqi@huawei.com, zhuo.song@linux.alibaba.com References: <20221027042445.60108-1-xueshuai@linux.alibaba.com> <20231007072818.58951-1-xueshuai@linux.alibaba.com> <20231123150710.GEZV9qnkWMBWrggGc1@fat_crate.local> From: Shuai Xue In-Reply-To: <20231123150710.GEZV9qnkWMBWrggGc1@fat_crate.local> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: B29A410000F X-Rspam-User: X-Stat-Signature: 8yiq9o4rhp3ogtbygggmj4xgdqyinhmx X-Rspamd-Server: rspam01 X-HE-Tag: 1700894701-761613 X-HE-Meta: U2FsdGVkX1/xQFtZrRDdqTna9Qwbk5cSmoYjjNMr+52TUyu/uaVSTpTbXpTz7VPSPt6AGkdL7V+6l8Ml+NE3c42iUbo1mSq34ZQHyEmkKRAAPWl2IKZRxEpNzSiJbqDYaoSpmhv44qpHqltiHQ3O9oVzg2gfRah6bIcko0YNYUNyO6tAQlu884BIOUVdiWikVlMf3p4r2zPY4qtc+fyjsq9zjfBEG1c/mNk/t3H5FW1ppg4QoZKuQeS9j981TCE3TwiK8la5ndQZ8NL8OVCDdtMVrS6n0PPBzM70fu0M4kX4AcvqHwpQ2KCkjTvil25kjsP6CA9aWdua+6zCvWpds0bxn+9OVdw2zE2jSVTMP42n4iIRWTypf5GnAKJiUthlGDzS2Ulgf30kleInsRV5cB9/EUmKBt52Ig/8rFjWIWGB9lpdg+jd+VOnfWQicOP9rguQo56TqWMxvGSxz05vqfpF5TjM+6pqSfTglgGAOGydJgTBP4DCZwNdnF6btg7gpXietun/1kHoAt/32Q6egGrpUwoOos9hFLbD4pXAo74Y8bBaua2O1L8d0jXVbTEL5VKxZdwq+5YQ7AGUcHVAoxeY86w/svuFCVKTBzOtIUKx2GE0GVmy7adM9X8G0fYb21Lvou59rpNv8p61s18jAzY9bua8mp45jnM/q0z2lgC/6VENfBtmasThG2fth8UxeOHzUGlVd/R0DwFNrWsvpKqE9LuTm1kbdrOhfwsXKcXgLY4cFFaQwEfUhBrry33ZYmLWqU2uotfRElSGKgQT+ieK6Samn6SCYhq1lhd+d2NwdFImldfou5JLsynaMxbpc9zzlFn1RzCHuOaAY5PiU+nsiIctItOvAm9/2Nl20iA49OVovrYV/PKQxMkX/qbQAsorLxl+obl5fTt3ixHXq7RoSBXXEE6WyoxCjUhIivCq/P7IzXGDF5IFe55P//grDYy0nhD6dkkIPdLyDkz H+KRc16+ lpI3o2kDvXEz+WpWz3bS/tp7lJNqHReNog5sZ3TBhjZf8+byCgMayfMcizI0d7eo7pAscLqZ+ElwFyFjdJ02PWHVhrS4u1tVBeGgcV1un0epTvj2uTEd5+wm7eTk79hKEgB9wtCDqpt0ZNcVg5y1Z7ez4Gy8a8E9ntQ4O 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 2023/11/23 23:07, Borislav Petkov wrote: Hi, Borislav, Thank you for your reply and advice. > On Sat, Oct 07, 2023 at 03:28:16PM +0800, Shuai Xue wrote: >> However, this trick is not always be effective > > So far so good. > > What's missing here is why "this trick" is not always effective. > > Basically to explain what exactly the problem is. I think the main point is that this trick for AR error is not effective, because: - an AR error consumed by current process is deferred to handle in a dedicated kernel thread, but memory_failure() assumes that it runs in the current context - another page fault is not unnecessary, we can send sigbus to current process in the first Synchronous External Abort SEA on arm64 (analogy Machine Check Exception on x86) > >> For example, hwpoison-aware user-space processes use the si_code: >> BUS_MCEERR_AO for 'action optional' early notifications, and BUS_MCEERR_AR >> for 'action required' synchronous/late notifications. Specifically, when a >> signal with SIGBUS_MCEERR_AR is delivered to QEMU, it will inject a vSEA to >> Guest kernel. In contrast, a signal with SIGBUS_MCEERR_AO will be ignored >> by QEMU.[1] >> >> Fix it by seting memory failure flags as MF_ACTION_REQUIRED on synchronous events. (PATCH 1) > > So you're fixing qemu by "fixing" the kernel? > > This doesn't make any sense. I just give an example that the user space process *really* relys on the si_code of signal to handle hardware errors > > Make errors which are ACPI_HEST_NOTIFY_SEA type return > MF_ACTION_REQUIRED so that it *happens* to fix your use case. > > Sounds like a lot of nonsense to me. > > What is the issue here you're trying to solve? The SIGBUS si_codes defined in include/uapi/asm-generic/siginfo.h says: /* hardware memory error consumed on a machine check: action required */ #define BUS_MCEERR_AR 4 /* hardware memory error detected in process but not consumed: action optional*/ #define BUS_MCEERR_AO 5 When a synchronous error is consumed by Guest, the kernel should send a signal with BUS_MCEERR_AR instead of BUS_MCEERR_AO. > >> 2. Handle memory_failure() abnormal fails to avoid a unnecessary reboot >> >> If process mapping fault page, but memory_failure() abnormal return before >> try_to_unmap(), for example, the fault page process mapping is KSM page. >> In this case, arm64 cannot use the page fault process to terminate the >> synchronous exception loop.[4] >> >> This loop can potentially exceed the platform firmware threshold or even trigger >> a kernel hard lockup, leading to a system reboot. However, kernel has the >> capability to recover from this error. >> >> Fix it by performing a force kill when memory_failure() abnormal fails or when >> other abnormal synchronous errors occur. > > Just like that? > > Without giving the process the opportunity to even save its other data? Exactly. > > So this all is still very confusing, patches definitely need splitting > and this whole thing needs restraint. > > You go and do this: you split *each* issue you're addressing into > a separate patch and explain it like this: > > --- > 1. Prepare the context for the explanation briefly. > > 2. Explain the problem at hand. > > 3. "It happens because of <...>" > > 4. "Fix it by doing X" > > 5. "(Potentially do Y)." > --- > > and each patch explains *exactly* *one* issue, what happens, why it > happens and just the fix for it and *why* it is needed. > > Otherwise, this is unreviewable. Thank you for your valuable suggestion, I will split the patches and resubmit a new patch set. > > Thx. > Best Regards, Shuai