From: Jiaqi Yan <jiaqiyan@google.com>
To: Andrew Morton <akpm@linux-foundation.org>, linmiaohe@huawei.com
Cc: nao.horiguchi@gmail.com, jane.chu@oracle.com,
ioworker0@gmail.com, muchun.song@linux.dev, shuah@kernel.org,
corbet@lwn.net, osalvador@suse.de, rientjes@google.com,
duenwen@google.com, fvdl@google.com, linux-mm@kvack.org,
linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH v3 1/3] mm/memory-failure: userspace controls soft-offlining pages
Date: Mon, 17 Jun 2024 16:17:01 -0700 [thread overview]
Message-ID: <CACw3F51wq4H-Hoxvm7GgCKodAR4Wy28hwBD=VngcF-fbxyRmUg@mail.gmail.com> (raw)
In-Reply-To: <20240617121348.4ee672a1d6bc9202b3ad0e08@linux-foundation.org>
On Mon, Jun 17, 2024 at 12:13 PM Andrew Morton
<akpm@linux-foundation.org> wrote:
>
> On Mon, 17 Jun 2024 17:05:43 +0000 Jiaqi Yan <jiaqiyan@google.com> wrote:
>
> > Correctable memory errors are very common on servers with large
> > amount of memory, and are corrected by ECC. Soft offline is kernel's
> > additional recovery handling for memory pages having (excessive)
> > corrected memory errors. Impacted page is migrated to a healthy page
> > if it is in-use; the original page is discarded for any future use.
> >
> > The actual policy on whether (and when) to soft offline should be
> > maintained by userspace, especially in case of an 1G HugeTLB page.
> > Soft-offline dissolves the HugeTLB page, either in-use or free, into
> > chunks of 4K pages, reducing HugeTLB pool capacity by 1 hugepage.
> > If userspace has not acknowledged such behavior, it may be surprised
> > when later failed to mmap hugepages due to lack of hugepages.
> > In case of a transparent hugepage, it will be split into 4K pages
> > as well; userspace will stop enjoying the transparent performance.
> >
> > In addition, discarding the entire 1G HugeTLB page only because of
> > corrected memory errors sounds very costly and kernel better not
> > doing under the hood. But today there are at least 2 such cases
> > doing so:
> > 1. GHES driver sees both GHES_SEV_CORRECTED and
> > CPER_SEC_ERROR_THRESHOLD_EXCEEDED after parsing CPER.
> > 2. RAS Correctable Errors Collector counts correctable errors per
> > PFN and when the counter for a PFN reaches threshold
> > In both cases, userspace has no control of the soft offline performed
> > by kernel's memory failure recovery.
> >
> > This commit gives userspace the control of softofflining any page:
> > kernel only soft offlines raw page / transparent hugepage / HugeTLB
> > hugepage if userspace has agreed to. The interface to userspace is a
> > new sysctl at /proc/sys/vm/enable_soft_offline. By default its value
> > is set to 1 to preserve existing behavior in kernel. When set to 0,
> > soft-offline (e.g. MADV_SOFT_OFFLINE) will fail with EOPNOTSUPP.
> >
>
> Seems reasonable. A very simple patch.
Thanks for taking a look, Andrew!
>
> Is there sufficient instrumentation in place for userspace to be able
> to know that these errors are occurring? To be able to generally
> monitor the machine's health?
For corrected memory errors, in general they are available in kernel
logs. On X86 Machine Check handling will log unparsed MCs (one needs
to read mci_status to know what exactly the error is). On ARM, GHES
logs parsed CPER (already containing error type and error severity).
The shortcoming is logs are rate limited. So in a burst of corrected
memory errors the user may not be able to figure out exactly how many
there were.
For uncorrectable memory errors, num_poisoned_pages is a reliable counter.
>
> > @@ -2783,6 +2795,12 @@ int soft_offline_page(unsigned long pfn, int flags)
> > return -EIO;
> > }
> >
> > + if (!sysctl_enable_soft_offline) {
> > + pr_info("%#lx: OS-wide disabled\n", pfn);
>
> This doesn't seem a very good message. There's no indication that it
> comes from the memory failure code at all. If the sysadmin sees this
> come out in the kernels logs, he/she will have to grep the kernel
> sources just to figure out where the message came from. Perhaps we can
> be more helpful here..
For sure. I took it for granted that any pr_info will have the "Memory
failure: " prefix, but now realize there is a `#undef pr_fmt` +
`#define pr_fmt(fmt) "" fmt` just above unpoison_memory.
I propose to do `#define pr_fmt(fmt) "Soft offline: " fmt` above
mf_isolate_folio, so that any soft-offline related code generates logs
with the same following format:
"Soft offline: 0x${pfn}: ${detailed_message}"
If everyone thinks this is reasonable, in v4 I can insert a new commit
to make the log formats unified.
>
> > + put_ref_page(pfn, flags);
> > + return -EOPNOTSUPP;
> > + }
> > +
> > mutex_lock(&mf_mutex);
> >
>
>
next prev parent reply other threads:[~2024-06-17 23:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 17:05 [PATCH v3 0/3] Userspace controls soft-offline pages Jiaqi Yan
2024-06-17 17:05 ` [PATCH v3 1/3] mm/memory-failure: userspace controls soft-offlining pages Jiaqi Yan
2024-06-17 19:13 ` Andrew Morton
2024-06-17 23:17 ` Jiaqi Yan [this message]
2024-06-18 3:01 ` Miaohe Lin
2024-06-19 6:35 ` Jiaqi Yan
2024-06-19 5:03 ` Oscar Salvador
2024-06-19 5:13 ` Oscar Salvador
2024-06-19 5:26 ` Jiaqi Yan
2024-06-19 5:23 ` Oscar Salvador
2024-06-19 5:25 ` Jiaqi Yan
2024-06-17 17:05 ` [PATCH v3 2/3] selftest/mm: test enable_soft_offline behaviors Jiaqi Yan
2024-06-17 17:05 ` [PATCH v3 3/3] docs: mm: add enable_soft_offline sysctl Jiaqi Yan
2024-06-19 5:19 ` Oscar Salvador
2024-06-20 17:25 ` Jiaqi Yan
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='CACw3F51wq4H-Hoxvm7GgCKodAR4Wy28hwBD=VngcF-fbxyRmUg@mail.gmail.com' \
--to=jiaqiyan@google.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=duenwen@google.com \
--cc=fvdl@google.com \
--cc=ioworker0@gmail.com \
--cc=jane.chu@oracle.com \
--cc=linmiaohe@huawei.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=nao.horiguchi@gmail.com \
--cc=osalvador@suse.de \
--cc=rientjes@google.com \
--cc=shuah@kernel.org \
/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