[LTP] [PATCH v4 3/3] max_map_count: replace ifdefs by tst_arch
Li Wang
liwang@redhat.com
Tue Nov 9 14:09:10 CET 2021
Signed-off-by: Li Wang <liwang@redhat.com>
---
testcases/kernel/mem/tunable/max_map_count.c | 46 ++++++++++----------
1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/testcases/kernel/mem/tunable/max_map_count.c b/testcases/kernel/mem/tunable/max_map_count.c
index 4f0ad0037..bd5af0ff6 100644
--- a/testcases/kernel/mem/tunable/max_map_count.c
+++ b/testcases/kernel/mem/tunable/max_map_count.c
@@ -55,7 +55,6 @@
static long old_max_map_count = -1;
static long old_overcommit = -1;
-static struct utsname un;
static void setup(void)
{
@@ -66,9 +65,6 @@ static void setup(void)
old_max_map_count = get_sys_tune("max_map_count");
old_overcommit = get_sys_tune("overcommit_memory");
set_sys_tune("overcommit_memory", 0, 1);
-
- if (uname(&un) != 0)
- tst_brk(TBROK | TERRNO, "uname error");
}
static void cleanup(void)
@@ -91,24 +87,30 @@ static bool filter_map(const char *line)
if (ret != 1)
return false;
-#if defined(__x86_64__) || defined(__x86__)
- /* On x86, there's an old compat vsyscall page */
- if (!strcmp(buf, "[vsyscall]"))
- return true;
-#elif defined(__ia64__)
- /* On ia64, the vdso is not a proper mapping */
- if (!strcmp(buf, "[vdso]"))
- return true;
-#elif defined(__arm__)
- /* Skip it when run it in aarch64 */
- if ((!strcmp(un.machine, "aarch64"))
- || (!strcmp(un.machine, "aarch64_be")))
- return false;
-
- /* Older arm kernels didn't label their vdso maps */
- if (!strncmp(line, "ffff0000-ffff1000", 17))
- return true;
-#endif
+ switch (tst_arch.type) {
+ case TST_I386:
+ case TST_X86_64:
+ /* On x86, there's an old compat vsyscall page */
+ if (!strcmp(buf, "[vsyscall]"))
+ return true;
+ break;
+ case TST_IA64:
+ /* On ia64, the vdso is not a proper mapping */
+ if (!strcmp(buf, "[vdso]"))
+ return true;
+ break;
+ case TST_ARM:
+ /* Skip it when run it in aarch64 */
+ if (tst_kernel_bits() == 64)
+ return false;
+
+ /* Older arm kernels didn't label their vdso maps */
+ if (!strncmp(line, "ffff0000-ffff1000", 17))
+ return true;
+ break;
+ default:
+ break;
+ };
return false;
}
--
2.31.1
More information about the ltp
mailing list