From: Minchan Kim <minchan@kernel.org> To: Suren Baghdasaryan <surenb@google.com> Cc: kbuild test robot <lkp@intel.com>, Andrew Morton <akpm@linux-foundation.org>, kbuild-all@lists.01.org, Linux Memory Management List <linux-mm@kvack.org> Subject: Re: [PATCH v6 2/7] mm: introduce external memory hinting API Date: Mon, 2 Mar 2020 11:18:28 -0800 [thread overview] Message-ID: <20200302191828.GA234476@google.com> (raw) In-Reply-To: <CAJuCfpEJCJR-N9bKBPMVqC3NgEXJYF3RG46cG9Y_3MEXq4F1tQ@mail.gmail.com> On Fri, Feb 28, 2020 at 02:14:56PM -0800, Suren Baghdasaryan wrote: < snip > > > > diff --git a/mm/madvise.c b/mm/madvise.c > > > index f75c86b6c463..f29155b8185d 100644 > > > --- a/mm/madvise.c > > > +++ b/mm/madvise.c > > > @@ -17,6 +17,7 @@ > > > #include <linux/falloc.h> > > > #include <linux/fadvise.h> > > > #include <linux/sched.h> > > > +#include <linux/sched/mm.h> > > > #include <linux/ksm.h> > > > #include <linux/fs.h> > > > #include <linux/file.h> > > > @@ -986,6 +987,18 @@ madvise_behavior_valid(int behavior) > > > } > > > } > > > > > > +static bool > > > +process_madvise_behavior_valid(int behavior) > > > +{ > > > + switch (behavior) { > > > + case MADV_COLD: > > > + case MADV_PAGEOUT: > > > + return true; > > > + default: > > > + return false; > > > + } > > > +} > > > + > > > /*/ > > > * The madvise(2) system call. > > > * > > > @@ -1033,6 +1046,11 @@ madvise_behavior_valid(int behavior) > > > * MADV_DONTDUMP - the application wants to prevent pages in the given range > > > * from being included in its core dump. > > > * MADV_DODUMP - cancel MADV_DONTDUMP: no longer exclude from core dump. > > > + * MADV_COLD - the application uses the memory less so the kernel can > > "kernel can" implies that kernel might not deactivate the pages, which > IIUC is not the case. Maybe rephrase as "MADV_COLD - the application > is not expected to use this memory soon, deactivate pages in this > range so that they can be reclaimed easily if memory pressure > happens."" That is much better. > > > > + * deactivate the memory to evict them quickly when the memory > > > + * pressure happen. > > > + * MADV_PAGEOUT - the application uses the memroy very rarely so kernel can > > s/memroy/memory Fixed. > > > > + * page out the memory instantly. > > same nit about the usage of "kernel can". Maybe rephrase as > "MADV_PAGEOUT - the application is not expected to use this memory > soon, page out the pages in this range immediately."" Yub. > > > > * > > > * return values: > > > * zero - success > > > @@ -1150,3 +1168,49 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior) > > > { > > > return do_madvise(current, current->mm, start, len_in, behavior); > > > } > > > + > > > +SYSCALL_DEFINE5(process_madvise, int, pidfd, unsigned long, start, > > > + size_t, len_in, int, behavior, unsigned long, flags) > > > +{ > > > + int ret; > > > + struct fd f; > > > + struct pid *pid; > > > + struct task_struct *task; > > > + struct mm_struct *mm; > > > + > > > + if (flags != 0) > > > + return -EINVAL; > > > + > > > + if (!process_madvise_behavior_valid(behavior)) > > > + return -EINVAL; > > > + > > > + f = fdget(pidfd); > > > + if (!f.file) > > > + return -EBADF; > > > + > > > + pid = pidfd_pid(f.file); > > > + if (IS_ERR(pid)) { > > > + ret = PTR_ERR(pid); > > > + goto fdput; > > > + } > > > + > > > + task = get_pid_task(pid, PIDTYPE_PID); > > > + if (!task) { > > > + ret = -ESRCH; > > > + goto fdput; > > > + } > > > + > > > + mm = mm_access(task, PTRACE_MODE_ATTACH_FSCREDS); > > > + if (IS_ERR_OR_NULL(mm)) { > > > + ret = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH; > > > + goto release_task; > > > + } > > > + > > > + ret = do_madvise(task, mm, start, len_in, behavior); > > > + mmput(mm); > > > +release_task: > > > + put_task_struct(task); > > > +fdput: > > > + fdput(f); > > > + return ret; > > > +} > > > -- > > > 2.25.0.265.gbab2e86ba0-goog > > > > > > > Reviewed-by: Suren Baghdasaryan <surenb@google.com> Thanks, Suren!
WARNING: multiple messages have this Message-ID (diff)
From: Minchan Kim <minchan@kernel.org> To: kbuild-all@lists.01.org Subject: Re: [PATCH v6 2/7] mm: introduce external memory hinting API Date: Mon, 02 Mar 2020 11:18:28 -0800 [thread overview] Message-ID: <20200302191828.GA234476@google.com> (raw) In-Reply-To: <CAJuCfpEJCJR-N9bKBPMVqC3NgEXJYF3RG46cG9Y_3MEXq4F1tQ@mail.gmail.com> [-- Attachment #1: Type: text/plain, Size: 3956 bytes --] On Fri, Feb 28, 2020 at 02:14:56PM -0800, Suren Baghdasaryan wrote: < snip > > > > diff --git a/mm/madvise.c b/mm/madvise.c > > > index f75c86b6c463..f29155b8185d 100644 > > > --- a/mm/madvise.c > > > +++ b/mm/madvise.c > > > @@ -17,6 +17,7 @@ > > > #include <linux/falloc.h> > > > #include <linux/fadvise.h> > > > #include <linux/sched.h> > > > +#include <linux/sched/mm.h> > > > #include <linux/ksm.h> > > > #include <linux/fs.h> > > > #include <linux/file.h> > > > @@ -986,6 +987,18 @@ madvise_behavior_valid(int behavior) > > > } > > > } > > > > > > +static bool > > > +process_madvise_behavior_valid(int behavior) > > > +{ > > > + switch (behavior) { > > > + case MADV_COLD: > > > + case MADV_PAGEOUT: > > > + return true; > > > + default: > > > + return false; > > > + } > > > +} > > > + > > > /*/ > > > * The madvise(2) system call. > > > * > > > @@ -1033,6 +1046,11 @@ madvise_behavior_valid(int behavior) > > > * MADV_DONTDUMP - the application wants to prevent pages in the given range > > > * from being included in its core dump. > > > * MADV_DODUMP - cancel MADV_DONTDUMP: no longer exclude from core dump. > > > + * MADV_COLD - the application uses the memory less so the kernel can > > "kernel can" implies that kernel might not deactivate the pages, which > IIUC is not the case. Maybe rephrase as "MADV_COLD - the application > is not expected to use this memory soon, deactivate pages in this > range so that they can be reclaimed easily if memory pressure > happens."" That is much better. > > > > + * deactivate the memory to evict them quickly when the memory > > > + * pressure happen. > > > + * MADV_PAGEOUT - the application uses the memroy very rarely so kernel can > > s/memroy/memory Fixed. > > > > + * page out the memory instantly. > > same nit about the usage of "kernel can". Maybe rephrase as > "MADV_PAGEOUT - the application is not expected to use this memory > soon, page out the pages in this range immediately."" Yub. > > > > * > > > * return values: > > > * zero - success > > > @@ -1150,3 +1168,49 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior) > > > { > > > return do_madvise(current, current->mm, start, len_in, behavior); > > > } > > > + > > > +SYSCALL_DEFINE5(process_madvise, int, pidfd, unsigned long, start, > > > + size_t, len_in, int, behavior, unsigned long, flags) > > > +{ > > > + int ret; > > > + struct fd f; > > > + struct pid *pid; > > > + struct task_struct *task; > > > + struct mm_struct *mm; > > > + > > > + if (flags != 0) > > > + return -EINVAL; > > > + > > > + if (!process_madvise_behavior_valid(behavior)) > > > + return -EINVAL; > > > + > > > + f = fdget(pidfd); > > > + if (!f.file) > > > + return -EBADF; > > > + > > > + pid = pidfd_pid(f.file); > > > + if (IS_ERR(pid)) { > > > + ret = PTR_ERR(pid); > > > + goto fdput; > > > + } > > > + > > > + task = get_pid_task(pid, PIDTYPE_PID); > > > + if (!task) { > > > + ret = -ESRCH; > > > + goto fdput; > > > + } > > > + > > > + mm = mm_access(task, PTRACE_MODE_ATTACH_FSCREDS); > > > + if (IS_ERR_OR_NULL(mm)) { > > > + ret = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH; > > > + goto release_task; > > > + } > > > + > > > + ret = do_madvise(task, mm, start, len_in, behavior); > > > + mmput(mm); > > > +release_task: > > > + put_task_struct(task); > > > +fdput: > > > + fdput(f); > > > + return ret; > > > +} > > > -- > > > 2.25.0.265.gbab2e86ba0-goog > > > > > > > Reviewed-by: Suren Baghdasaryan <surenb@google.com> Thanks, Suren!
next prev parent reply other threads:[~2020-03-02 19:18 UTC|newest] Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-02-19 1:44 [PATCH v6 0/7] introduce memory hinting API for external process Minchan Kim 2020-02-19 1:44 ` [PATCH v6 1/7] mm: pass task and mm to do_madvise Minchan Kim 2020-02-28 22:15 ` Suren Baghdasaryan 2020-02-28 22:15 ` Suren Baghdasaryan 2020-02-19 1:44 ` [PATCH v6 2/7] mm: introduce external memory hinting API Minchan Kim 2020-02-20 19:13 ` kbuild test robot 2020-02-20 19:13 ` kbuild test robot 2020-02-20 21:15 ` Minchan Kim 2020-02-20 21:15 ` Minchan Kim 2020-02-20 21:21 ` Minchan Kim 2020-02-20 21:21 ` Minchan Kim 2020-02-28 22:14 ` Suren Baghdasaryan 2020-02-28 22:14 ` Suren Baghdasaryan 2020-03-02 19:18 ` Minchan Kim [this message] 2020-03-02 19:18 ` Minchan Kim 2020-02-20 20:48 ` kbuild test robot 2020-02-20 20:48 ` kbuild test robot 2020-02-19 1:44 ` [PATCH v6 3/7] mm: check fatal signal pending of target process Minchan Kim 2020-02-28 22:20 ` Suren Baghdasaryan 2020-02-28 22:20 ` Suren Baghdasaryan 2020-02-19 1:44 ` [PATCH v6 4/7] pid: move pidfd_get_pid function to pid.c Minchan Kim 2020-02-28 22:22 ` Suren Baghdasaryan 2020-02-28 22:22 ` Suren Baghdasaryan 2020-02-19 1:44 ` [PATCH v6 5/7] mm: support both pid and pidfd for process_madvise Minchan Kim 2020-02-28 22:41 ` Suren Baghdasaryan 2020-02-28 22:41 ` Suren Baghdasaryan 2020-03-02 19:23 ` Minchan Kim 2020-03-02 19:38 ` Suren Baghdasaryan 2020-03-02 19:38 ` Suren Baghdasaryan 2020-02-19 1:44 ` [PATCH v6 6/7] mm/madvise: employ mmget_still_valid for write lock Minchan Kim 2020-02-28 23:19 ` Suren Baghdasaryan 2020-02-28 23:19 ` Suren Baghdasaryan 2020-03-02 7:33 ` Oleksandr Natalenko 2020-03-02 16:32 ` Suren Baghdasaryan 2020-03-02 16:32 ` Suren Baghdasaryan 2020-02-19 1:44 ` [PATCH v6 7/7] mm/madvise: allow KSM hints for remote API Minchan Kim 2020-02-19 20:01 ` [PATCH v6 0/7] introduce memory hinting API for external process Andrew Morton 2020-02-19 21:05 ` Suren Baghdasaryan 2020-02-19 21:05 ` Suren Baghdasaryan 2020-02-19 22:32 ` Minchan Kim 2020-02-19 22:51 ` Brian Geffon 2020-02-19 22:51 ` Brian Geffon 2020-02-20 9:16 ` SeongJae Park
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=20200302191828.GA234476@google.com \ --to=minchan@kernel.org \ --cc=akpm@linux-foundation.org \ --cc=kbuild-all@lists.01.org \ --cc=linux-mm@kvack.org \ --cc=lkp@intel.com \ --cc=surenb@google.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.