linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftest/vm_util: remove unused variables
@ 2025-11-04  6:28 Zhang Chujun
  2025-11-05 22:16 ` Lorenzo Stoakes
  0 siblings, 1 reply; 3+ messages in thread
From: Zhang Chujun @ 2025-11-04  6:28 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, david, thomas.weissschuh, Zhang Chujun

The global variables __page_size and __page_shift are declared in
vm_util.c, but they are never used anywhere in the codebase. This
patch removes them to clean up the source and eliminate dead code.

Signed-off-by: Zhang Chujun <zhangchujun@cmss.chinamobile.com>

diff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftests/mm/vm_util.c
index 3869e68bb8b5..3983c368edd2 100644
--- a/tools/testing/selftests/mm/vm_util.c
+++ b/tools/testing/selftests/mm/vm_util.c
@@ -17,9 +17,6 @@
 #define STATUS_FILE_PATH "/proc/self/status"
 #define MAX_LINE_LENGTH 500
 
-unsigned int __page_size;
-unsigned int __page_shift;
-
 uint64_t pagemap_get_entry(int fd, char *start)
 {
 	const unsigned long pfn = (unsigned long)start / getpagesize();
-- 
2.50.1.windows.1





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

* Re: [PATCH] selftest/vm_util: remove unused variables
  2025-11-04  6:28 [PATCH] selftest/vm_util: remove unused variables Zhang Chujun
@ 2025-11-05 22:16 ` Lorenzo Stoakes
  2025-11-06 10:04   ` David Hildenbrand (Red Hat)
  0 siblings, 1 reply; 3+ messages in thread
From: Lorenzo Stoakes @ 2025-11-05 22:16 UTC (permalink / raw)
  To: Zhang Chujun; +Cc: akpm, linux-mm, david, thomas.weissschuh

Andrew - can we drop this from mm-new please? It's broken the build.

I get a splurge of linker errors building the mm selftests otherwise:

/usr/bin/ld: /tmp/ccA0DyGC.o: in function `__pagemap_scan_get_categories':
vm_util.c:(.text+0x1e9): undefined reference to `__page_size'
/usr/bin/ld: vm_util.c:(.text+0x2bd): undefined reference to `__page_size'
/usr/bin/ld: /tmp/ccA0DyGC.o: in function `allocate_transhuge':
vm_util.c:(.text+0xb90): undefined reference to `__page_shift'
/usr/bin/ld: vm_util.c:(.text+0xbfe): undefined reference to `__page_shift'
/usr/bin/ld: vm_util.c:(.text+0xc52): undefined reference to `__page_size'
/usr/bin/ld: vm_util.c:(.text+0xc67): undefined reference to `__page_shift'
/usr/bin/ld: vm_util.c:(.text+0xc72): undefined reference to `__page_size'
/usr/bin/ld: vm_util.c:(.text+0xc87): undefined reference to `__page_shift'
/usr/bin/ld: vm_util.c:(.text+0xc9c): undefined reference to `__page_size'
/usr/bin/ld: vm_util.c:(.text+0xcc4): undefined reference to `__page_size'

etc.

The idea that nobody uses these variables is simply false, see vm_util.h in same
directory:

extern unsigned int __page_size;
extern unsigned int __page_shift;

static inline unsigned int psize(void)
{
	if (!__page_size)
		__page_size = sysconf(_SC_PAGESIZE);
	return __page_size;
}

static inline unsigned int pshift(void)
{
	if (!__page_shift)
		__page_shift = (ffsl(psize()) - 1);
	return __page_shift;
}

So this patch just seems to be completely broken?

Thanks, Lorenzo


On Tue, Nov 04, 2025 at 02:28:55PM +0800, Zhang Chujun wrote:
> The global variables __page_size and __page_shift are declared in
> vm_util.c, but they are never used anywhere in the codebase. This
> patch removes them to clean up the source and eliminate dead code.
>
> Signed-off-by: Zhang Chujun <zhangchujun@cmss.chinamobile.com>
>
> diff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftests/mm/vm_util.c
> index 3869e68bb8b5..3983c368edd2 100644
> --- a/tools/testing/selftests/mm/vm_util.c
> +++ b/tools/testing/selftests/mm/vm_util.c
> @@ -17,9 +17,6 @@
>  #define STATUS_FILE_PATH "/proc/self/status"
>  #define MAX_LINE_LENGTH 500
>
> -unsigned int __page_size;
> -unsigned int __page_shift;
> -
>  uint64_t pagemap_get_entry(int fd, char *start)
>  {
>  	const unsigned long pfn = (unsigned long)start / getpagesize();
> --
> 2.50.1.windows.1
>
>
>
>
>


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

* Re: [PATCH] selftest/vm_util: remove unused variables
  2025-11-05 22:16 ` Lorenzo Stoakes
@ 2025-11-06 10:04   ` David Hildenbrand (Red Hat)
  0 siblings, 0 replies; 3+ messages in thread
From: David Hildenbrand (Red Hat) @ 2025-11-06 10:04 UTC (permalink / raw)
  To: Lorenzo Stoakes, Zhang Chujun; +Cc: akpm, linux-mm, thomas.weissschuh

On 05.11.25 23:16, Lorenzo Stoakes wrote:
> Andrew - can we drop this from mm-new please? It's broken the build.
> 
> I get a splurge of linker errors building the mm selftests otherwise:
> 
> /usr/bin/ld: /tmp/ccA0DyGC.o: in function `__pagemap_scan_get_categories':
> vm_util.c:(.text+0x1e9): undefined reference to `__page_size'
> /usr/bin/ld: vm_util.c:(.text+0x2bd): undefined reference to `__page_size'
> /usr/bin/ld: /tmp/ccA0DyGC.o: in function `allocate_transhuge':
> vm_util.c:(.text+0xb90): undefined reference to `__page_shift'
> /usr/bin/ld: vm_util.c:(.text+0xbfe): undefined reference to `__page_shift'
> /usr/bin/ld: vm_util.c:(.text+0xc52): undefined reference to `__page_size'
> /usr/bin/ld: vm_util.c:(.text+0xc67): undefined reference to `__page_shift'
> /usr/bin/ld: vm_util.c:(.text+0xc72): undefined reference to `__page_size'
> /usr/bin/ld: vm_util.c:(.text+0xc87): undefined reference to `__page_shift'
> /usr/bin/ld: vm_util.c:(.text+0xc9c): undefined reference to `__page_size'
> /usr/bin/ld: vm_util.c:(.text+0xcc4): undefined reference to `__page_size'
> 
> etc.
> 
> The idea that nobody uses these variables is simply false, see vm_util.h in same
> directory:
> 
> extern unsigned int __page_size;
> extern unsigned int __page_shift;
> 
> static inline unsigned int psize(void)
> {
> 	if (!__page_size)
> 		__page_size = sysconf(_SC_PAGESIZE);
> 	return __page_size;
> }
> 
> static inline unsigned int pshift(void)
> {
> 	if (!__page_shift)
> 		__page_shift = (ffsl(psize()) - 1);
> 	return __page_shift;
> }
> 
> So this patch just seems to be completely broken?

Grml, I only skipped over the file and didn't think of the header. Nasty.

Note to myself to not trust anybody that they are even performing a 
basic compile test. Hard to believe that's not the case when wanting to 
contribute to the Linux kernel ...


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

end of thread, other threads:[~2025-11-06 10:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-04  6:28 [PATCH] selftest/vm_util: remove unused variables Zhang Chujun
2025-11-05 22:16 ` Lorenzo Stoakes
2025-11-06 10:04   ` David Hildenbrand (Red Hat)

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