From: Liam Howlett <liam.howlett@oracle.com>
To: Hugh Dickins <hughd@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Oleg Nesterov <oleg@redhat.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH mmotm] mempolicy: mbind_range() set_policy() after vma_merge()
Date: Fri, 4 Mar 2022 19:05:38 +0000 [thread overview]
Message-ID: <20220304190531.6giqbnnaka4xhovx@revolver> (raw)
In-Reply-To: <20220304184927.vkq6ewn6uqtcesma@revolver>
* Liam R. Howlett <Liam.Howlett@Oracle.com> [220304 13:49]:
> * Hugh Dickins <hughd@google.com> [220303 23:36]:
> > v2.6.34 commit 9d8cebd4bcd7 ("mm: fix mbind vma merge problem")
> > introduced vma_merge() to mbind_range(); but unlike madvise, mlock and
> > mprotect, it put a "continue" to next vma where its precedents go to
> > update flags on current vma before advancing: that left vma with the
> > wrong setting in the infamous vma_merge() case 8.
> >
> > v3.10 commit 1444f92c8498 ("mm: merging memory blocks resets mempolicy")
> > tried to fix that in vma_adjust(), without fully understanding the issue.
> >
> > v3.11 commit 3964acd0dbec ("mm: mempolicy: fix mbind_range() &&
> > vma_adjust() interaction") reverted that, and went about the fix in the
> > right way, but chose to optimize out an unnecessary mpol_dup() with a
> > prior mpol_equal() test. But on tmpfs, that also pessimized out the
> > vital call to its ->set_policy(), leaving the new mbind unenforced.
> >
I just thought of something after my initial email
How does the ->set_policy() requirement on tmpfs play out for the
mpol_equal() check earlier in that for loop?
> > Just delete that optimization now (though it could be made conditional
> > on vma not having a set_policy). Also remove the "next" variable:
> > it turned out to be blameless, but also pointless.
> >
> > Fixes: 3964acd0dbec ("mm: mempolicy: fix mbind_range() && vma_adjust() interaction")
> > Signed-off-by: Hugh Dickins <hughd@google.com>
> > ---
> >
> > mm/mempolicy.c | 8 +-------
> > 1 file changed, 1 insertion(+), 7 deletions(-)
> >
> > --- a/mm/mempolicy.c
> > +++ b/mm/mempolicy.c
> > @@ -786,7 +786,6 @@ static int vma_replace_policy(struct vm_area_struct *vma,
> > static int mbind_range(struct mm_struct *mm, unsigned long start,
> > unsigned long end, struct mempolicy *new_pol)
> > {
> > - struct vm_area_struct *next;
> > struct vm_area_struct *prev;
> > struct vm_area_struct *vma;
> > int err = 0;
> > @@ -801,8 +800,7 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
> > if (start > vma->vm_start)
> > prev = vma;
> >
> > - for (; vma && vma->vm_start < end; prev = vma, vma = next) {
> > - next = vma->vm_next;
> > + for (; vma && vma->vm_start < end; prev = vma, vma = vma->vm_next) {
> > vmstart = max(start, vma->vm_start);
> > vmend = min(end, vma->vm_end);
> >
> > @@ -817,10 +815,6 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
> > anon_vma_name(vma));
> > if (prev) {
> > vma = prev;
> > - next = vma->vm_next;
> > - if (mpol_equal(vma_policy(vma), new_pol))
> > - continue;
> > - /* vma_merge() joined vma && vma->next, case 8 */
> > goto replace;
> > }
> > if (vma->vm_start != vmstart) {
>
> Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
next prev parent reply other threads:[~2022-03-04 19:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-04 4:36 Hugh Dickins
2022-03-04 18:06 ` Oleg Nesterov
2022-03-04 22:33 ` Hugh Dickins
2022-03-04 18:49 ` Liam Howlett
2022-03-04 19:05 ` Liam Howlett [this message]
2022-03-04 22:48 ` Hugh Dickins
2022-03-05 2:00 ` Liam Howlett
2022-03-05 2:28 ` Hugh Dickins
2022-03-08 16:05 ` Liam Howlett
2022-03-08 21:32 ` Hugh Dickins
2022-03-09 12:41 ` Vlastimil Babka
2022-03-09 19:10 ` Liam Howlett
2022-03-11 9:33 ` Hugh Dickins
2022-03-11 8:54 ` Hugh Dickins
2022-03-11 12:47 ` 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=20220304190531.6giqbnnaka4xhovx@revolver \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=oleg@redhat.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: 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