[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200212233946.246210-6-minchan@kernel.org>
Date: Wed, 12 Feb 2020 15:39:43 -0800
From: Minchan Kim <minchan@...nel.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: LKML <linux-kernel@...r.kernel.org>, linux-mm <linux-mm@...ck.org>,
linux-api@...r.kernel.org, oleksandr@...hat.com,
Suren Baghdasaryan <surenb@...gle.com>,
Tim Murray <timmurray@...gle.com>,
Daniel Colascione <dancol@...gle.com>,
Sandeep Patil <sspatil@...gle.com>,
Sonny Rao <sonnyrao@...gle.com>,
Brian Geffon <bgeffon@...gle.com>,
Michal Hocko <mhocko@...e.com>,
Johannes Weiner <hannes@...xchg.org>,
Shakeel Butt <shakeelb@...gle.com>,
John Dias <joaodias@...gle.com>,
Joel Fernandes <joel@...lfernandes.org>,
Alexander Duyck <alexander.h.duyck@...ux.intel.com>,
Minchan Kim <minchan@...nel.org>
Subject: [PATCH v4 5/8] mm/madvise: employ mmget_still_valid for write lock
From: Oleksandr Natalenko <oleksandr@...hat.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.
Signed-off-by: Oleksandr Natalenko <oleksandr@...hat.com>
Signed-off-by: Minchan Kim <minchan@...nel.org>
---
mm/madvise.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/madvise.c b/mm/madvise.c
index 276b9d81c1dd..71f0ba199ae8 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -1120,6 +1120,8 @@ int do_madvise(struct task_struct *task, unsigned long start,
if (write) {
if (down_write_killable(&mm->mmap_sem))
return -EINTR;
+ if (current->mm != mm && !mmget_still_valid(mm))
+ goto skip_mm;
} else {
down_read(&mm->mmap_sem);
}
@@ -1170,6 +1172,7 @@ int do_madvise(struct task_struct *task, unsigned long start,
}
out:
blk_finish_plug(&plug);
+skip_mm:
if (write)
up_write(&mm->mmap_sem);
else
--
2.25.0.225.g125e21ebc7-goog
Powered by blists - more mailing lists