Skip to contentSkip to conversation

mm: shmem: avoid build warning for CONFIG_SHMEM=n

PATCH Applied Arnd Bergmann 7 participants 10 messages Dec 4, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mm: shmem: avoid build warning for CONFIG_SHMEM=n

From: Arnd Bergmann <[email protected]>

The newly added 'flags' variable is unused and causes a warning if CONFIG_SHMEM is disabled, since the shmem_acct_size() macro it is passed into does nothing:

mm/shmem.c: In function '__shmem_file_setup':
mm/shmem.c:5816:23: error: unused variable 'flags' [-Werror=unused-variable]
5816 | unsigned long flags = (vm_flags & VM_NORESERVE) ? SHMEM_F_NORESERVE : 0;
| ^~~~~

Replace the two macros with equivalent inline functions tto get the argument checking.

Fixes 6ff1610ced56 ("mm: shmem: use SHMEM_F_* flags instead of VM_* flags")

---
v2: make shmem_unacct_size() inline as well.

---
 mm/shmem.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
mm/shmem.c +9 -2
index 3f194c9842a8..b329b5302c48 100644
@@ -5794,8 +5794,15 @@ EXPORT_SYMBOL_GPL(shmem_truncate_range);
 #define shmem_vm_ops				generic_file_vm_ops
 #define shmem_anon_vm_ops			generic_file_vm_ops
 #define shmem_file_operations			ramfs_file_operations
-#define shmem_acct_size(flags, size)		0
-#define shmem_unacct_size(flags, size)		do {} while (0)
+
+static inline int shmem_acct_size(unsigned long flags, loff_t size)
+{
+	return 0;
+}
+
+static inline void shmem_unacct_size(unsigned long flags, loff_t size)
+{
+}
 
 static inline struct inode *shmem_get_inode(struct mnt_idmap *idmap,
 				struct super_block *sb, struct inode *dir,
Signature · 1 line
2.39.5
#1 lore raw
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly added 'flags' variable is unused and causes a warning if CONFIG_SHMEM is disabled, since the shmem_acct_size() macro it is passed into does nothing:

mm/shmem.c: In function '__shmem_file_setup':
mm/shmem.c:5816:23: error: unused variable 'flags' [-Werror=unused-variable]
5816 | unsigned long flags = (vm_flags & VM_NORESERVE) ? SHMEM_F_NORESERVE : 0;
| ^~~~~

Quoted 4 lines

Replace the two macros with equivalent inline functions tto get the argument checking.

Fixes 6ff1610ced56 ("mm: shmem: use SHMEM_F_* flags instead of VM_* flags")

That's still not upstream, right?

$ git tag --contains 6ff1610ced56
mm-everything-2025-11-29-19-43
mm-everything-2025-12-03-23-49
next-20251201
next-20251203
next-20251204

So we can likely just squash it into the problematic commit before proceeding with it?

Thanks Arnd!

Signature · 3 lines
Cheers

David
#2 lore raw
Quoted 3 lines · David Hildenbrand (Red Hat)

So we can likely just squash it into the problematic commit before proceeding with it?

Yes, that would be best.

Arnd

#3 lore raw
In reply to David Hildenbrand (Red Hat)
Quoted 26 lines · David Hildenbrand (Red Hat)
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly added 'flags' variable is unused and causes a warning if CONFIG_SHMEM is disabled, since the shmem_acct_size() macro it is passed into does nothing:

mm/shmem.c: In function '__shmem_file_setup':
mm/shmem.c:5816:23: error: unused variable 'flags' [-Werror=unused-variable]
5816 | unsigned long flags = (vm_flags & VM_NORESERVE) ? SHMEM_F_NORESERVE : 0;
| ^~~~~

Quoted 4 lines

Replace the two macros with equivalent inline functions tto get the argument checking.

Fixes 6ff1610ced56 ("mm: shmem: use SHMEM_F_* flags instead of VM_* flags")

That's still not upstream, right?

$ git tag --contains 6ff1610ced56
mm-everything-2025-11-29-19-43
mm-everything-2025-12-03-23-49
next-20251201
next-20251203
next-20251204
Quoted 2 lines

So we can likely just squash it into the problematic commit before proceeding with it?

It's mm-nonmm-stable, I don't think fixups can go there.

Quoted 6 lines

Thanks Arnd!

Signature · 3 lines
Cheers

David
Signature · 2 lines
Sincerely yours,
Mike.
#4 lore raw
Quoted 27 lines · Mike Rapoport
Quoted 26 lines · David Hildenbrand (Red Hat)
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly added 'flags' variable is unused and causes a warning if CONFIG_SHMEM is disabled, since the shmem_acct_size() macro it is passed into does nothing:

mm/shmem.c: In function '__shmem_file_setup':
mm/shmem.c:5816:23: error: unused variable 'flags' [-Werror=unused-variable]
5816 | unsigned long flags = (vm_flags & VM_NORESERVE) ? SHMEM_F_NORESERVE : 0;
| ^~~~~

Quoted 4 lines

Replace the two macros with equivalent inline functions tto get the argument checking.

Fixes 6ff1610ced56 ("mm: shmem: use SHMEM_F_* flags instead of VM_* flags")

That's still not upstream, right?

$ git tag --contains 6ff1610ced56
mm-everything-2025-11-29-19-43
mm-everything-2025-12-03-23-49
next-20251201
next-20251203
next-20251204
Quoted 4 lines
Quoted 2 lines

So we can likely just squash it into the problematic commit before proceeding with it?

It's mm-nonmm-stable, I don't think fixups can go there.

Ah, I only looked at mm-stable and mm-unstable.

Confused why this is in nomm-stable and not mm-stable.

Anyhow:

Signature · 3 lines
Cheers

David
#5 lore raw
Quoted 28 lines · David Hildenbrand (Red Hat)
Quoted 27 lines · Mike Rapoport
Quoted 26 lines · David Hildenbrand (Red Hat)
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly added 'flags' variable is unused and causes a warning if CONFIG_SHMEM is disabled, since the shmem_acct_size() macro it is passed into does nothing:

mm/shmem.c: In function '__shmem_file_setup':
mm/shmem.c:5816:23: error: unused variable 'flags' [-Werror=unused-variable]
5816 | unsigned long flags = (vm_flags & VM_NORESERVE) ? SHMEM_F_NORESERVE : 0;
| ^~~~~

Quoted 4 lines

Replace the two macros with equivalent inline functions tto get the argument checking.

Fixes 6ff1610ced56 ("mm: shmem: use SHMEM_F_* flags instead of VM_* flags")

That's still not upstream, right?

$ git tag --contains 6ff1610ced56
mm-everything-2025-11-29-19-43
mm-everything-2025-12-03-23-49
next-20251201
next-20251203
next-20251204
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

So we can likely just squash it into the problematic commit before proceeding with it?

It's mm-nonmm-stable, I don't think fixups can go there.

Ah, I only looked at mm-stable and mm-unstable.

Confused why this is in nomm-stable and not mm-stable.

The patch came in with the liveupdate series [0], most of which counts as nonmm I suppose.

[0] https://lore.kernel.org/all/[email protected]/

[...]

Signature · 2 lines
Regards,
Pratyush Yadav
Acked-by on v2 1/1
#6 lore raw
In reply to Arnd Bergmann
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly added 'flags' variable is unused and causes a warning if CONFIG_SHMEM is disabled, since the shmem_acct_size() macro it is passed into does nothing:

mm/shmem.c: In function '__shmem_file_setup':
mm/shmem.c:5816:23: error: unused variable 'flags' [-Werror=unused-variable]
5816 | unsigned long flags = (vm_flags & VM_NORESERVE) ? SHMEM_F_NORESERVE : 0;
| ^~~~~

Quoted 5 lines

Replace the two macros with equivalent inline functions tto get the argument checking.

Fixes 6ff1610ced56 ("mm: shmem: use SHMEM_F_* flags instead of VM_* flags")
Quoted 2 lines

---
v2: make shmem_unacct_size() inline as well.

Signature · 2 lines
Sincerely yours,
Mike.
reviewer Reviewed-by on v2 1/1
#7 lore raw
In reply to Arnd Bergmann
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly added 'flags' variable is unused and causes a warning if CONFIG_SHMEM is disabled, since the shmem_acct_size() macro it is passed into does nothing:

mm/shmem.c: In function '__shmem_file_setup':
mm/shmem.c:5816:23: error: unused variable 'flags' [-Werror=unused-variable]
5816 | unsigned long flags = (vm_flags & VM_NORESERVE) ? SHMEM_F_NORESERVE : 0;
| ^~~~~

Quoted 8 lines

Replace the two macros with equivalent inline functions tto get the argument checking.

Fixes 6ff1610ced56 ("mm: shmem: use SHMEM_F_* flags instead of VM_* flags")

---
v2: make shmem_unacct_size() inline as well.
---

LGTM. Thanks.

Reviewed-by on v2 1/1
#8 lore raw
In reply to Arnd Bergmann
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly added 'flags' variable is unused and causes a warning if CONFIG_SHMEM is disabled, since the shmem_acct_size() macro it is passed into does nothing:

mm/shmem.c: In function '__shmem_file_setup':
mm/shmem.c:5816:23: error: unused variable 'flags' [-Werror=unused-variable]
5816 | unsigned long flags = (vm_flags & VM_NORESERVE) ? SHMEM_F_NORESERVE : 0;
| ^~~~~

Quoted 5 lines

Replace the two macros with equivalent inline functions tto get the argument checking.

Fixes 6ff1610ced56 ("mm: shmem: use SHMEM_F_* flags instead of VM_* flags")

[...]

Signature · 2 lines
Regards,
Pratyush Yadav
Reviewed-by on v2 1/1
#9 lore raw
In reply to Arnd Bergmann
Quoted 12 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly added 'flags' variable is unused and causes a warning if CONFIG_SHMEM is disabled, since the shmem_acct_size() macro it is passed into does nothing:

mm/shmem.c: In function '__shmem_file_setup':
mm/shmem.c:5816:23: error: unused variable 'flags' [-Werror=unused-variable]
5816 | unsigned long flags = (vm_flags & VM_NORESERVE) ? SHMEM_F_NORESERVE : 0;
| ^~~~~

Quoted 7 lines

Replace the two macros with equivalent inline functions tto get the argument checking.

Fixes 6ff1610ced56 ("mm: shmem: use SHMEM_F_* flags instead of VM_* flags")

---
v2: make shmem_unacct_size() inline as well.

for v2 as well, thank you for the fixes! :-)

Quoted 29 lines
---
 mm/shmem.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
mm/shmem.c +9 -3
index 3f194c9842a8..b329b5302c48 100644
@@ -5794,8 +5794,15 @@ EXPORT_SYMBOL_GPL(shmem_truncate_range);
 #define shmem_vm_ops                           generic_file_vm_ops
 #define shmem_anon_vm_ops                      generic_file_vm_ops
 #define shmem_file_operations                  ramfs_file_operations
-#define shmem_acct_size(flags, size)           0
-#define shmem_unacct_size(flags, size)         do {} while (0)
+
+static inline int shmem_acct_size(unsigned long flags, loff_t size)
+{
+       return 0;
+}
+
+static inline void shmem_unacct_size(unsigned long flags, loff_t size)
+{
+}
 
 static inline struct inode *shmem_get_inode(struct mnt_idmap *idmap,
                                struct super_block *sb, struct inode *dir,
--

2.39.5