linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Jann Horn <jannh@google.com>,
	Thorsten Leemhuis <regressions@leemhuis.info>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Petr Tesarik <ptesarik@suse.com>, Michael Matz <matz@suse.de>,
	Gabriel Krisman Bertazi <gabriel@krisman.be>,
	Matthias Bodenbinder <matthias@bodenbinder.de>,
	stable@vger.kernel.org, Rik van Riel <riel@surriel.com>,
	Yang Shi <yang@os.amperecomputing.com>
Subject: Re: [PATCH hotfix 6.12] mm, mmap: limit THP aligment of anonymous mappings to PMD-aligned sizes
Date: Thu, 24 Oct 2024 17:00:36 +0100	[thread overview]
Message-ID: <00899fee-4bf9-46de-8a66-45088243bd2f@lucifer.local> (raw)
In-Reply-To: <2b89811b-5957-4fad-8979-86744678d296@lucifer.local>

On Thu, Oct 24, 2024 at 04:47:54PM +0100, Lorenzo Stoakes wrote:
[snip]

> > diff --git a/mm/mmap.c b/mm/mmap.c
> > index 9c0fb43064b5..a5297cfb1dfc 100644
> > --- a/mm/mmap.c
> > +++ b/mm/mmap.c
> > @@ -900,7 +900,8 @@ __get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
> >
> >  	if (get_area) {
> >  		addr = get_area(file, addr, len, pgoff, flags);
> > -	} else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
> > +	} else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)
> > +		   && IS_ALIGNED(len, PMD_SIZE)) {
>
> So doing this feels right but...
>
> Hm this seems like it belongs in __thp_get_unmapped_area() which does a bunch of
> checks up front returning 0 if they fail, which then results in it peforming the
> normal get unmapped area logic.
>
> That also has a bunch of (offset) alignment checks as well overflow checks
> so it would seem the natural place to also check length?
>

OK having said that, I see this function is referenced from a bunch of fs
stuff we probably don't want to potentially break by enforcing this
requirement there (at least in this fix).

So disregard that and since this looks otherwise good to me, feel free to add:

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>


> >  		/* Ensures that larger anonymous mappings are THP aligned. */
> >  		addr = thp_get_unmapped_area_vmflags(file, addr, len,
> >  						     pgoff, flags, vm_flags);
> > --
> > 2.47.0
> >

Thanks!


  reply	other threads:[~2024-10-24 16:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-24  7:45 darktable performance regression on AMD systems caused by "mm: align larger anonymous mappings on THP boundaries" Thorsten Leemhuis
2024-10-24  9:58 ` Vlastimil Babka
2024-10-24 10:23   ` Vlastimil Babka
2024-10-24 10:49     ` Petr Tesarik
2024-10-24 10:56       ` Vlastimil Babka
2024-10-24 11:13         ` Petr Tesarik
2024-10-24 13:29           ` Vlastimil Babka
2024-10-24 14:14             ` Petr Tesarik
2024-10-24 11:20     ` Matthias Bodenbinder
2024-10-24 15:12 ` [PATCH hotfix 6.12] mm, mmap: limit THP aligment of anonymous mappings to PMD-aligned sizes Vlastimil Babka
2024-10-24 15:47   ` Lorenzo Stoakes
2024-10-24 16:00     ` Lorenzo Stoakes [this message]
2024-10-24 16:04     ` Vlastimil Babka
2024-10-24 16:17       ` Lorenzo Stoakes
2024-10-28 13:45     ` Michael Matz
2024-10-24 18:32   ` Yang Shi

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=00899fee-4bf9-46de-8a66-45088243bd2f@lucifer.local \
    --to=lorenzo.stoakes@oracle.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=gabriel@krisman.be \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matthias@bodenbinder.de \
    --cc=matz@suse.de \
    --cc=ptesarik@suse.com \
    --cc=regressions@leemhuis.info \
    --cc=riel@surriel.com \
    --cc=stable@vger.kernel.org \
    --cc=vbabka@suse.cz \
    --cc=yang@os.amperecomputing.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