[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJuCfpHS3hZi-E=JCp257u0AG+RoMAG4kLa3NQydONGfp9oXQQ@mail.gmail.com>
Date: Fri, 13 Nov 2020 17:09:37 -0800
From: Suren Baghdasaryan <surenb@...gle.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Michal Hocko <mhocko@...nel.org>,
David Rientjes <rientjes@...gle.com>,
Matthew Wilcox <willy@...radead.org>,
Johannes Weiner <hannes@...xchg.org>,
Roman Gushchin <guro@...com>, Rik van Riel <riel@...riel.com>,
Christian Brauner <christian@...uner.io>,
Oleg Nesterov <oleg@...hat.com>,
Tim Murray <timmurray@...gle.com>, linux-api@...r.kernel.org,
linux-mm <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>,
kernel-team <kernel-team@...roid.com>,
Minchan Kim <minchan@...nel.org>
Subject: Re: [PATCH 1/1] RFC: add pidfd_send_signal flag to reclaim mm while
killing a process
On Fri, Nov 13, 2020 at 5:00 PM Andrew Morton <akpm@...ux-foundation.org> wrote:
>
> On Fri, 13 Nov 2020 16:06:25 -0800 Suren Baghdasaryan <surenb@...gle.com> wrote:
>
> > On Fri, Nov 13, 2020 at 3:55 PM Andrew Morton <akpm@...ux-foundation.org> wrote:
> > >
> > > On Fri, 13 Nov 2020 09:34:48 -0800 Suren Baghdasaryan <surenb@...gle.com> wrote:
> > >
> > > > When a process is being killed it might be in an uninterruptible sleep
> > > > which leads to an unpredictable delay in its memory reclaim. In low memory
> > > > situations, when it's important to free up memory quickly, such delay is
> > > > problematic. Kernel solves this problem with oom-reaper thread which
> > > > performs memory reclaim even when the victim process is not runnable.
> > > > Userspace currently lacks such mechanisms and the need and potential
> > > > solutions were discussed before (see links below).
> > > > This patch provides a mechanism to perform memory reclaim in the context
> > > > of the process that sends SIGKILL signal. New SYNC_REAP_MM flag for
> > > > pidfd_send_signal syscall can be used only when sending SIGKILL signal
> > > > and will lead to the caller synchronously reclaiming the memory that
> > > > belongs to the victim and can be easily reclaimed.
> > >
> > > hm.
> > >
> > > Seems to me that the ability to reap another process's memory is a
> > > generally useful one, and that it should not be tied to delivering a
> > > signal in this fashion.
> > >
> > > And we do have the new process_madvise(MADV_PAGEOUT). It may need a
> > > few changes and tweaks, but can't that be used to solve this problem?
> >
> > Thank you for the feedback, Andrew. process_madvise(MADV_DONTNEED) was
> > one of the options recently discussed in
> > https://lore.kernel.org/linux-api/CAJuCfpGz1kPM3G1gZH+09Z7aoWKg05QSAMMisJ7H5MdmRrRhNQ@mail.gmail.com
> > . The thread describes some of the issues with that approach but if we
> > limit it to processes with pending SIGKILL only then I think that
> > would be doable.
>
> Why would it be necessary to read /proc/pid/maps? I'd have thought
> that a starting effort would be
>
> madvise((void *)0, (void *)-1, MADV_PAGEOUT)
>
> (after translation into process_madvise() speak). Which is equivalent
> to the proposed process_madvise(MADV_DONTNEED_MM)?
Yep, this is very similar to option #3 in
https://lore.kernel.org/linux-api/CAJuCfpGz1kPM3G1gZH+09Z7aoWKg05QSAMMisJ7H5MdmRrRhNQ@mail.gmail.com
and I actually have a tested prototype for that. If that's the
preferred method then I can post it quite quickly.
>
> There may be things which trip this up, such as mlocked regions or
> whatever, but we could add another madvise `advice' mode to handle
> this?
Powered by blists - more mailing lists