Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/mmu_notifier: convert !CONFIG_MMU_NOTIFIER range_init stubs to inline
@ 2026-12-02 12:15 A. Sverdlin
  2026-12-02 12:43 ` David Hildenbrand (Arm)
  0 siblings, 1 reply; 6+ messages in thread
From: A. Sverdlin @ 2026-12-02 12:15 UTC (permalink / raw)
  To: linux-mm
  Cc: Alexander Sverdlin, David Hildenbrand, Liam R. Howlett,
	Vlastimil Babka, Mike Rapoport, Michal Hocko, stable

From: Alexander Sverdlin <alexander.sverdlin@siemens.com>

Without CONFIG_MMU_NOTIFIER, mmu_notifier_range_init() and
mmu_notifier_range_init_owner() are macros which discard all arguments
except range, start and end. A local variable which is only passed to
them is therefore reported as unused, but only in !CONFIG_MMU_NOTIFIER
builds.

Callers must not care whether these are macros. Turn them into static
inline functions with the same prototypes as in the CONFIG_MMU_NOTIFIER=y
case, so that all arguments are consumed and type-checked. No change in
generated code.

Cc: stable@vger.kernel.org # 6.1.x
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
---

On 6.1.y, the backport of commit 92daa8652f88 ("mm/hugetlb: fix mremap
deadlock when PMD sharing is possible") left such a variable in
__unmap_hugepage_range(), breaking -Werror builds. Mainline and newer
stable trees are not affected.

Build failure on v6.1.193 with CONFIG_MMU_NOTIFIER=n:

  mm/hugetlb.c: In function '__unmap_hugepage_range':
  mm/hugetlb.c:5509:27: error: unused variable 'mm' [-Werror=unused-variable]
         struct mm_struct *mm = vma->vm_mm;
                           ^~

6.1.y still has the vma argument removed by commit 7d4a8be0c4b2
("mm/mmu_notifier: remove unused mmu_notifier_range_update_to_read_only
export"), so this will need an adapted backport.

 include/linux/mmu_notifier.h | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h
index 5db78e5761c5c..e5c57af2bc181 100644
--- a/include/linux/mmu_notifier.h
+++ b/include/linux/mmu_notifier.h
@@ -570,11 +570,24 @@ static inline void _mmu_notifier_range_init(struct mmu_notifier_range *range,
 	range->end = end;
 }
 
-#define mmu_notifier_range_init(range,event,flags,mm,start,end)  \
-	_mmu_notifier_range_init(range, start, end)
-#define mmu_notifier_range_init_owner(range, event, flags, mm, start, \
-					end, owner) \
-	_mmu_notifier_range_init(range, start, end)
+static inline void mmu_notifier_range_init(struct mmu_notifier_range *range,
+					   enum mmu_notifier_event event,
+					   unsigned int flags,
+					   struct mm_struct *mm,
+					   unsigned long start,
+					   unsigned long end)
+{
+	_mmu_notifier_range_init(range, start, end);
+}
+
+static inline void
+mmu_notifier_range_init_owner(struct mmu_notifier_range *range,
+			      enum mmu_notifier_event event, unsigned int flags,
+			      struct mm_struct *mm, unsigned long start,
+			      unsigned long end, void *owner)
+{
+	_mmu_notifier_range_init(range, start, end);
+}
 
 static inline bool
 mmu_notifier_range_blockable(const struct mmu_notifier_range *range)
-- 
2.56.1



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

* Re: [PATCH] mm/mmu_notifier: convert !CONFIG_MMU_NOTIFIER range_init stubs to inline
  2026-12-02 12:15 [PATCH] mm/mmu_notifier: convert !CONFIG_MMU_NOTIFIER range_init stubs to inline A. Sverdlin
@ 2026-12-02 12:43 ` David Hildenbrand (Arm)
  2026-12-02 13:10   ` Sverdlin, Alexander
  0 siblings, 1 reply; 6+ messages in thread
From: David Hildenbrand (Arm) @ 2026-12-02 12:43 UTC (permalink / raw)
  To: A. Sverdlin, linux-mm
  Cc: Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Michal Hocko,
	stable

On 12/2/26 13:15, A. Sverdlin wrote:
> From: Alexander Sverdlin <alexander.sverdlin@siemens.com>
> 
> Without CONFIG_MMU_NOTIFIER, mmu_notifier_range_init() and
> mmu_notifier_range_init_owner() are macros which discard all arguments
> except range, start and end. A local variable which is only passed to
> them is therefore reported as unused, but only in !CONFIG_MMU_NOTIFIER
> builds.
> 
> Callers must not care whether these are macros. Turn them into static
> inline functions with the same prototypes as in the CONFIG_MMU_NOTIFIER=y
> case, so that all arguments are consumed and type-checked. No change in
> generated code.
> 
> Cc: stable@vger.kernel.org # 6.1.x

Stable without Fixes? Is this a 6.1.x-only fix?

We usually indicate that in the [PATCH] tag and describe it properly in the
patch description.

-- 
Cheers,

David


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

* Re: [PATCH] mm/mmu_notifier: convert !CONFIG_MMU_NOTIFIER range_init stubs to inline
  2026-12-02 12:43 ` David Hildenbrand (Arm)
@ 2026-12-02 13:10   ` Sverdlin, Alexander
  2026-12-02 13:22     ` David Hildenbrand (Arm)
  0 siblings, 1 reply; 6+ messages in thread
From: Sverdlin, Alexander @ 2026-12-02 13:10 UTC (permalink / raw)
  To: linux-mm@kvack.org, david@kernel.org
  Cc: vbabka@kernel.org, liam@infradead.org, mhocko@suse.com,
	stable@vger.kernel.org, rppt@kernel.org

Hi David,

On Wed, 2026-12-02 at 13:43 +0100, David Hildenbrand (Arm) wrote:
> On 12/2/26 13:15, A. Sverdlin wrote:
> > From: Alexander Sverdlin <alexander.sverdlin@siemens.com>
> > 
> > Without CONFIG_MMU_NOTIFIER, mmu_notifier_range_init() and
> > mmu_notifier_range_init_owner() are macros which discard all arguments
> > except range, start and end. A local variable which is only passed to
> > them is therefore reported as unused, but only in !CONFIG_MMU_NOTIFIER
> > builds.
> > 
> > Callers must not care whether these are macros. Turn them into static
> > inline functions with the same prototypes as in the CONFIG_MMU_NOTIFIER=y
> > case, so that all arguments are consumed and type-checked. No change in
> > generated code.
> > 
> > Cc: stable@vger.kernel.org # 6.1.x
> 
> Stable without Fixes? Is this a 6.1.x-only fix?
> 
> We usually indicate that in the [PATCH] tag and describe it properly in the
> patch description.

yes, this is a bit tricky situation and I went a longer way to
describe it, but you've trimmed it in your reply ;-)

> On 6.1.y, the backport of commit 92daa8652f88 ("mm/hugetlb: fix mremap
> deadlock when PMD sharing is possible") left such a variable in
> __unmap_hugepage_range(), breaking -Werror builds. Mainline and newer
> stable trees are not affected.
> 
> Build failure on v6.1.193 with CONFIG_MMU_NOTIFIER=n:
> 
>   mm/hugetlb.c: In function '__unmap_hugepage_range':
>   mm/hugetlb.c:5509:27: error: unused variable 'mm' [-Werror=unused-variable]
>          struct mm_struct *mm = vma->vm_mm;
>                            ^~
> 
> 6.1.y still has the vma argument removed by commit 7d4a8be0c4b2
> ("mm/mmu_notifier: remove unused mmu_notifier_range_update_to_read_only
> export"), so this will need an adapted backport.

So with next-20261201 I cannot reproduce any build problems because
upstream 92daa8652f88 is different from v6.1.x 02e932981359.

Now it probably doesn't make sense to address this issue as -stable
patch only, because these macros would probably cause issues again
and again until converted, that's why "master" commit. And -stable
maintainers probably want it, unless they do not care about "-Werror"
regression.

But I was hesitant on adding Fixes: to "master" commit because:
- 92daa8652f88 doesn't cause any problems
- 02e932981359 is not a root cause, but only a trigger and it's not part of
  "master"

If there are still better ways to submit the patch, I've no problems
to re-spin.

-- 
Alexander Sverdlin
Siemens AG
www.siemens.com

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

* Re: [PATCH] mm/mmu_notifier: convert !CONFIG_MMU_NOTIFIER range_init stubs to inline
  2026-12-02 13:10   ` Sverdlin, Alexander
@ 2026-12-02 13:22     ` David Hildenbrand (Arm)
  2026-12-02 14:40       ` Sverdlin, Alexander
  0 siblings, 1 reply; 6+ messages in thread
From: David Hildenbrand (Arm) @ 2026-12-02 13:22 UTC (permalink / raw)
  To: Sverdlin, Alexander, linux-mm@kvack.org
  Cc: vbabka@kernel.org, liam@infradead.org, mhocko@suse.com,
	stable@vger.kernel.org, rppt@kernel.org, Greg KH

On 12/2/26 14:10, Sverdlin, Alexander wrote:
> Hi David,
> 
> On Wed, 2026-12-02 at 13:43 +0100, David Hildenbrand (Arm) wrote:
>> On 12/2/26 13:15, A. Sverdlin wrote:
>>> From: Alexander Sverdlin <alexander.sverdlin@siemens.com>
>>>
>>> Without CONFIG_MMU_NOTIFIER, mmu_notifier_range_init() and
>>> mmu_notifier_range_init_owner() are macros which discard all arguments
>>> except range, start and end. A local variable which is only passed to
>>> them is therefore reported as unused, but only in !CONFIG_MMU_NOTIFIER
>>> builds.
>>>
>>> Callers must not care whether these are macros. Turn them into static
>>> inline functions with the same prototypes as in the CONFIG_MMU_NOTIFIER=y
>>> case, so that all arguments are consumed and type-checked. No change in
>>> generated code.
>>>
>>> Cc: stable@vger.kernel.org # 6.1.x
>>
>> Stable without Fixes? Is this a 6.1.x-only fix?
>>
>> We usually indicate that in the [PATCH] tag and describe it properly in the
>> patch description.
> 
> yes, this is a bit tricky situation and I went a longer way to
> describe it, but you've trimmed it in your reply ;-)

Which is why it should properly be described above the "---" :)

Because that's what would get merged and what will have to be self-describing.

Stable without Fixes usually doesn't make sense, especially when not even
mentioning the problematic commit in the description.

> 
>> On 6.1.y, the backport of commit 92daa8652f88 ("mm/hugetlb: fix mremap
>> deadlock when PMD sharing is possible") left such a variable in
>> __unmap_hugepage_range(), breaking -Werror builds. Mainline and newer
>> stable trees are not affected.
>>
>> Build failure on v6.1.193 with CONFIG_MMU_NOTIFIER=n:
>>
>>   mm/hugetlb.c: In function '__unmap_hugepage_range':
>>   mm/hugetlb.c:5509:27: error: unused variable 'mm' [-Werror=unused-variable]
>>          struct mm_struct *mm = vma->vm_mm;
>>                            ^~
>>
>> 6.1.y still has the vma argument removed by commit 7d4a8be0c4b2
>> ("mm/mmu_notifier: remove unused mmu_notifier_range_update_to_read_only
>> export"), so this will need an adapted backport.
> 
> So with next-20261201 I cannot reproduce any build problems because
> upstream 92daa8652f88 is different from v6.1.x 02e932981359.

Okay, so stable-only problem.

> 
> Now it probably doesn't make sense to address this issue as -stable
> patch only, because these macros would probably cause issues again
> and again until converted, that's why "master" commit. 

If no build in mainline is broken, why should we care and why would it "cause
issues again"?

> And -stable
> maintainers probably want it, unless they do not care about "-Werror"
> regression.
> 
> But I was hesitant on adding Fixes: to "master" commit because:
> - 92daa8652f88 doesn't cause any problems
> - 02e932981359 is not a root cause, but only a trigger and it's not part of
>   "master"
> 
> If there are still better ways to submit the patch, I've no problems
> to re-spin.
Let's ask Greg: Greg, how to fix stable-only compile problems that appear with
"-Werror" ?

-- 
Cheers,

David


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

* Re: [PATCH] mm/mmu_notifier: convert !CONFIG_MMU_NOTIFIER range_init stubs to inline
  2026-12-02 13:22     ` David Hildenbrand (Arm)
@ 2026-12-02 14:40       ` Sverdlin, Alexander
  2026-12-02 15:15         ` David Hildenbrand (Arm)
  0 siblings, 1 reply; 6+ messages in thread
From: Sverdlin, Alexander @ 2026-12-02 14:40 UTC (permalink / raw)
  To: linux-mm@kvack.org, david@kernel.org
  Cc: gregkh@linuxfoundation.org, vbabka@kernel.org, liam@infradead.org,
	mhocko@suse.com, stable@vger.kernel.org, rppt@kernel.org

Hi David,

On Wed, 2026-12-02 at 14:22 +0100, David Hildenbrand (Arm) wrote:
> > > > Without CONFIG_MMU_NOTIFIER, mmu_notifier_range_init() and
> > > > mmu_notifier_range_init_owner() are macros which discard all arguments
> > > > except range, start and end. A local variable which is only passed to
> > > > them is therefore reported as unused, but only in !CONFIG_MMU_NOTIFIER
> > > > builds.
> > > > 
> > > > Callers must not care whether these are macros. Turn them into static
> > > > inline functions with the same prototypes as in the CONFIG_MMU_NOTIFIER=y
> > > > case, so that all arguments are consumed and type-checked. No change in
> > > > generated code.
> > > > 
> > > > Cc: stable@vger.kernel.org # 6.1.x
> > > 
> > > Stable without Fixes? Is this a 6.1.x-only fix?
> > > 
> > > We usually indicate that in the [PATCH] tag and describe it properly in the
> > > patch description.
> > 
> > yes, this is a bit tricky situation and I went a longer way to
> > describe it, but you've trimmed it in your reply ;-)
> 
> Which is why it should properly be described above the "---" :)
> 
> Because that's what would get merged and what will have to be self-describing.
> 
> Stable without Fixes usually doesn't make sense, especially when not even
> mentioning the problematic commit in the description.
> 
> > 
> > > On 6.1.y, the backport of commit 92daa8652f88 ("mm/hugetlb: fix mremap
> > > deadlock when PMD sharing is possible") left such a variable in
> > > __unmap_hugepage_range(), breaking -Werror builds. Mainline and newer
> > > stable trees are not affected.
> > > 
> > > Build failure on v6.1.193 with CONFIG_MMU_NOTIFIER=n:
> > > 
> > >   mm/hugetlb.c: In function '__unmap_hugepage_range':
> > >   mm/hugetlb.c:5509:27: error: unused variable 'mm' [-Werror=unused-variable]
> > >          struct mm_struct *mm = vma->vm_mm;
> > >                            ^~
> > > 
> > > 6.1.y still has the vma argument removed by commit 7d4a8be0c4b2
> > > ("mm/mmu_notifier: remove unused mmu_notifier_range_update_to_read_only
> > > export"), so this will need an adapted backport.
> > 
> > So with next-20261201 I cannot reproduce any build problems because
> > upstream 92daa8652f88 is different from v6.1.x 02e932981359.
> 
> Okay, so stable-only problem.

For now, accidentally...

> > Now it probably doesn't make sense to address this issue as -stable
> > patch only, because these macros would probably cause issues again
> > and again until converted, that's why "master" commit. 
> 
> If no build in mainline is broken, why should we care and why would it "cause
> issues again"?

Because a macro disguised as a function ignores most of its arguments
and causes warnings at perfectly valid call-sites and even worse, not
when original developers build with CONFIG_MMU_NOTIFIER, but after
the code has been merged and being built elsewhere without
CONFIG_MMU_NOTIFIER?

> > And -stable
> > maintainers probably want it, unless they do not care about "-Werror"
> > regression.
> > 
> > But I was hesitant on adding Fixes: to "master" commit because:
> > - 92daa8652f88 doesn't cause any problems
> > - 02e932981359 is not a root cause, but only a trigger and it's not part of
> >   "master"
> > 
> > If there are still better ways to submit the patch, I've no problems
> > to re-spin.
> Let's ask Greg: Greg, how to fix stable-only compile problems that appear with
> "-Werror" ?

-- 
Alexander Sverdlin
Siemens AG
www.siemens.com

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

* Re: [PATCH] mm/mmu_notifier: convert !CONFIG_MMU_NOTIFIER range_init stubs to inline
  2026-12-02 14:40       ` Sverdlin, Alexander
@ 2026-12-02 15:15         ` David Hildenbrand (Arm)
  0 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand (Arm) @ 2026-12-02 15:15 UTC (permalink / raw)
  To: Sverdlin, Alexander, linux-mm@kvack.org
  Cc: gregkh@linuxfoundation.org, vbabka@kernel.org, liam@infradead.org,
	mhocko@suse.com, stable@vger.kernel.org, rppt@kernel.org

>>> Now it probably doesn't make sense to address this issue as -stable
>>> patch only, because these macros would probably cause issues again
>>> and again until converted, that's why "master" commit. 
>>
>> If no build in mainline is broken, why should we care and why would it "cause
>> issues again"?
> 
> Because a macro disguised as a function ignores most of its arguments
> and causes warnings at perfectly valid call-sites and even worse, not
> when original developers build with CONFIG_MMU_NOTIFIER, but after
> the code has been merged and being built elsewhere without
> CONFIG_MMU_NOTIFIER?

We do that all of the time, and we fix it when it's a real problem upstream.

I'm happy with having this as a cleanup (if you switch to two-tab indent ons
econd parameter line etc).

But it will neither carry a Fixes: or stable.

Because that's a stable-only issue.

You can then send a backport request for that commit once it's upstream.

-- 
Cheers,

David


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

end of thread, other threads:[~2026-12-02 15:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 12:15 [PATCH] mm/mmu_notifier: convert !CONFIG_MMU_NOTIFIER range_init stubs to inline A. Sverdlin
2026-12-02 12:43 ` David Hildenbrand (Arm)
2026-12-02 13:10   ` Sverdlin, Alexander
2026-12-02 13:22     ` David Hildenbrand (Arm)
2026-12-02 14:40       ` Sverdlin, Alexander
2026-12-02 15:15         ` David Hildenbrand (Arm)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox