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 7DCE3CE7A81 for ; Mon, 25 Sep 2023 14:43:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 99B0E6B016D; Mon, 25 Sep 2023 10:43:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 949276B016F; Mon, 25 Sep 2023 10:43:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EE246B0171; Mon, 25 Sep 2023 10:43:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6C2D46B016D for ; Mon, 25 Sep 2023 10:43:33 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 28ABF16071E for ; Mon, 25 Sep 2023 14:43:33 +0000 (UTC) X-FDA: 81275388306.16.2D7AEC5 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf06.hostedemail.com (Postfix) with ESMTP id 752DE18001E for ; Mon, 25 Sep 2023 14:43:29 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qw77X9fk; spf=pass (imf06.hostedemail.com: domain of jarkko@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jarkko@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695653010; 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:dkim-signature; bh=YtbvCkOfeIQBXRIQ7T8EjU2PDb1ifWMvDHkBrDbRj2A=; b=FBkUlwMpplqq48rKXVh8udQYfclOvBaXi7sWwh7OXGEjbSM+zVRd5l3PWLl8jEzu+cG3ro Bgt9jVVT5wx64JlxjBEMFsE++fohq0Gfk1GfNLEr5QSpUyMSVgMpuYfNaAlLF2UyMG2thF nTHM3d49JN/foJAJ6/FoBCxNK8kFYkg= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qw77X9fk; spf=pass (imf06.hostedemail.com: domain of jarkko@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jarkko@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695653010; a=rsa-sha256; cv=none; b=SqLCubYgtI7pfH9Ub5qnxmxj8ZhzV5LXOEYdtFLL0y4zuEb6tjEZCSUxlEFP11OHbyZehr 3PQ9Dgmlw0B8ozQFJxHMFB8lZ+k3+qIysVHAbzQWMCIJpyMrOB8UqPdh+OiIYf3DwvZt9O uBUuqYP+3CtD4Fi+wnyksM5t7dAN1Eo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B1166CE0FB5; Mon, 25 Sep 2023 14:43:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 693E4C433C7; Mon, 25 Sep 2023 14:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695653004; bh=zLu+VnRpIsjtnAXABy7BDzCTOqyINaVoPvsO++Hkwow=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=qw77X9fkt0hBOpDdvTU2WKmu46P3XwVZXqEmHv04wqXA/tZs4NgonJaHKf7T8MZAC oPNae1MmhWZ3eOq+eqzdXMUr7j7oPNnBXePU3V/yvxGYt+LT2sEv94UA86N3ssa4p9 fz6Z0JVoPlrWpHUK4hmHg0rA8lKjUp3uYG452ywN2dkQxUZlpqN4ML0W/HvnTG/LnR mQw58kFoNZmb/HPdqzWT0XPfhg/ijXT/GT5Lcx89pnr12GhQ1x5zAlOPlUT4HhfwTS xy1RrnkmKut5d1yXF7k93DE2LrJT+5zXjmyv4CnjDdS+Abrr+nZp1g5CeFrS7FcnLD QhF4td3R7tIOg== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 25 Sep 2023 17:43:15 +0300 Message-Id: Cc: , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [RESEND PATCH v8 1/2] ACPI: APEI: set memory failure flags as MF_ACTION_REQUIRED on synchronous events From: "Jarkko Sakkinen" To: "Shuai Xue" , , , , , , , , , , X-Mailer: aerc 0.14.0 References: <20221027042445.60108-1-xueshuai@linux.alibaba.com> <20230919022127.69732-2-xueshuai@linux.alibaba.com> In-Reply-To: <20230919022127.69732-2-xueshuai@linux.alibaba.com> X-Rspamd-Queue-Id: 752DE18001E X-Rspam-User: X-Stat-Signature: xfb1iw7rckqns3jxutga16nspq1gfbcg X-Rspamd-Server: rspam01 X-HE-Tag: 1695653009-632215 X-HE-Meta: U2FsdGVkX19xkq9qHtiBI5dQ1y2u8/3wDxbXzaoyJPgIh+7zLeWFZUal7rmyTOY3RjFeoRiHK3Sz2AQz23iURW1lGuBM9POyxOfxuRxzXSrWh8kdbQM5hUK12R0bjQFASZrCMldFguPZIh77kdYlxRZR3Qj3GDmlVDnYL02lu7J3eLGlcPWEcMKpGS7AYSL3WgniT+HV/53IJHxi02Rj888SqtySntUpTWjf/ylCEkSyP3Sjc1wV3EQTmO7aLz0XcqAuycNVyyFP+C1xTmIoEdEkCJ89Q10ZgoPvuFDNYzuQpMJclZxDoxNbfIuQh+/+3Ya51Daf8UlZYZQRnpBP2fpposoWl1hNzMBQ5AvTYa0zYSZyIbKS+57tfJKnev+YKdmJQlOyOETk7MiXespIppUXcu/YuUIWBtdo+ie2Fz006Jgli8cSDDKEFsI6zsBFkBCZqFAJa9kh9XQOoWfQRG+rCIQBTLkssus1b0ylwsH3+ny8BA5xDEdnJiIl1X+/M6eir8QxyBLJPBGilXN9ahQi+i2eBVHXFmHOXsBXXlP198VO+keb24/x5oALtzlg4HFCZKrnBxeD0PKsn+2SYTsiEuJPqjAXIE9YEdXfwEjBM10d+ok1GQxlGYKXlcT7Sk/uSAEm1mQDhrESt89GTWJmVQ0cq/GXtfU4AMAcaQ6Y46W59JtAuBc0Ty2QZwkJnhKOh3ZuyUUHQ4ze1zf4R16mXjZcySh2ASpU5qDIfk8iQH+Yo8J9NYD4rpVgbAn6/h8PX25yMDMbA0B3YRjOQEuGDDsCcO31UBWu83m3+k/EUdPBhrX/5GIsaf9YEpM1nKaNeqE+c6O4dqZosHdeJu/vd630tAMkM+BGnHZTN9ickXOwvW4HGWtKD/UCOsqvzqMrzzy1SUS3i0tumoNq0HFJRGMU+v0vZjRFuNWo0hOXg1E0SRJVS3KvI6qXj6TLyeLqpNt7ctBUS/UEvUd Rg1du7qJ aqe5VXfiqG++WljEdAoL3Ov2tb2kUsLk7sMbwy7ckta8Oc3F40Z5XWHffWuaZmjFpBEPdmOOqxbGWlyu0kniz8tr8/UQcqnUnYfn7oEINjmKxGiU3e3JqpW1prCgNhZdae5nzfxB3ZROutviFP6BoteU6+P7iCAkkp5COv9Kn+/7A3+dSy5HiH/YGCaV/6UGclznZiG1govXLR2At4W4A+po6ot8uzdqu6eBH+H1A8l4sYdwq9knFOn1cRTC8+chQomXtV/7aR8DM/17yNryGhCnWGj37JogsfLiWKPxrinEFgq0ZDM2GoahYJ/gYeUJFZV4A 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: On Tue Sep 19, 2023 at 5:21 AM EEST, Shuai Xue wrote: > There are two major types of uncorrected recoverable (UCR) errors : > > - Action Required (AR): The error is detected and the processor already > consumes the memory. OS requires to take action (for example, offline > failure page/kill failure thread) to recover this uncorrectable error. > > - Action Optional (AO): The error is detected out of processor execution > context. Some data in the memory are corrupted. But the data have not > been consumed. OS is optional to take action to recover this > uncorrectable error. > > The essential difference between AR and AO errors is that AR is a > synchronous event, while AO is an asynchronous event. The hardware will > signal a synchronous exception (Machine Check Exception on X86 and > Synchronous External Abort on Arm64) when an error is detected and the > memory access has been architecturally executed. > > When APEI firmware first is enabled, a platform may describe one error > source for the handling of synchronous errors (e.g. MCE or SEA notificati= on > ), or for handling asynchronous errors (e.g. SCI or External Interrupt > notification). In other words, we can distinguish synchronous errors by > APEI notification. For AR errors, kernel will kill current process > accessing the poisoned page by sending SIGBUS with BUS_MCEERR_AR. In > addition, for AO errors, kernel will notify the process who owns the > poisoned page by sending SIGBUS with BUS_MCEERR_AO in early kill mode. > However, the GHES driver always sets mf_flags to 0 so that all UCR errors > are handled as AO errors in memory failure. > > To this end, set memory failure flags as MF_ACTION_REQUIRED on synchronou= s > events. > > Fixes: ba61ca4aab47 ("ACPI, APEI, GHES: Add hardware memory error recover= y support")' > Signed-off-by: Shuai Xue > Tested-by: Ma Wupeng > Reviewed-by: Kefeng Wang > Reviewed-by: Xiaofei Tan > Reviewed-by: Baolin Wang > --- > drivers/acpi/apei/ghes.c | 29 +++++++++++++++++++++++------ > 1 file changed, 23 insertions(+), 6 deletions(-) > > diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c > index ef59d6ea16da..88178aa6222d 100644 > --- a/drivers/acpi/apei/ghes.c > +++ b/drivers/acpi/apei/ghes.c > @@ -101,6 +101,20 @@ static inline bool is_hest_type_generic_v2(struct gh= es *ghes) > return ghes->generic->header.type =3D=3D ACPI_HEST_TYPE_GENERIC_ERROR_V= 2; > } > =20 > +/* > + * A platform may describe one error source for the handling of synchron= ous > + * errors (e.g. MCE or SEA), or for handling asynchronous errors (e.g. S= CI > + * or External Interrupt). On x86, the HEST notifications are always > + * asynchronous, so only SEA on ARM is delivered as a synchronous > + * notification. > + */ > +static inline bool is_hest_sync_notify(struct ghes *ghes) > +{ > + u8 notify_type =3D ghes->generic->notify.type; > + > + return notify_type =3D=3D ACPI_HEST_NOTIFY_SEA; > +} > + > /* > * This driver isn't really modular, however for the time being, > * continuing to use module_param is the easiest way to remain > @@ -475,7 +489,7 @@ static bool ghes_do_memory_failure(u64 physical_addr,= int flags) > } > =20 > static bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gd= ata, > - int sev) > + int sev, bool sync) > { > int flags =3D -1; > int sec_sev =3D ghes_severity(gdata->error_severity); > @@ -489,7 +503,7 @@ static bool ghes_handle_memory_failure(struct acpi_he= st_generic_data *gdata, > (gdata->flags & CPER_SEC_ERROR_THRESHOLD_EXCEEDED)) > flags =3D MF_SOFT_OFFLINE; > if (sev =3D=3D GHES_SEV_RECOVERABLE && sec_sev =3D=3D GHES_SEV_RECOVERA= BLE) > - flags =3D 0; > + flags =3D sync ? MF_ACTION_REQUIRED : 0; Not my territory but this branching looks a bit weird to my eyes so just in case putting a comment. What *if* the previous condition sets MF_SOFT_OFFLINE and this condition overwrites the value? I know that earlier it could have been overwritten by zero. Neither the function comment has any explanation why it is ok overwrite like this. Or if these cannot happen simultaenously why there is not immediate return after settting MF_SOFT_OFFLINE? For someone like me the functions logic is tediously hard to understand tbh. BR, Jarkko