linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jiaqi Yan <jiaqiyan@google.com>
To: Lance Yang <ioworker0@gmail.com>, linmiaohe@huawei.com
Cc: nao.horiguchi@gmail.com, jane.chu@oracle.com,
	muchun.song@linux.dev,  akpm@linux-foundation.org,
	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 v2 1/3] mm/memory-failure: userspace controls soft-offlining pages
Date: Fri, 14 Jun 2024 09:30:59 -0700	[thread overview]
Message-ID: <CACw3F5134NmmLNr4zXHV1h0sLMTGcAJLpApQ7Fv_-DtUieD7zw@mail.gmail.com> (raw)
In-Reply-To: <CABzRoyYGY2EgT5wC9o98Vn_auh59poQ-OOnKceCiWQAJrbZoBw@mail.gmail.com>

On Fri, Jun 14, 2024 at 1:35 AM Lance Yang <ioworker0@gmail.com> wrote:
>
> Hi Jiaqi,
>
> On Wed, Jun 12, 2024 at 5:56 AM 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 inuse; 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 mmap hugepages MAP_FAILED 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:
> > 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 called enable_soft_offline under /proc/sys/vm. By default
> > enable_soft_line is 1 to preserve existing behavior in kernel.
>
> s/enable_soft_line/enable_soft_offline

Will fix this typo in v3.

>
> >
> > Signed-off-by: Jiaqi Yan <jiaqiyan@google.com>
> > ---
> >  mm/memory-failure.c | 16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> >
> > diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> > index d3c830e817e3..23415fe03318 100644
> > --- a/mm/memory-failure.c
> > +++ b/mm/memory-failure.c
> > @@ -68,6 +68,8 @@ static int sysctl_memory_failure_early_kill __read_mostly;
> >
> >  static int sysctl_memory_failure_recovery __read_mostly = 1;
> >
> > +static int sysctl_enable_soft_offline __read_mostly = 1;
> > +
> >  atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
> >
> >  static bool hw_memory_failure __read_mostly = false;
> > @@ -141,6 +143,15 @@ static struct ctl_table memory_failure_table[] = {
> >                 .extra1         = SYSCTL_ZERO,
> >                 .extra2         = SYSCTL_ONE,
> >         },
> > +       {
> > +               .procname       = "enable_soft_offline",
> > +               .data           = &sysctl_enable_soft_offline,
> > +               .maxlen         = sizeof(sysctl_enable_soft_offline),
> > +               .mode           = 0644,
> > +               .proc_handler   = proc_dointvec_minmax,
> > +               .extra1         = SYSCTL_ZERO,
> > +               .extra2         = SYSCTL_ONE,
> > +       }
> >  };
> >
> >  /*
> > @@ -2771,6 +2782,11 @@ int soft_offline_page(unsigned long pfn, int flags)
> >         bool try_again = true;
> >         struct page *page;
> >
> > +       if (!sysctl_enable_soft_offline) {
> > +               pr_info("soft offline: %#lx: OS-wide disabled\n", pfn);
> > +               return -EINVAL;
>
> IMO, "-EPERM" might sound better ;)
>
> Using "-EPERM" indicates that the operation is not permitted due to
> the OS-wide configuration.

Miaohe suggested -EOPNOTSUPP. I agree both EOPNOTSUPP and EPERM may be
better than EINVAL. But I wonder how about EAGAIN? With EAGAIN plus
showing "disabled by /proc/sys/vm/enable_soft_offline" in dmesg, users
now should be clear that they can try again with
/proc/sys/vm/enable_soft_offline=1.

>
> Thanks,
> Lance
>
> > +       }
> > +
> >         if (!pfn_valid(pfn)) {
> >                 WARN_ON_ONCE(flags & MF_COUNT_INCREASED);
> >                 return -ENXIO;
> > --
> > 2.45.2.505.gda0bf45e8d-goog
> >
> >


  reply	other threads:[~2024-06-14 16:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-11 21:55 [PATCH v2 0/3] Userspace controls soft-offline pages Jiaqi Yan
2024-06-11 21:55 ` [PATCH v2 1/3] mm/memory-failure: userspace controls soft-offlining pages Jiaqi Yan
2024-06-14  3:28   ` Miaohe Lin
2024-06-14 16:40     ` Jiaqi Yan
2024-06-14  8:35   ` Lance Yang
2024-06-14 16:30     ` Jiaqi Yan [this message]
2024-06-17  7:31       ` Miaohe Lin
2024-06-17  7:51         ` Oscar Salvador
2024-06-17  8:16           ` Miaohe Lin
2024-06-17 10:34             ` Lance Yang
2024-06-17 15:42               ` Jiaqi Yan
2024-06-11 21:55 ` [PATCH v2 2/3] selftest/mm: test enable_soft_offline behaviors Jiaqi Yan
2024-06-14  3:50   ` Miaohe Lin
2024-06-14 19:36     ` Jiaqi Yan
2024-06-11 21:55 ` [PATCH v2 3/3] docs: mm: add enable_soft_offline sysctl Jiaqi Yan
2024-06-12  0:25   ` David Rientjes
2024-06-14 23:15     ` 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=CACw3F5134NmmLNr4zXHV1h0sLMTGcAJLpApQ7Fv_-DtUieD7zw@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