linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Nadav Amit <nadav.amit@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@suse.com>, Vlastimil Babka <vbabka@suse.cz>,
	Linux-MM <linux-mm@kvack.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: madvise: MADV_DONTNEED_LOCKED
Date: Thu, 3 Mar 2022 17:25:15 -0500	[thread overview]
Message-ID: <YiFASwUhc1Mz1Jz2@cmpxchg.org> (raw)
In-Reply-To: <A5A8E655-0CE6-4F27-85FD-E99726776EAC@gmail.com>

On Thu, Mar 03, 2022 at 01:35:56PM -0800, Nadav Amit wrote:
> 
> 
> > On Mar 3, 2022, at 1:29 PM, Johannes Weiner <hannes@cmpxchg.org> wrote:
> > 
> > MADV_DONTNEED historically rejects mlocked ranges, but with
> > MLOCK_ONFAULT and MCL_ONFAULT allowing to mlock without populating,
> > there are valid use cases for depopulating locked ranges as well.
> 
> ...
> 
> > @@ -850,7 +858,7 @@ static long madvise_dontneed_free(struct vm_area_struct *vma,
> > 		VM_WARN_ON(start >= end);
> > 	}
> > 
> > -	if (behavior == MADV_DONTNEED)
> > +	if (behavior == MADV_DONTNEED || behavior == MADV_DONTNEED_LOCKED)
> > 		return madvise_dontneed_single_vma(vma, start, end);
> > 	else if (behavior == MADV_FREE)
> > 		return madvise_free_single_vma(vma, start, end);
> > @@ -988,6 +996,7 @@ static int madvise_vma_behavior(struct vm_area_struct *vma,
> > 		return madvise_pageout(vma, prev, start, end);
> > 	case MADV_FREE:
> > 	case MADV_DONTNEED:
> > +	case MADV_DONTNEED_LOCKED:
> > 		return madvise_dontneed_free(vma, prev, start, end, behavior);
> > 	case MADV_POPULATE_READ:
> > 	case MADV_POPULATE_WRITE:
> > @@ -1113,6 +1122,7 @@ madvise_behavior_valid(int behavior)
> > 	case MADV_REMOVE:
> > 	case MADV_WILLNEED:
> > 	case MADV_DONTNEED:
> > +	case MADV_DONTNEED_LOCKED:
> > 	case MADV_FREE:
> > 	case MADV_COLD:
> > 	case MADV_PAGEOUT:
> 
> Don’t you want to change madvise_need_mmap_write() as well and add
> MADV_DONTNEED_LOCKED there too?

You're absolutely right, thanks Nadav! It'd be fine, but more
expensive than necessary. Here is the fixlet:

diff --git a/mm/madvise.c b/mm/madvise.c
index 12dfa14bc985..7dbfcd6c955a 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -52,6 +52,7 @@ static int madvise_need_mmap_write(int behavior)
 	case MADV_REMOVE:
 	case MADV_WILLNEED:
 	case MADV_DONTNEED:
+	case MADV_DONTNEED_LOCKED:
 	case MADV_COLD:
 	case MADV_PAGEOUT:
 	case MADV_FREE:


  reply	other threads:[~2022-03-03 22:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03 21:29 Johannes Weiner
2022-03-03 21:35 ` Nadav Amit
2022-03-03 22:25   ` Johannes Weiner [this message]
2022-03-03 21:47 ` Johannes Weiner
2022-03-04  9:12   ` Michal Hocko
2022-03-04 13:08   ` David Hildenbrand
2022-03-04 17:19 Johannes Weiner
2022-03-04 18:45 ` Mike Kravetz
2022-03-04 19:26 ` Shakeel Butt
2022-03-08 15:31 ` Vlastimil Babka

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=YiFASwUhc1Mz1Jz2@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=nadav.amit@gmail.com \
    --cc=vbabka@suse.cz \
    /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