From: Zenghui Yu <zenghui.yu@linux.dev>
To: linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org,
liam@infradead.org, vbabka@kernel.org, rppt@kernel.org,
surenb@google.com, mhocko@suse.com, shuah@kernel.org,
gourry@gourry.net, "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
Subject: [PATCH v2 2/3] selftests/mm: mark file-local symbols of pagemap_ioctl.c static
Date: Tue, 8 Sep 2026 21:43:14 +0800 [thread overview]
Message-ID: <20260908134315.84431-1-zenghui.yu@linux.dev> (raw)
In-Reply-To: <20260908134117.84405-1-zenghui.yu@linux.dev>
From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
The file-scope variables (pagemap_fd, uffd, page_size, hpage_size and
progname) and most functions of the pagemap_ioctl test are only used
locally, but lack the static storage class. Mark them static so that the
compiler can catch accidental outer references.
Suggested-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>
---
tools/testing/selftests/mm/pagemap_ioctl.c | 43 +++++++++++-----------
1 file changed, 21 insertions(+), 22 deletions(-)
diff --git a/tools/testing/selftests/mm/pagemap_ioctl.c b/tools/testing/selftests/mm/pagemap_ioctl.c
index 3665530eda76..1a87b7483316 100644
--- a/tools/testing/selftests/mm/pagemap_ioctl.c
+++ b/tools/testing/selftests/mm/pagemap_ioctl.c
@@ -36,11 +36,11 @@
#define TEST_ITERATIONS 100
#define PAGEMAP "/proc/self/pagemap"
-int pagemap_fd;
-int uffd;
-size_t page_size;
-size_t hpage_size;
-const char *progname;
+static int pagemap_fd;
+static int uffd;
+static size_t page_size;
+static size_t hpage_size;
+static const char *progname;
#define LEN(region) ((region.end - region.start)/page_size)
@@ -92,8 +92,7 @@ static long pagemap_ioc(void *start, size_t len, void *vec, size_t vec_len, int
return ret;
}
-
-int init_uffd(void)
+static int init_uffd(void)
{
struct uffdio_api uffdio_api;
@@ -116,7 +115,7 @@ int init_uffd(void)
return 0;
}
-int wp_init(void *addr, size_t size)
+static int wp_init(void *addr, size_t size)
{
struct uffdio_register uffdio_register;
struct uffdio_writeprotect wp;
@@ -140,7 +139,7 @@ int wp_init(void *addr, size_t size)
return 0;
}
-int wp_free(void *addr, size_t size)
+static int wp_free(void *addr, size_t size)
{
struct uffdio_register uffdio_register;
@@ -152,7 +151,7 @@ int wp_free(void *addr, size_t size)
return 0;
}
-int wp_addr_range(void *addr, size_t size)
+static int wp_addr_range(void *addr, size_t size)
{
if (pagemap_ioctl(addr, size, NULL, 0,
PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC,
@@ -162,7 +161,7 @@ int wp_addr_range(void *addr, size_t size)
return 0;
}
-void *gethugetlb_mem(size_t size, int *shmid)
+static void *gethugetlb_mem(size_t size, int *shmid)
{
char *mem;
@@ -186,7 +185,7 @@ void *gethugetlb_mem(size_t size, int *shmid)
return mem;
}
-int userfaultfd_tests(void)
+static int userfaultfd_tests(void)
{
size_t mem_size, vec_size, num_pages = 16;
long written;
@@ -230,7 +229,7 @@ int userfaultfd_tests(void)
return 0;
}
-int get_reads(struct page_region *vec, size_t vec_size)
+static int get_reads(struct page_region *vec, size_t vec_size)
{
size_t i;
int sum = 0;
@@ -241,7 +240,7 @@ int get_reads(struct page_region *vec, size_t vec_size)
return sum;
}
-int sanity_tests_sd(void)
+static int sanity_tests_sd(void)
{
size_t mem_size, vec_size, i, total_pages = 0;
long ret, ret2, ret3;
@@ -684,7 +683,7 @@ int sanity_tests_sd(void)
return 0;
}
-int base_tests(char *prefix, char *mem, size_t mem_size, int skip)
+static int base_tests(char *prefix, char *mem, size_t mem_size, int skip)
{
size_t vec_size;
int written;
@@ -789,7 +788,7 @@ int base_tests(char *prefix, char *mem, size_t mem_size, int skip)
return 0;
}
-void *gethugepage(size_t map_size)
+static void *gethugepage(size_t map_size)
{
int ret;
char *map;
@@ -807,7 +806,7 @@ void *gethugepage(size_t map_size)
return map;
}
-int hpage_unit_tests(void)
+static int hpage_unit_tests(void)
{
char *map;
int ret, ret2;
@@ -1001,7 +1000,7 @@ int hpage_unit_tests(void)
return 0;
}
-int unmapped_region_tests(void)
+static int unmapped_region_tests(void)
{
void *start = (void *)0x10000000;
int written;
@@ -1158,7 +1157,7 @@ static void unpopulated_thp_scan_test(void)
munmap(area, 2 * hpage_size);
}
-int sanity_tests(void)
+static int sanity_tests(void)
{
size_t mem_size, vec_size, i, buf_size;
long ret, fd, nr_pages;
@@ -1330,7 +1329,7 @@ int sanity_tests(void)
return 0;
}
-int mprotect_tests(void)
+static int mprotect_tests(void)
{
int ret;
char *mem, *mem2;
@@ -1450,7 +1449,7 @@ static ssize_t get_dirty_pages_reset(char *mem, unsigned int count,
return cnt;
}
-void *thread_proc(void *mem)
+static void *thread_proc(void *mem)
{
int *m = mem;
long curr_faults, faults;
@@ -1583,7 +1582,7 @@ static void transact_test(int page_size)
extra_thread_faults);
}
-void zeropfn_tests(void)
+static void zeropfn_tests(void)
{
size_t mem_size, i;
struct page_region vec;
--
2.53.0
next prev parent reply other threads:[~2026-09-08 13:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 13:41 [PATCH v2 0/3] selftests/mm: pagemap_ioctl test fixes and cleanups Zenghui Yu
2026-09-08 13:41 ` [PATCH v2 1/3] selftests/mm: fix size truncation in pagemap_ioctl test Zenghui Yu
2026-09-08 13:43 ` Zenghui Yu [this message]
2026-09-08 13:44 ` [PATCH v2 3/3] selftests/mm: init page sizes early " Zenghui Yu
2026-09-08 13:50 ` Zenghui Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260908134315.84431-1-zenghui.yu@linux.dev \
--to=zenghui.yu@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=gourry@gourry.net \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®