All of lore.kernel.org
 help / color / mirror / Atom feed
* + mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch added to mm-unstable branch
@ 2025-12-05 20:15 Andrew Morton
  2025-12-08 16:09 ` Vlastimil Babka
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2025-12-05 20:15 UTC (permalink / raw)
  To: mm-commits, vbabka, surenb, rppt, oliver.sang, mhocko,
	liam.howlett, jhubbard, david.laight.linux, lorenzo.stoakes, akpm


The patch titled
     Subject: mm: avoid use of BIT() macro for initialising VMA flags
has been added to the -mm mm-unstable branch.  Its filename is
     mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch

This patch will later appear in the mm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Subject: mm: avoid use of BIT() macro for initialising VMA flags
Date: Fri, 5 Dec 2025 17:50:37 +0000

Commit 2b6a3f061f11 ("mm: declare VMA flags by bit") significantly changed
how VMA flags are declared, utilising an enum of VMA bit values and
ifdef-fery VM_xxx flag declarations via macro.

As part of this change, it uses INIT_VM_FLAG() to define VM_xxx flags from
the newly introduced VMA bit numbers.

However, use of this macro results in apparently unfortunate macro
expansion and resulted in a performance degradation.This appears to be due
to the (__force int), which is required for the sparse typechecking to
work.

Avoid macro expansion issues by simply using 1UL << bitnum.

Link: https://lkml.kernel.org/r/20251205175037.1287366-1-lorenzo.stoakes@oracle.com
Fixes: 2b6a3f061f11 ("mm: declare VMA flags by bit")
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202512041634.150c7e4f-lkp@intel.com
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: David Laight <david.laight.linux@gmail.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 include/linux/mm.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/include/linux/mm.h~mm-avoid-use-of-bit-macro-for-initialising-vma-flags
+++ a/include/linux/mm.h
@@ -395,7 +395,8 @@ enum {
 #undef DECLARE_VMA_BIT
 #undef DECLARE_VMA_BIT_ALIAS
 
-#define INIT_VM_FLAG(name) BIT((__force int) VMA_ ## name ## _BIT)
+#define INIT_VM_FLAG(name) (1UL << (__force int)(VMA_ ## name ## _BIT))
+
 #define VM_READ		INIT_VM_FLAG(READ)
 #define VM_WRITE	INIT_VM_FLAG(WRITE)
 #define VM_EXEC		INIT_VM_FLAG(EXEC)
_

Patches currently in -mm which might be from lorenzo.stoakes@oracle.com are

mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch added to mm-unstable branch
  2025-12-05 20:15 + mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch added to mm-unstable branch Andrew Morton
@ 2025-12-08 16:09 ` Vlastimil Babka
  2025-12-09  1:40   ` Andrew Morton
  0 siblings, 1 reply; 9+ messages in thread
From: Vlastimil Babka @ 2025-12-08 16:09 UTC (permalink / raw)
  To: Andrew Morton, mm-commits, surenb, rppt, oliver.sang, mhocko,
	liam.howlett, jhubbard, david.laight.linux, lorenzo.stoakes

On 12/5/25 21:15, Andrew Morton wrote:
> The patch titled
>      Subject: mm: avoid use of BIT() macro for initialising VMA flags
> has been added to the -mm mm-unstable branch.  Its filename is

Can we move it to mm-hotfixes-unstable please, to have this resolved within
6.19 itself.

>      mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch
> 
> This patch will shortly appear at
>      https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch
> 
> This patch will later appear in the mm-unstable branch at
>     git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> 
> Before you just go and hit "reply", please:
>    a) Consider who else should be cc'ed
>    b) Prefer to cc a suitable mailing list as well
>    c) Ideally: find the original patch on the mailing list and do a
>       reply-to-all to that, adding suitable additional cc's
> 
> *** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
> 
> The -mm tree is included into linux-next via the mm-everything
> branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> and is updated there every 2-3 working days
> 
> ------------------------------------------------------
> From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Subject: mm: avoid use of BIT() macro for initialising VMA flags
> Date: Fri, 5 Dec 2025 17:50:37 +0000
> 
> Commit 2b6a3f061f11 ("mm: declare VMA flags by bit") significantly changed
> how VMA flags are declared, utilising an enum of VMA bit values and
> ifdef-fery VM_xxx flag declarations via macro.
> 
> As part of this change, it uses INIT_VM_FLAG() to define VM_xxx flags from
> the newly introduced VMA bit numbers.
> 
> However, use of this macro results in apparently unfortunate macro
> expansion and resulted in a performance degradation.This appears to be due
> to the (__force int), which is required for the sparse typechecking to
> work.
> 
> Avoid macro expansion issues by simply using 1UL << bitnum.
> 
> Link: https://lkml.kernel.org/r/20251205175037.1287366-1-lorenzo.stoakes@oracle.com
> Fixes: 2b6a3f061f11 ("mm: declare VMA flags by bit")
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202512041634.150c7e4f-lkp@intel.com
> Cc: Liam Howlett <liam.howlett@oracle.com>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Mike Rapoport <rppt@kernel.org>
> Cc: Suren Baghdasaryan <surenb@google.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: David Laight <david.laight.linux@gmail.com>
> Cc: John Hubbard <jhubbard@nvidia.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  include/linux/mm.h |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> --- a/include/linux/mm.h~mm-avoid-use-of-bit-macro-for-initialising-vma-flags
> +++ a/include/linux/mm.h
> @@ -395,7 +395,8 @@ enum {
>  #undef DECLARE_VMA_BIT
>  #undef DECLARE_VMA_BIT_ALIAS
>  
> -#define INIT_VM_FLAG(name) BIT((__force int) VMA_ ## name ## _BIT)
> +#define INIT_VM_FLAG(name) (1UL << (__force int)(VMA_ ## name ## _BIT))
> +
>  #define VM_READ		INIT_VM_FLAG(READ)
>  #define VM_WRITE	INIT_VM_FLAG(WRITE)
>  #define VM_EXEC		INIT_VM_FLAG(EXEC)
> _
> 
> Patches currently in -mm which might be from lorenzo.stoakes@oracle.com are
> 
> mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch added to mm-unstable branch
  2025-12-08 16:09 ` Vlastimil Babka
@ 2025-12-09  1:40   ` Andrew Morton
  2025-12-09  8:23     ` Vlastimil Babka
  2025-12-09 19:29     ` Andrew Morton
  0 siblings, 2 replies; 9+ messages in thread
From: Andrew Morton @ 2025-12-09  1:40 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: mm-commits, surenb, rppt, oliver.sang, mhocko, liam.howlett,
	jhubbard, david.laight.linux, lorenzo.stoakes

On Mon, 8 Dec 2025 17:09:05 +0100 Vlastimil Babka <vbabka@suse.cz> wrote:

> On 12/5/25 21:15, Andrew Morton wrote:
> > The patch titled
> >      Subject: mm: avoid use of BIT() macro for initialising VMA flags
> > has been added to the -mm mm-unstable branch.  Its filename is
> 
> Can we move it to mm-hotfixes-unstable please, to have this resolved within
> 6.19 itself.

It's in mm-unstable at present and I'll be moving it into mm-stable
soon in preparation for another merge window mm updates batch.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch added to mm-unstable branch
  2025-12-09  1:40   ` Andrew Morton
@ 2025-12-09  8:23     ` Vlastimil Babka
  2025-12-09 19:29     ` Andrew Morton
  1 sibling, 0 replies; 9+ messages in thread
From: Vlastimil Babka @ 2025-12-09  8:23 UTC (permalink / raw)
  To: Andrew Morton
  Cc: mm-commits, surenb, rppt, oliver.sang, mhocko, liam.howlett,
	jhubbard, david.laight.linux, lorenzo.stoakes

On 12/9/25 02:40, Andrew Morton wrote:
> On Mon, 8 Dec 2025 17:09:05 +0100 Vlastimil Babka <vbabka@suse.cz> wrote:
> 
>> On 12/5/25 21:15, Andrew Morton wrote:
>> > The patch titled
>> >      Subject: mm: avoid use of BIT() macro for initialising VMA flags
>> > has been added to the -mm mm-unstable branch.  Its filename is
>> 
>> Can we move it to mm-hotfixes-unstable please, to have this resolved within
>> 6.19 itself.
> 
> It's in mm-unstable at present and I'll be moving it into mm-stable
> soon in preparation for another merge window mm updates batch.

Ah I see, thanks. However, since then I've looked at the patch more closely
and we also discussed it off-list a bit, and it's not at all clear why it's
apparently helping and what the actual problem is.

I'll reply with more details on the patch thread. But I don't think it's
urgent to proceed with this fix just for a bot report of stress-ng
regression (in an msg send operation that should not be even stressing
anything with vm flag setting), and would rather find out the actual problem
first, as the fix might be accidental.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch added to mm-unstable branch
  2025-12-09  1:40   ` Andrew Morton
  2025-12-09  8:23     ` Vlastimil Babka
@ 2025-12-09 19:29     ` Andrew Morton
  2025-12-10  9:36       ` Lorenzo Stoakes
  1 sibling, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2025-12-09 19:29 UTC (permalink / raw)
  To: Vlastimil Babka, mm-commits, surenb, rppt, oliver.sang, mhocko,
	liam.howlett, jhubbard, david.laight.linux, lorenzo.stoakes

On Mon, 8 Dec 2025 17:40:09 -0800 Andrew Morton <akpm@linux-foundation.org> wrote:

> > On 12/5/25 21:15, Andrew Morton wrote:
> > > The patch titled
> > >      Subject: mm: avoid use of BIT() macro for initialising VMA flags
> > > has been added to the -mm mm-unstable branch.  Its filename is
> > 
> > Can we move it to mm-hotfixes-unstable please, to have this resolved within
> > 6.19 itself.
> 
> It's in mm-unstable at present and I'll be moving it into mm-stable
> soon in preparation for another merge window mm updates batch.

So I haven't moved it into mm-stable.  It's a bit unclear what way the
wind is blowing on this one, unclear whether the performance regression
is real and we've yet to hear back from viro.

So I'm holding it in want-and-see mode - we can add it later as a
hotfix.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch added to mm-unstable branch
  2025-12-09 19:29     ` Andrew Morton
@ 2025-12-10  9:36       ` Lorenzo Stoakes
  2025-12-10 17:46         ` Andrew Morton
  0 siblings, 1 reply; 9+ messages in thread
From: Lorenzo Stoakes @ 2025-12-10  9:36 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Vlastimil Babka, mm-commits, surenb, rppt, oliver.sang, mhocko,
	liam.howlett, jhubbard, david.laight.linux, Mateusz Guzik

+cc Mateusz.

On Tue, Dec 09, 2025 at 11:29:43AM -0800, Andrew Morton wrote:
> On Mon, 8 Dec 2025 17:40:09 -0800 Andrew Morton <akpm@linux-foundation.org> wrote:
>
> > > On 12/5/25 21:15, Andrew Morton wrote:
> > > > The patch titled
> > > >      Subject: mm: avoid use of BIT() macro for initialising VMA flags
> > > > has been added to the -mm mm-unstable branch.  Its filename is
> > >
> > > Can we move it to mm-hotfixes-unstable please, to have this resolved within
> > > 6.19 itself.
> >
> > It's in mm-unstable at present and I'll be moving it into mm-stable
> > soon in preparation for another merge window mm updates batch.
>
> So I haven't moved it into mm-stable.  It's a bit unclear what way the
> wind is blowing on this one, unclear whether the performance regression

Hmm, well it's bisected, even it's just perturbed timings don't we want to
fix it?

Figuring out that it's that doesn't mean we shouldn't make a simple change
here no?

> is real and we've yet to hear back from viro.

We're waiting to see if my use of __bitwise is 'cargo cult' as in I just
copy/pasted it as an idea from somewhere?

Even though Vlasta (thanks!) and I have clearly stated why I did this - and
proved definitively it's not 'cargo cult'?

It literally prevents very possible future bugs in the kernel. Consider:

vma_flags_set(vma, VMA_READ_BIT) vs.
vma_flags_set(vma, VM_READ) (which _looks_ correct)

So I'm not sure what exactly we're waiting for there?

>
> So I'm holding it in want-and-see mode - we can add it later as a
> hotfix.

I mean not sure it's really worth holding back given this is:

BIT(...) vs.

(1UL << ...)

Hardly something that is hugely harmful no?

Thanks, Lorenzo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch added to mm-unstable branch
  2025-12-10  9:36       ` Lorenzo Stoakes
@ 2025-12-10 17:46         ` Andrew Morton
  2025-12-12 17:46           ` Lorenzo Stoakes
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2025-12-10 17:46 UTC (permalink / raw)
  To: Lorenzo Stoakes
  Cc: Vlastimil Babka, mm-commits, surenb, rppt, oliver.sang, mhocko,
	liam.howlett, jhubbard, david.laight.linux, Mateusz Guzik

On Wed, 10 Dec 2025 09:36:19 +0000 Lorenzo Stoakes <lorenzo.stoakes@oracle.com> wrote:

> >
> > So I'm holding it in want-and-see mode - we can add it later as a
> > hotfix.
> 
> I mean not sure it's really worth holding back given this is:
> 
> BIT(...) vs.
> 
> (1UL << ...)
> 
> Hardly something that is hugely harmful no?

Nope.  I'm just giving it some settling time.  Doing it as a hotfix in
a week or so is fine.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch added to mm-unstable branch
  2025-12-10 17:46         ` Andrew Morton
@ 2025-12-12 17:46           ` Lorenzo Stoakes
  2025-12-12 17:53             ` Vlastimil Babka
  0 siblings, 1 reply; 9+ messages in thread
From: Lorenzo Stoakes @ 2025-12-12 17:46 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Vlastimil Babka, mm-commits, surenb, rppt, oliver.sang, mhocko,
	liam.howlett, jhubbard, david.laight.linux, Mateusz Guzik

On Wed, Dec 10, 2025 at 09:46:42AM -0800, Andrew Morton wrote:
> On Wed, 10 Dec 2025 09:36:19 +0000 Lorenzo Stoakes <lorenzo.stoakes@oracle.com> wrote:
>
> > >
> > > So I'm holding it in want-and-see mode - we can add it later as a
> > > hotfix.
> >
> > I mean not sure it's really worth holding back given this is:
> >
> > BIT(...) vs.
> >
> > (1UL << ...)
> >
> > Hardly something that is hugely harmful no?
>
> Nope.  I'm just giving it some settling time.  Doing it as a hotfix in
> a week or so is fine.
>

Actually, given we've prety much confirmed this is random, unrelated behaviour,
I don't think we need this patch after all.

Thanks, Lorenzo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch added to mm-unstable branch
  2025-12-12 17:46           ` Lorenzo Stoakes
@ 2025-12-12 17:53             ` Vlastimil Babka
  0 siblings, 0 replies; 9+ messages in thread
From: Vlastimil Babka @ 2025-12-12 17:53 UTC (permalink / raw)
  To: Lorenzo Stoakes, Andrew Morton
  Cc: mm-commits, surenb, rppt, oliver.sang, mhocko, liam.howlett,
	jhubbard, david.laight.linux, Mateusz Guzik

On 12/12/25 18:46, Lorenzo Stoakes wrote:
> On Wed, Dec 10, 2025 at 09:46:42AM -0800, Andrew Morton wrote:
>> On Wed, 10 Dec 2025 09:36:19 +0000 Lorenzo Stoakes <lorenzo.stoakes@oracle.com> wrote:
>>
>> > >
>> > > So I'm holding it in want-and-see mode - we can add it later as a
>> > > hotfix.
>> >
>> > I mean not sure it's really worth holding back given this is:
>> >
>> > BIT(...) vs.
>> >
>> > (1UL << ...)
>> >
>> > Hardly something that is hugely harmful no?
>>
>> Nope.  I'm just giving it some settling time.  Doing it as a hotfix in
>> a week or so is fine.
>>
> 
> Actually, given we've prety much confirmed this is random, unrelated behaviour,
> I don't think we need this patch after all.

Agreed. Let's drop it.

Thanks, Vlastimil


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-12-12 17:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-05 20:15 + mm-avoid-use-of-bit-macro-for-initialising-vma-flags.patch added to mm-unstable branch Andrew Morton
2025-12-08 16:09 ` Vlastimil Babka
2025-12-09  1:40   ` Andrew Morton
2025-12-09  8:23     ` Vlastimil Babka
2025-12-09 19:29     ` Andrew Morton
2025-12-10  9:36       ` Lorenzo Stoakes
2025-12-10 17:46         ` Andrew Morton
2025-12-12 17:46           ` Lorenzo Stoakes
2025-12-12 17:53             ` Vlastimil Babka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.