linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: shmem: avoid build warning for CONFIG_SHMEM=n
@ 2025-12-04  9:44 Arnd Bergmann
  2025-12-04 10:02 ` Pratyush Yadav
  2025-12-04 14:07 ` Pasha Tatashin
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2025-12-04  9:44 UTC (permalink / raw)
  To: Hugh Dickins, Andrew Morton, Mike Rapoport (Microsoft),
	Pasha Tatashin, Pratyush Yadav
  Cc: Arnd Bergmann, Baolin Wang, Kairui Song, David Hildenbrand,
	Christian Brauner, Kemeng Shi, Lorenzo Stoakes, Guo Weikang,
	linux-mm, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

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 macro with an equivalent inline function to get the
argument checking.

Fixes: 6ff1610ced56 ("mm: shmem: use SHMEM_F_* flags instead of VM_* flags")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 mm/shmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 3f194c9842a8..93746270c459 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -5794,7 +5794,7 @@ 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
+static inline int shmem_acct_size(unsigned long flags, loff_t size) { return 0; }
 #define shmem_unacct_size(flags, size)		do {} while (0)
 
 static inline struct inode *shmem_get_inode(struct mnt_idmap *idmap,
-- 
2.39.5



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

* Re: [PATCH] mm: shmem: avoid build warning for CONFIG_SHMEM=n
  2025-12-04  9:44 [PATCH] mm: shmem: avoid build warning for CONFIG_SHMEM=n Arnd Bergmann
@ 2025-12-04 10:02 ` Pratyush Yadav
  2025-12-04 14:07 ` Pasha Tatashin
  1 sibling, 0 replies; 3+ messages in thread
From: Pratyush Yadav @ 2025-12-04 10:02 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Hugh Dickins, Andrew Morton, Mike Rapoport (Microsoft),
	Pasha Tatashin, Pratyush Yadav, Arnd Bergmann, Baolin Wang,
	Kairui Song, David Hildenbrand, Christian Brauner, Kemeng Shi,
	Lorenzo Stoakes, Guo Weikang, linux-mm, linux-kernel

Hi Arnd,

On Thu, Dec 04 2025, Arnd Bergmann wrote:

> From: Arnd Bergmann <arnd@arndb.de>
>
> 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 macro with an equivalent inline function to get the
> argument checking.
>
> Fixes: 6ff1610ced56 ("mm: shmem: use SHMEM_F_* flags instead of VM_* flags")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks for the fix!

I recall that the kernel test robot also reported something similar, and
Andrew sent out a fix for that [0]. But I guess it got dropped in the
later re-rolls of the patchset.

> ---
>  mm/shmem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 3f194c9842a8..93746270c459 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -5794,7 +5794,7 @@ 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
> +static inline int shmem_acct_size(unsigned long flags, loff_t size) { return 0; }
>  #define shmem_unacct_size(flags, size)		do {} while (0)

Can you please also make shmem_unacct_size() an inline function for
consistency?

>  
>  static inline struct inode *shmem_get_inode(struct mnt_idmap *idmap,

[0] https://lore.kernel.org/all/20251108084308.8640699dc4f737c520841391@linux-foundation.org/

-- 
Regards,
Pratyush Yadav


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

* Re: [PATCH] mm: shmem: avoid build warning for CONFIG_SHMEM=n
  2025-12-04  9:44 [PATCH] mm: shmem: avoid build warning for CONFIG_SHMEM=n Arnd Bergmann
  2025-12-04 10:02 ` Pratyush Yadav
@ 2025-12-04 14:07 ` Pasha Tatashin
  1 sibling, 0 replies; 3+ messages in thread
From: Pasha Tatashin @ 2025-12-04 14:07 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Hugh Dickins, Andrew Morton, Mike Rapoport (Microsoft),
	Pratyush Yadav, Arnd Bergmann, Baolin Wang, Kairui Song,
	David Hildenbrand, Christian Brauner, Kemeng Shi,
	Lorenzo Stoakes, Guo Weikang, linux-mm, linux-kernel

On Thu, Dec 4, 2025 at 4:44 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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 macro with an equivalent inline function to get the
> argument checking.
>
> Fixes: 6ff1610ced56 ("mm: shmem: use SHMEM_F_* flags instead of VM_* flags")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>

Thanks,
Pasha


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

end of thread, other threads:[~2025-12-04 14:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-04  9:44 [PATCH] mm: shmem: avoid build warning for CONFIG_SHMEM=n Arnd Bergmann
2025-12-04 10:02 ` Pratyush Yadav
2025-12-04 14:07 ` Pasha Tatashin

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