Skip to contentSkip to conversation

mm/shmem.c:139:24: warning: 'huge_shmem_orders_lock' defined but not used

PATCH kernel test robot 2 participants 2 messages Jun 15, 2024 – Jun 16, 2024

Subsystems (2)
lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   6906a84c482f098d31486df8dc98cead21cce2d0
commit: dfe69b2f4ed49aee4a46f09010f7888ee289083d [4839/5501] mm: shmem: add multi-size THP sysfs interface for anonymous shmem
config: mips-randconfig-r034-20220430 (https://download.01.org/0day-ci/archive/20240615/[email protected]/config)
compiler: mips-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240615/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from include/linux/spinlock.h:89,

                    from include/linux/wait.h:9,
                    from include/linux/wait_bit.h:8,
                    from include/linux/fs.h:6,
                    from mm/shmem.c:24:
>> mm/shmem.c:139:24: warning: 'huge_shmem_orders_lock' defined but not used [-Wunused-variable]
     139 | static DEFINE_SPINLOCK(huge_shmem_orders_lock);
         |                        ^~~~~~~~~~~~~~~~~~~~~~
   include/linux/spinlock_types.h:43:44: note: in definition of macro 'DEFINE_SPINLOCK'
      43 | #define DEFINE_SPINLOCK(x)      spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
         |                                            ^
   mm/shmem.c:138:22: warning: 'huge_shmem_orders_within_size' defined but not used [-Wunused-variable]
     138 | static unsigned long huge_shmem_orders_within_size __read_mostly;
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/shmem.c:136:22: warning: 'huge_shmem_orders_madvise' defined but not used [-Wunused-variable]
     136 | static unsigned long huge_shmem_orders_madvise __read_mostly;
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~
   mm/shmem.c:135:22: warning: 'huge_shmem_orders_always' defined but not used [-Wunused-variable]
     135 | static unsigned long huge_shmem_orders_always __read_mostly;
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~

vim +/huge_shmem_orders_lock +139 mm/shmem.c

133
134 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
135 static unsigned long huge_shmem_orders_always __read_mostly;
136 static unsigned long huge_shmem_orders_madvise __read_mostly;
137 static unsigned long huge_shmem_orders_inherit __read_mostly;
138 static unsigned long huge_shmem_orders_within_size __read_mostly;

 > 139	static DEFINE_SPINLOCK(huge_shmem_orders_lock);

140 #endif
141

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reviewer
#1 lore raw
Quoted 44 lines · kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   6906a84c482f098d31486df8dc98cead21cce2d0
commit: dfe69b2f4ed49aee4a46f09010f7888ee289083d [4839/5501] mm: shmem: add multi-size THP sysfs interface for anonymous shmem
config: mips-randconfig-r034-20220430 (https://download.01.org/0day-ci/archive/20240615/[email protected]/config)
compiler: mips-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240615/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from include/linux/spinlock.h:89,
from include/linux/wait.h:9, from include/linux/wait_bit.h:8, from include/linux/fs.h:6, from mm/shmem.c:24:

Quoted 1 line
Quoted 1 line

mm/shmem.c:139:24: warning: 'huge_shmem_orders_lock' defined but not used [-Wunused-variable]

      139 | static DEFINE_SPINLOCK(huge_shmem_orders_lock);
          |                        ^~~~~~~~~~~~~~~~~~~~~~
    include/linux/spinlock_types.h:43:44: note: in definition of macro 'DEFINE_SPINLOCK'
       43 | #define DEFINE_SPINLOCK(x)      spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
          |                                            ^
    mm/shmem.c:138:22: warning: 'huge_shmem_orders_within_size' defined but not used [-Wunused-variable]
      138 | static unsigned long huge_shmem_orders_within_size __read_mostly;
          |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    mm/shmem.c:136:22: warning: 'huge_shmem_orders_madvise' defined but not used [-Wunused-variable]
      136 | static unsigned long huge_shmem_orders_madvise __read_mostly;
          |                      ^~~~~~~~~~~~~~~~~~~~~~~~~
    mm/shmem.c:135:22: warning: 'huge_shmem_orders_always' defined but not used [-Wunused-variable]
      135 | static unsigned long huge_shmem_orders_always __read_mostly;
          |                      ^~~~~~~~~~~~~~~~~~~~~~~~

vim +/huge_shmem_orders_lock +139 mm/shmem.c

    133	
    134	#ifdef CONFIG_TRANSPARENT_HUGEPAGE
    135	static unsigned long huge_shmem_orders_always __read_mostly;
    136	static unsigned long huge_shmem_orders_madvise __read_mostly;
    137	static unsigned long huge_shmem_orders_inherit __read_mostly;
    138	static unsigned long huge_shmem_orders_within_size __read_mostly;
Quoted 3 lines
Quoted 1 line

139 static DEFINE_SPINLOCK(huge_shmem_orders_lock);

    140	#endif
    141	

Thanks for reporting. I should move the 'huge_shmem_orders_lock' under CONFIG_SYSFS config.

@Andrew, please help to squash the following fix into this patch. Thanks.

mm/shmem.c +1 -1
index 4acaf02bfe44..d09c6bf1f28a 100644
@@ -136,7 +136,6 @@ static unsigned long huge_shmem_orders_always __read_mostly;
 static unsigned long huge_shmem_orders_madvise __read_mostly;
 static unsigned long huge_shmem_orders_inherit __read_mostly;
 static unsigned long huge_shmem_orders_within_size __read_mostly;
-static DEFINE_SPINLOCK(huge_shmem_orders_lock);
 #endif
 
 #ifdef CONFIG_TMPFS
@@ -4918,6 +4917,7 @@ static ssize_t shmem_enabled_store(struct kobject *kobj,
 }
 
 struct kobj_attribute shmem_enabled_attr = __ATTR_RW(shmem_enabled);
+static DEFINE_SPINLOCK(huge_shmem_orders_lock);
 
 static ssize_t thpsize_shmem_enabled_show(struct kobject *kobj,
                                          struct kobj_attribute *attr, 

char *buf)