Message ID | 20211108021450.1460819-3-liwang@redhat.com |
---|---|
State | Changes Requested |
Headers | show |
Series | [v3,1/3] lib: adding .supported_archs field in tst_test structure | expand |
On Mon, Nov 08, 2021 at 10:14:50AM +0800, Li Wang wrote: > Signed-off-by: Li Wang <liwang@redhat.com> > --- > testcases/kernel/mem/tunable/max_map_count.c | 41 +++++++++++--------- > 1 file changed, 23 insertions(+), 18 deletions(-) > > diff --git a/testcases/kernel/mem/tunable/max_map_count.c b/testcases/kernel/mem/tunable/max_map_count.c > index 4f0ad0037..9da67520c 100644 > --- a/testcases/kernel/mem/tunable/max_map_count.c > +++ b/testcases/kernel/mem/tunable/max_map_count.c > @@ -91,24 +91,29 @@ 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_X86: > + 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 ((!strcmp(un.machine, "aarch64")) > + || (!strcmp(un.machine, "aarch64_be"))) > + return false; I wonder if this would be better as: if (tst_kernel_bits() == 64) return false; Other than this the code looks actually better this way. > + /* Older arm kernels didn't label their vdso maps */ > + if (!strncmp(line, "ffff0000-ffff1000", 17)) > + return true; > + break; > + }; > > return false; > } > -- > 2.31.1 > > > -- > Mailing list info: https://lists.linux.it/listinfo/ltp
> > + switch (tst_arch.type) { > > + case TST_X86: > > + 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 ((!strcmp(un.machine, "aarch64")) > > + || (!strcmp(un.machine, "aarch64_be"))) > > + return false; > > I wonder if this would be better as: > > if (tst_kernel_bits() == 64) > return false; > Actually, we have TST_AARCH64 already, I'd go with switch to that.
Hi! > > > + switch (tst_arch.type) { > > > + case TST_X86: > > > + 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 ((!strcmp(un.machine, "aarch64")) > > > + || (!strcmp(un.machine, "aarch64_be"))) > > > + return false; > > > > I wonder if this would be better as: > > > > if (tst_kernel_bits() == 64) > > return false; > > > > Actually, we have TST_AARCH64 already, I'd go with switch to that. That wouldn't work right? Since we are checking here if 32bit ARM binary runs on 64bit AARCH64 kernel. The tst_arch defines for which architecture the binary was build while the tst_kernel_bits() checks if the kernel is 32bit or 64bit.
> > > I wonder if this would be better as: > > > > > > if (tst_kernel_bits() == 64) > > > return false; > > > > > > > Actually, we have TST_AARCH64 already, I'd go with switch to that. > > That wouldn't work right? Since we are checking here if 32bit ARM binary > runs on 64bit AARCH64 kernel. The tst_arch defines for which > architecture the binary was build while the tst_kernel_bits() checks if > the kernel is 32bit or 64bit. > Right, I didn't realize that situation. Thanks for the reminder~
diff --git a/testcases/kernel/mem/tunable/max_map_count.c b/testcases/kernel/mem/tunable/max_map_count.c index 4f0ad0037..9da67520c 100644 --- a/testcases/kernel/mem/tunable/max_map_count.c +++ b/testcases/kernel/mem/tunable/max_map_count.c @@ -91,24 +91,29 @@ 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_X86: + 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 ((!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; + break; + }; return false; }
Signed-off-by: Li Wang <liwang@redhat.com> --- testcases/kernel/mem/tunable/max_map_count.c | 41 +++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-)