lkml.org 
[lkml]   [2020]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v7 6/7] mm/madvise: employ mmget_still_valid for write lock
From
Date
On 3/2/20 8:36 PM, Minchan Kim wrote:
> From: Oleksandr Natalenko <oleksandr@redhat.com>
>
> Do the very same trick as we already do since 04f5866e41fb. KSM hints
> will require locking mmap_sem for write since they modify vm_flags, so
> for remote KSM hinting this additional check is needed.
>
> Reviewed-by: Suren Baghdasaryan <surenb@google.com>
> Signed-off-by: Oleksandr Natalenko <oleksandr@redhat.com>
> Signed-off-by: Minchan Kim <minchan@kernel.org>
> ---
> mm/madvise.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/mm/madvise.c b/mm/madvise.c
> index e794367f681e..e77c6c1fad34 100644
> --- a/mm/madvise.c
> +++ b/mm/madvise.c
> @@ -1118,6 +1118,8 @@ int do_madvise(struct task_struct *target_task, struct mm_struct *mm,
> if (write) {
> if (down_write_killable(&mm->mmap_sem))
> return -EINTR;
> + if (current->mm != mm && !mmget_still_valid(mm))
> + goto skip_mm;

This will return 0, is that correct? Shoudln't there be a similar error e.g. as
when finding the task by pid fails (-ESRCH ?), because IIUC the task here is
going away and dumping the core?

> } else {
> down_read(&mm->mmap_sem);
> }
> @@ -1169,6 +1171,7 @@ int do_madvise(struct task_struct *target_task, struct mm_struct *mm,
> }
> out:
> blk_finish_plug(&plug);
> +skip_mm:
> if (write)
> up_write(&mm->mmap_sem);
> else
>

\
 
 \ /
  Last update: 2020-03-06 13:53    [W:2.785 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site