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 22D82C10F1A for ; Thu, 9 May 2024 23:03:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 688596B0088; Thu, 9 May 2024 19:03:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6116E6B0089; Thu, 9 May 2024 19:03:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48AD96B0092; Thu, 9 May 2024 19:03:16 -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 28C226B0088 for ; Thu, 9 May 2024 19:03:16 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D4EA61C0AD2 for ; Thu, 9 May 2024 23:03:15 +0000 (UTC) X-FDA: 82100385150.20.0CDE119 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by imf13.hostedemail.com (Postfix) with ESMTP id 0660320013 for ; Thu, 9 May 2024 23:03:13 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=DxAJ4O6s; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf13.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.221.50 as permitted sender) smtp.mailfrom=axelrasmussen@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715295794; 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=cPbSvLzfel2aidHv4944fpA4agv4jm4lmrU+rS2yRC4=; b=OMnfeBykG0tbjLu2ArPxP1CUWrlqzz2Po5mTBGFAhC49T15lBnBYpmUplUTNyRH1XqT+6F pzftctm6iJyhgbf0j7KFT3/VYjQgjQc5nyoxyLpKHL8Smfa7Ty+CJO5d5OeezkqWHHbKPp FTls8BcwJXgBWFsT2ZKphidl3xHVCMQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715295794; a=rsa-sha256; cv=none; b=HpPNy7gZsjh3IpEyAbSSTo/CWykMp5CxdHxrO4FBfGT0N1o0kJOa3ieAnlUdN0/W9ojn0/ H8nvQE5lQjB9JFm32RnaX4ymJZlfesrpQIMsfm0/g/64J9+XZINCRpXzAgIlNO2uBkwmT6 0Alcr6gs3T7olPpsiDZ7vmdqso0F/S4= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=DxAJ4O6s; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf13.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.221.50 as permitted sender) smtp.mailfrom=axelrasmussen@google.com Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-34e28e32ea4so896652f8f.2 for ; Thu, 09 May 2024 16:03:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715295792; x=1715900592; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cPbSvLzfel2aidHv4944fpA4agv4jm4lmrU+rS2yRC4=; b=DxAJ4O6sWwH7aO1FR/hVh25+f9qkwQcKQoEIvO9Y6Ml4lfPgmTF2B49ES4y3kVt2+t U7ZmN+E33y87leVJs2c3r/hZH9utiMdi43EblmX6jlMFryZ/FN0QomxTtvxML2/yMbnp wKyMzTiNEz+JyDa0yfTV335fesccB5cy4WUkBXg2UnB5S2J5BdZAPLvfruwtUabCs9lJ FQFjl+1XA3DHgUA0orpXAuaR+nuujcJqsINsWshACTL6Nr1DX1x1cJOem8UsBUyq0cYZ Vj+YR1EgP4ZB3aCpghs1+xWHndsBP4m8KevWB1i2NjBFi1TG0p87c5RvR6m7qObsqU2W XEhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715295792; x=1715900592; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cPbSvLzfel2aidHv4944fpA4agv4jm4lmrU+rS2yRC4=; b=sK2mS5YPCGLJMcAUVRJtOApVaufbKe8RJ3aKF6vakWfNGVV7plSUy08n79s4TJy9Ye jhKCY5GHzMAnWeIt4PjhlWsagSSU4r6s1o56P8qlkrHo5cKQtHG8qXdQ1qllvjfBiic5 oK86E1+hq+okU2wb+SltoDEtA57Ptwpdlu1/JSadyMN4CQ1B4WqL8N6rL4ZgSVrt6BQv HyDlCeY39SvWtSMVHOotoodOw9Hc4Un2Qwrxs7H8YJY5PDBvVM0DRQpit8c9ZfBE7Bvg 70zlNZzjvpdnn2WJiCY2l8rXsXs6kWrtvQpOsStBdlNUdFqBFArfP4Xowr/TA7Y6ZabI sBtw== X-Forwarded-Encrypted: i=1; AJvYcCUstAiIBPWMWwNsgYlPsP40pqeSY3xsLvuP4z0LF7N2mehf4QuGhyLTYYcOvp5EMccHlfJwFHmATyGPVOYkFxczUGI= X-Gm-Message-State: AOJu0Yyv6EeFeBr/iFQmpsSTE0s9PT52/zax511ZlQ3xDxoqiLzJLqeb j1yyGpdb9xRCrRyGwoZfrqaviAihQ3IKwH1A1JYeyvXUnS3h3aGcuqBPz02NPWDDlfBv0taDO66 dZD3a3CTvgirvtRo6+brODx8b/QLwA7hL5sxT X-Google-Smtp-Source: AGHT+IFhmWSmgHAekjGKzRtk8e+YHHuEDjTnB0xuUIijeYWCpcIdqwfIqifcfRX9laqU/XyPu9INnEX+SjRuGN5KTmg= X-Received: by 2002:a05:6000:e43:b0:34e:21cd:dbf3 with SMTP id ffacd0b85a97d-3504a73ec96mr677219f8f.36.1715295792241; Thu, 09 May 2024 16:03:12 -0700 (PDT) MIME-Version: 1.0 References: <20240509203907.504891-1-axelrasmussen@google.com> <20240509203907.504891-2-axelrasmussen@google.com> In-Reply-To: From: Axel Rasmussen Date: Thu, 9 May 2024 16:02:33 -0700 Message-ID: Subject: Re: [PATCH 1/1] arch/fault: don't print logs for simulated poison errors To: Peter Xu Cc: Andrew Morton , Andy Lutomirski , "Aneesh Kumar K.V" , Borislav Petkov , Christophe Leroy , Dave Hansen , David Hildenbrand , "H. Peter Anvin" , Helge Deller , Ingo Molnar , "James E.J. Bottomley" , John Hubbard , Liu Shixin , "Matthew Wilcox (Oracle)" , Michael Ellerman , Muchun Song , "Naveen N. Rao" , Nicholas Piggin , Oscar Salvador , Peter Zijlstra , Suren Baghdasaryan , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 0660320013 X-Stat-Signature: 8kykjjdhjbfckyf3g38ursfi367ppgic X-Rspam-User: X-HE-Tag: 1715295793-211494 X-HE-Meta: U2FsdGVkX19pFkXlvgkTQbo9JBYTMIboYsm+dHfBGmDg+dDQzc3iK22icbIjaqR97S8utI9w/C88OPiRQXIhjCqKTcF0VTpBN6Ni4KH5Ix8WfFJ6MJEGyWSIg5h1Y3WoYF4lo3LtX2SnQ59v8d7rRSldco9vAAbqP1vZjAspfZIUIZqqLcgg6A29W2lhuDSQGc2kVi+YOEOpjqy22S8GOTlgPagS6orH/Y52hCrnKEaAUMEaua8Fq6s/pFMe2vzsvA+SbPZnY8k/5Zw2k8HxKune8fe8uIVXWh41K4pUiesLdJrFDJB7/l2YJLmfcdohWODbr5GlTbc1H9P75aiWQhPmjqmHIy2MYhRaFhsnhrnZy/bakvkXQT3UGD5e9JnJBd9CxuRTR1rNeQJEN16iruQfh9vcV1kIVCascxIfL0p2fXKig1nshx6gko5/1DxMh8tYwJyOqgF4yq5T/QcCIwEvz8cdwzPMfgkb31nNzIbkcNH466Ukz7Pv4FQW9O6g4micJiwpH2vRF415ymERVPX96UKmD+JGwgdVtJStHznN9/5kYaXIkxiGzFx8qWrRjW/oNJNsXG3vaGSZh0etR2Cb8JQ1/ywx/Fj+vEmB5I4F1TeqWUEiAFlXmIUq7IaCVmjeQKAo6GmZ3+baA4HPNcLafTIpH8+o+jNTqhJc4sBoU7h/C77rObzo8fxXeXH1ICenARAzZNnbSCIJVS71WXYSadqd0FDVNDb5WSYpceITI11qvlGdhK92JaGooOo1aRqkZ7I6dow31vl3wrzO1O+1W7w5nhaR9r8Giy/gBJP26qJl9jLHARbFDnTXgNgZIZdIfagLQR3IrHqEoRAI/p3x/f4Pj7FjyFxcdYAiY47RpDr0QxpmK5ftwT3MNq5NnXKY3BT9TS0+bOO/wCz2moQaGq6ocXTOAK1laiwHjhLpvkng3dkrE2pxe61MD7uGhQV4HGI92mSDvZT+5YS DDQqb6xV isGftTMGcLi+kNPpGvl86vcdCZMuRMyWTEhPH2P+YH6YpZs+WI0oT05XvdpiZ3OBI9lALfd2WHexhz3STsji172vfIAWuyTqTU2WzQpd8eTMYZLdoXucxOZn7gO7UZt55+f5LoSNBT1b4HLLLgCx72aqwgGJOtYW8R/VwgFUzTotKMHZ1ND8Hf2oONDS7wy4TlDkvbz0U1LdJPkq50GlZNP1IE8MJPhAkqbAdeQFM+UV2S7cdHEKEAkRDfS+FKiPx5ovbM8VyF62f816/J45A9UYBkw== 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 Thu, May 9, 2024 at 2:05=E2=80=AFPM Peter Xu wrote: > > On Thu, May 09, 2024 at 01:39:07PM -0700, Axel Rasmussen wrote: > > For real MCEs, various architectures print log messages when poisoned > > memory is accessed (which results in a SIGBUS). These messages can be > > important for users to understand the issue. > > > > On the other hand, we have the userfaultfd UFFDIO_POISON operation, > > which can "simulate" memory poisoning. That particular process will get > > It also coveres swapin errors as we talked before, so not always SIM. > > I was thinking we should also do that report for swapin errors, however > then I noticed it wasn't reported before the replacement of pte markers, > in commit 15520a3f04, since 2022: > > @@ -3727,8 +3731,6 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) > put_page(vmf->page); > } else if (is_hwpoison_entry(entry)) { > ret =3D VM_FAULT_HWPOISON; > - } else if (is_swapin_error_entry(entry)) { > - ret =3D VM_FAULT_SIGBUS; > } else if (is_pte_marker_entry(entry)) { > ret =3D handle_pte_marker(vmf); > } else { > > So I am guessing it could be fine to just turn this report off to syslog. > There will be a back-and-forth on this behavior, but hopefully this is ev= en > rarer than hwpoison so nobody will notice. > > With that, the idea looks valid to me, but perhaps a rename is needed. > Maybe _QUIESCE or _SILENT? Ah, I had forgotten about the swapin error case. I think it still makes sense to silence the log in that case; if we consider a scenario like disk error, it could seem weird to get an MCE message for that, since the physical memory is fine and it wouldn't show up in mcelog or similar. I like _SILENT, I'll do the rename and update my comments to better explain in v2. > > > SIGBUS on access to the memory, but this effect is tied to an MM, rathe= r > > than being global like a real poison event. So, we don't want to log > > about this case to the global kernel log; instead, let the process > > itself log or whatever else it wants to do. This avoids spamming the > > kernel log, and avoids e.g. drowning out real events with simulated > > ones. > > > > To identify this situation, add a new VM_FAULT_HWPOISON_SIM flag. This > > is expected to be set *in addition to* one of the existing > > VM_FAULT_HWPOISON or VM_FAULT_HWPOISON_LARGE flags (which are mutually > > exclusive). > > > > Signed-off-by: Axel Rasmussen > > --- > > arch/parisc/mm/fault.c | 7 +++++-- > > arch/powerpc/mm/fault.c | 6 ++++-- > > arch/x86/mm/fault.c | 6 ++++-- > > include/linux/mm_types.h | 5 +++++ > > mm/hugetlb.c | 3 ++- > > mm/memory.c | 2 +- > > 6 files changed, 21 insertions(+), 8 deletions(-) > > > > diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c > > index c39de84e98b0..e5370bcadf27 100644 > > --- a/arch/parisc/mm/fault.c > > +++ b/arch/parisc/mm/fault.c > > @@ -400,9 +400,12 @@ void do_page_fault(struct pt_regs *regs, unsigned = long code, > > #ifdef CONFIG_MEMORY_FAILURE > > if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) = { > > unsigned int lsb =3D 0; > > - printk(KERN_ERR > > + > > + if (!(fault & VM_FAULT_HWPOISON_SIM)) { > > + pr_err( > > "MCE: Killing %s:%d due to hardware memory corruption fault at %0= 8lx\n", > > - tsk->comm, tsk->pid, address); > > + tsk->comm, tsk->pid, address); > > + } > > /* > > * Either small page or large page may be poisone= d. > > * In other words, VM_FAULT_HWPOISON_LARGE and > > diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c > > index 53335ae21a40..ac5e8a3c7fba 100644 > > --- a/arch/powerpc/mm/fault.c > > +++ b/arch/powerpc/mm/fault.c > > @@ -140,8 +140,10 @@ static int do_sigbus(struct pt_regs *regs, unsigne= d long address, > > if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) { > > unsigned int lsb =3D 0; /* shutup gcc */ > > > > - pr_err("MCE: Killing %s:%d due to hardware memory corrupt= ion fault at %lx\n", > > - current->comm, current->pid, address); > > + if (!(fault & VM_FAULT_HWPOISON_SIM)) { > > + pr_err("MCE: Killing %s:%d due to hardware memory= corruption fault at %lx\n", > > + current->comm, current->pid, address); > > + } > > > > if (fault & VM_FAULT_HWPOISON_LARGE) > > lsb =3D hstate_index_to_shift(VM_FAULT_GET_HINDEX= (fault)); > > diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c > > index e4f3c7721f45..16d077a3ad14 100644 > > --- a/arch/x86/mm/fault.c > > +++ b/arch/x86/mm/fault.c > > @@ -928,9 +928,11 @@ do_sigbus(struct pt_regs *regs, unsigned long erro= r_code, unsigned long address, > > struct task_struct *tsk =3D current; > > unsigned lsb =3D 0; > > > > - pr_err_ratelimited( > > + if (!(fault & VM_FAULT_HWPOISON_SIM)) { > > + pr_err_ratelimited( > > "MCE: Killing %s:%d due to hardware memory corruption fault at %l= x\n", > > - tsk->comm, tsk->pid, address); > > + tsk->comm, tsk->pid, address); > > + } > > if (fault & VM_FAULT_HWPOISON_LARGE) > > lsb =3D hstate_index_to_shift(VM_FAULT_GET_HINDEX= (fault)); > > if (fault & VM_FAULT_HWPOISON) > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > > index 5240bd7bca33..7f8fc3efc5b2 100644 > > --- a/include/linux/mm_types.h > > +++ b/include/linux/mm_types.h > > @@ -1226,6 +1226,9 @@ typedef __bitwise unsigned int vm_fault_t; > > * @VM_FAULT_HWPOISON_LARGE: Hit poisoned large page. Index encoded > > * in upper bits > > * @VM_FAULT_SIGSEGV: segmentation fault > > + * @VM_FAULT_HWPOISON_SIM Hit poisoned, PTE marker; this indicates = a > > + * simulated poison (e.g. via usefaultfd's > > + * UFFDIO_POISON), not a "real" hwerror. > > * @VM_FAULT_NOPAGE: ->fault installed the pte, not return pag= e > > * @VM_FAULT_LOCKED: ->fault locked the returned page > > * @VM_FAULT_RETRY: ->fault blocked, must retry > > @@ -1245,6 +1248,7 @@ enum vm_fault_reason { > > VM_FAULT_HWPOISON =3D (__force vm_fault_t)0x000010, > > VM_FAULT_HWPOISON_LARGE =3D (__force vm_fault_t)0x000020, > > VM_FAULT_SIGSEGV =3D (__force vm_fault_t)0x000040, > > + VM_FAULT_HWPOISON_SIM =3D (__force vm_fault_t)0x000080, > > VM_FAULT_NOPAGE =3D (__force vm_fault_t)0x000100, > > VM_FAULT_LOCKED =3D (__force vm_fault_t)0x000200, > > VM_FAULT_RETRY =3D (__force vm_fault_t)0x000400, > > @@ -1270,6 +1274,7 @@ enum vm_fault_reason { > > { VM_FAULT_HWPOISON, "HWPOISON" }, \ > > { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ > > { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ > > + { VM_FAULT_HWPOISON_SIM, "HWPOISON_SIM" }, \ > > { VM_FAULT_NOPAGE, "NOPAGE" }, \ > > { VM_FAULT_LOCKED, "LOCKED" }, \ > > { VM_FAULT_RETRY, "RETRY" }, \ > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > > index 65456230cc71..2b4e0173e806 100644 > > --- a/mm/hugetlb.c > > +++ b/mm/hugetlb.c > > @@ -6485,7 +6485,8 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, st= ruct vm_area_struct *vma, > > pte_marker_get(pte_to_swp_entry(entry)); > > > > if (marker & PTE_MARKER_POISONED) { > > - ret =3D VM_FAULT_HWPOISON_LARGE | > > + ret =3D VM_FAULT_HWPOISON_SIM | > > + VM_FAULT_HWPOISON_LARGE | > > VM_FAULT_SET_HINDEX(hstate_index(h)= ); > > goto out_mutex; > > } > > diff --git a/mm/memory.c b/mm/memory.c > > index d2155ced45f8..29a833b996ae 100644 > > --- a/mm/memory.c > > +++ b/mm/memory.c > > @@ -3910,7 +3910,7 @@ static vm_fault_t handle_pte_marker(struct vm_fau= lt *vmf) > > > > /* Higher priority than uffd-wp when data corrupted */ > > if (marker & PTE_MARKER_POISONED) > > - return VM_FAULT_HWPOISON; > > + return VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_SIM; > > > > if (pte_marker_entry_uffd_wp(entry)) > > return pte_marker_handle_uffd_wp(vmf); > > -- > > 2.45.0.118.g7fe29c98d7-goog > > > > -- > Peter Xu >