Skip to contentSkip to conversation

hugemmap15 pre-release testing

PATCH In review Petr Vorel 3 participants 17 messages Jan 25, 2023 – Feb 13, 2023

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

cover hugemmap15 pre-release testing

Hi all,

it'd be good to merge tomorrow, to have it in upcoming release.

Kind regards,
Petr

Petr Vorel (2):
hugemmap15: Compile with -O
hugemmap15.c: Use TST_TEST_TCONF() for unsupported archs

 testcases/kernel/mem/hugetlb/hugemmap/Makefile     |  2 +-
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c | 14 ++++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)
Signature · 5 lines
2.39.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#1 lore raw

PATCH 1/2 hugemmap15: Compile with -O

-O0 originally used causes warning on gcc 12:

In file included from /usr/include/bits/libc-header-start.h:33,

                 from /usr/include/stdio.h:27,
                 from hugemmap15.c:22:

/usr/include/features.h:412:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
412 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O)

Fixes 15625f6185 ("Hugetlb: Migrating libhugetlbfs icache-hygiene")
---
 testcases/kernel/mem/hugetlb/hugemmap/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/mem/hugetlb/hugemmap/Makefile +1 -1
index 6f10807cde..503a35f7f1 100644
@@ -8,5 +8,5 @@ include $(top_srcdir)/include/mk/testcases.mk
 include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
 
-hugemmap15: CFLAGS+=-O0
+hugemmap15: CFLAGS+=-O
 hugemmap06: CFLAGS+=-pthread
Signature · 5 lines
2.39.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Re: [LTP] [PATCH 1/2] hugemmap15: Compile with -O

Hi Petr, Cyril, all

Though It already got merged, please note this,

IIRC, I specifically turned off optimization for hugemmap15 because of clang compiler issue, it behaves weirdly with clang without -O0 and test fails on the system.

Quoted 31 lines · Petr Vorel

-O0 originally used causes warning on gcc 12:

In file included from /usr/include/bits/libc-header-start.h:33,

                 from /usr/include/stdio.h:27,
                 from hugemmap15.c:22:

/usr/include/features.h:412:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
412 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O)

Fixes 15625f6185 ("Hugetlb: Migrating libhugetlbfs icache-hygiene")
---
 testcases/kernel/mem/hugetlb/hugemmap/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/mem/hugetlb/hugemmap/Makefile +1 -1
index 6f10807cde..503a35f7f1 100644
@@ -8,5 +8,5 @@ include $(top_srcdir)/include/mk/testcases.mk
 include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
 
-hugemmap15: CFLAGS+=-O0
+hugemmap15: CFLAGS+=-O
 hugemmap06: CFLAGS+=-pthread
Signature · 5 lines
2.39.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#3 lore raw

Re: [LTP] [PATCH 1/2] hugemmap15: Compile with -O

Hi Tarun,

Quoted 3 lines

Hi Petr, Cyril, all

Though It already got merged, please note this,

FYI this has not been merged (only the second patch "hugemmap15: Use TST_TEST_TCONF() for unsupported archs", which was needed to fix compilations).

Quoted 3 lines

IIRC, I specifically turned off optimization for hugemmap15 because of clang compiler issue, it behaves weirdly with clang without -O0 and test fails on the system.

Isn't -O the same as -O0 ?

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Re: [LTP] [PATCH 1/2] hugemmap15: Compile with -O

Quoted 7 lines · Petr Vorel

Hi Tarun,

Quoted 3 lines

Hi Petr, Cyril, all

Though It already got merged, please note this,

FYI this has not been merged (only the second patch "hugemmap15: Use TST_TEST_TCONF() for unsupported archs", which was needed to fix compilations).

Ok.

Quoted 6 lines
Quoted 4 lines

IIRC, I specifically turned off optimization for hugemmap15 because of clang compiler issue, it behaves weirdly with clang without -O0 and test fails on the system.

Isn't -O the same as -O0 ?

I think -O is -O1.

I tested with clang with -O, it fails. So yeah it is not turning off relevant optimization.

Quoted 6 lines

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#5 lore raw

Re: [LTP] [PATCH 1/2] hugemmap15: Compile with -O

Hi all,

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Though It already got merged, please note this,

FYI this has not been merged (only the second patch "hugemmap15: Use TST_TEST_TCONF() for unsupported archs", which was needed to fix compilations).

Ok.

And don't worry, this will not be merged before release, which is going to happen hopefully today (or on Monday).

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

IIRC, I specifically turned off optimization for hugemmap15 because of clang compiler issue, it behaves weirdly with clang without -O0 and test fails on the system.

Isn't -O the same as -O0 ?

I think -O is -O1.

Yes, -O Equivalent to -O1 [1].

Quoted 2 lines

I tested with clang with -O, it fails. So yeah it is not turning off relevant optimization.

Yes, you're right. It worked for me, but after full cleanup it really failed with -O or -O1 (at least on x86_64 on clang 15.0.7).

@Cyril: I wonder why we need
1) -D_FORTIFY_SOURCE=2 for all (in CPPFLAGS), defined in m4/ltp-fortify_source.m4, this will warn, when we need to disable optimisation for some test? -D_FORTIFY_SOURCE=0 obviously warn for redefinition.
It was added in 2013 (4b3007a8e1), not sure which glibc version required it, but maybe time to drop it? (after release of course)
2) to use CPPFLAGS and CFLAGS together?

Kind regards,
Petr

[1] https://clang.llvm.org/docs/CommandGuide/clang.html

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Re: [LTP] [PATCH 1/2] hugemmap15: Compile with -O

In reply to Tarun Sahu

Hi!

Quoted 2 lines

I tested with clang with -O, it fails. So yeah it is not turning off relevant optimization.

There seems to be pragma to turn off optimizations only for clang, can you try if adding:

#pragma clang optimize off

to the source and removeing the -O0 from the Makefile works?

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

Re: [LTP] [PATCH 1/2] hugemmap15: Compile with -O

Cyril Hrubis <[email protected]> writes:

Hi Cyril,

I tested with pragma, This works well.
Will send a patch.

Thanks
Tarun

Quoted 17 lines

Hi!

Quoted 2 lines

I tested with clang with -O, it fails. So yeah it is not turning off relevant optimization.

There seems to be pragma to turn off optimizations only for clang, can you try if adding:

#pragma clang optimize off

to the source and removeing the -O0 from the Makefile works?

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

PATCH 1/1 hugepage15: Resolve compile time warning generating with -O0

In reply to Petr Vorel

Instead of turning off the optimizaton with -O0 to resolve unwanted behaviour of clang with goto statements, this will make use of clang pragma to turn off the optimization for just clang compiler. This way, gcc won't throw unwanted warning on turning off optimization:
"warning: _FORTIFY_SOURCE requires compiling with optimization (-O)".

Also, removed redundant header-includes.

---
 testcases/kernel/mem/hugetlb/hugemmap/Makefile     |  1 -
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c | 12 ++++--------
 2 files changed, 4 insertions(+), 9 deletions(-)
testcases/kernel/mem/hugetlb/hugemmap/Makefile +0 -1
index 6f10807cd..2d651b4aa 100644
@@ -8,5 +8,4 @@ include $(top_srcdir)/include/mk/testcases.mk
 include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
 
-hugemmap15: CFLAGS+=-O0
 hugemmap06: CFLAGS+=-pthread
testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c +4 -8
index 4730d8d18..aae234135 100644
@@ -18,17 +18,13 @@
  * remap, or because the icache happens to get flushed in the interim.
  */
 
+#if defined(__clang__)
+	#pragma clang optimize off
+#endif
+
 #define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
 #include <setjmp.h>
-#include <unistd.h>
 #include <signal.h>
-#include <sys/mman.h>
-#include <ucontext.h>
-#include <limits.h>
-#include <sys/param.h>
-#include <sys/types.h>
 
 #include "hugetlb.h"
 
Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author Reviewed-by on v1 1/1
#9 lore raw

Re: [LTP] [PATCH] hugepage15: Resolve compile time warning generating with -O0

Hi Tarun,

Quoted 5 lines

Instead of turning off the optimizaton with -O0 to resolve unwanted behaviour of clang with goto statements, this will make use of clang pragma to turn off the optimization for just clang compiler. This way, gcc won't throw unwanted warning on turning off optimization:
"warning: _FORTIFY_SOURCE requires compiling with optimization (-O)".

Thanks!

Quoted 1 line

Also, removed redundant header-includes.

BTW this does not apply because there was change which is not in your fork:

1106777cd ("hugemmap15: Use TST_TEST_TCONF() for unsupported archs")

No need to repost, but please always rebase to current master before posting

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw

Re: [LTP] [PATCH] hugepage15: Resolve compile time warning generating with -O0

In reply to Tarun Sahu

Thanks for reviewing it, Petr.
Sent the re-based version.

Quoted 58 lines · Tarun Sahu

Instead of turning off the optimizaton with -O0 to resolve unwanted behaviour of clang with goto statements, this will make use of clang pragma to turn off the optimization for just clang compiler. This way, gcc won't throw unwanted warning on turning off optimization:
"warning: _FORTIFY_SOURCE requires compiling with optimization (-O)".

Also, removed redundant header-includes.

---
 testcases/kernel/mem/hugetlb/hugemmap/Makefile     |  1 -
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c | 12 ++++--------
 2 files changed, 4 insertions(+), 9 deletions(-)
testcases/kernel/mem/hugetlb/hugemmap/Makefile +0 -1
index 6f10807cd..2d651b4aa 100644
@@ -8,5 +8,4 @@ include $(top_srcdir)/include/mk/testcases.mk
 include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
 
-hugemmap15: CFLAGS+=-O0
 hugemmap06: CFLAGS+=-pthread
testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c +4 -8
index 4730d8d18..aae234135 100644
@@ -18,17 +18,13 @@
  * remap, or because the icache happens to get flushed in the interim.
  */
 
+#if defined(__clang__)
+	#pragma clang optimize off
+#endif
+
 #define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
 #include <setjmp.h>
-#include <unistd.h>
 #include <signal.h>
-#include <sys/mman.h>
-#include <ucontext.h>
-#include <limits.h>
-#include <sys/param.h>
-#include <sys/types.h>
 
 #include "hugetlb.h"
 
Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#11 lore raw

PATCH v2 1/1 hugepage15: Resolve compile time warning generating with -O0

In reply to Petr Vorel

Instead of turning off the optimizaton with -O0 to resolve unwanted behaviour of clang with goto statements, this will make use of clang pragma to turn off the optimization for just clang compiler. This way, gcc won't throw unwanted warning on turning off optimization:
"warning: _FORTIFY_SOURCE requires compiling with optimization (-O)".

Also, removed redundant header-includes.

---
v2:
- rebase and added Reviewed-by

 testcases/kernel/mem/hugetlb/hugemmap/Makefile     |  1 -
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c | 13 ++++---------
 2 files changed, 4 insertions(+), 10 deletions(-)
testcases/kernel/mem/hugetlb/hugemmap/Makefile +0 -1
index 6f10807cd..2d651b4aa 100644
@@ -8,5 +8,4 @@ include $(top_srcdir)/include/mk/testcases.mk
 include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
 
-hugemmap15: CFLAGS+=-O0
 hugemmap06: CFLAGS+=-pthread
testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c +4 -9
index 07e65a160..4d1984070 100644
@@ -19,6 +19,10 @@
  * remap, or because the icache happens to get flushed in the interim.
  */
 
+#if defined(__clang__)
+	#pragma clang optimize off
+#endif
+
 #define _GNU_SOURCE
 #include "hugetlb.h"
 
@@ -27,16 +31,7 @@
 	defined(__aarch64__) || (defined(__riscv) && __riscv_xlen == 64) || \
 	defined(__i386__) || defined(__x86_64__) || defined(__arm__)
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <setjmp.h>
-#include <unistd.h>
-#include <signal.h>
-#include <sys/mman.h>
-#include <ucontext.h>
-#include <limits.h>
-#include <sys/param.h>
-#include <sys/types.h>
 
 #define SUCC_JMP 1
 #define FAIL_JMP 2
Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#12 lore raw

Re: [LTP] [PATCH v2] hugepage15: Resolve compile time warning generating with -O0

Hi Tarun,

thanks for rebasing. I dared to separate include change into it's own commit (merged as 2 commits).

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#13 lore raw

PATCH 2/2 hugemmap15.c: Use TST_TEST_TCONF() for unsupported archs

In reply to Petr Vorel

15625f6185 broke LTP build at least on riscv32 and mipsel32 (and for any new arch in the future). Replace #error directive with TST_TEST_TCONF() fixes that.

Fixes 15625f6185 ("Hugetlb: Migrating libhugetlbfs icache-hygiene")
---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c +10 -4
index 4730d8d184..836225acd8 100644
@@ -19,6 +19,13 @@
  */
 
 #define _GNU_SOURCE
+
+#include "hugetlb.h"
+#if defined(__powerpc__) || defined(__powerpc64__) || defined(__ia64__) || \
+	defined(__s390__) || defined(__s390x__) || defined(__sparc__) || \
+	defined(__aarch64__) || (defined(__riscv) && __riscv_xlen == 64) || \
+	defined(__i386__) || defined(__x86_64__) || defined(__arm__)
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <setjmp.h>
@@ -30,8 +37,6 @@
 #include <sys/param.h>
 #include <sys/types.h>
 
-#include "hugetlb.h"
-
 #define SUCC_JMP 1
 #define FAIL_JMP 2
 #define COPY_SIZE	128
@@ -142,8 +147,6 @@ static void sig_handler(int signum, siginfo_t *si, void *uc)
 		siglongjmp(sig_escape, FAIL_JMP + SIGSEGV);
 	}
 #endif
-#else
-#error "Need to setup signal conditions for this arch"
 #endif
 }
 
@@ -241,3 +244,6 @@ static struct tst_test test = {
 	.test_all = run_test,
 	.hugepages = {3, TST_NEEDS},
 };
+#else
+	TST_TEST_TCONF("Architecture not supported");
+#endif
Signature · 5 lines
2.39.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 2/2
#14 lore raw

Re: [LTP] [PATCH 2/2] hugemmap15.c: Use TST_TEST_TCONF() for unsupported archs

Hi!

Quoted 47 lines

15625f6185 broke LTP build at least on riscv32 and mipsel32 (and for any new arch in the future). Replace #error directive with TST_TEST_TCONF() fixes that.

Fixes 15625f6185 ("Hugetlb: Migrating libhugetlbfs icache-hygiene")
---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c +7 -4
index 4730d8d184..836225acd8 100644
@@ -19,6 +19,13 @@
  */
 
 #define _GNU_SOURCE
+
+#include "hugetlb.h"
+#if defined(__powerpc__) || defined(__powerpc64__) || defined(__ia64__) || \
+	defined(__s390__) || defined(__s390x__) || defined(__sparc__) || \
+	defined(__aarch64__) || (defined(__riscv) && __riscv_xlen == 64) || \
+	defined(__i386__) || defined(__x86_64__) || defined(__arm__)
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <setjmp.h>
@@ -30,8 +37,6 @@
 #include <sys/param.h>
 #include <sys/types.h>
 
-#include "hugetlb.h"
-
 #define SUCC_JMP 1
 #define FAIL_JMP 2
 #define COPY_SIZE	128
@@ -142,8 +147,6 @@ static void sig_handler(int signum, siginfo_t *si, void *uc)
 		siglongjmp(sig_escape, FAIL_JMP + SIGSEGV);
 	}
 #endif
-#else
-#error "Need to setup signal conditions for this arch"
 #endif
 }
 

testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c static struct tst_test test = { · line 248

Quoted 5 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c +2 -0
@@ -241,3 +244,6 @@ static struct tst_test test = {
 	.test_all = run_test,
 	.hugepages = {3, TST_NEEDS},
 };
+#else
+	TST_TEST_TCONF("Architecture not supported");

^
Maybe I would change this to be closer to the original, so that it's clear that a piece of code needs to be written for the test to be enabled and that this is not inherently not supported

Something as:

	TST_TEST_TCONF("Signal handler for this architecture hasn't been written");

Other than this it looks fine, with a better message:

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#15 lore raw

Re: [LTP] [PATCH 2/2] hugemmap15.c: Use TST_TEST_TCONF() for unsupported archs

Hi Cyril,

...

Quoted 9 lines

testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c static struct tst_test test = { · line 248

Quoted 2 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c +2 -0
+#else
+	TST_TEST_TCONF("Architecture not supported");

^
Maybe I would change this to be closer to the original, so that it's clear that a piece of code needs to be written for the test to be enabled and that this is not inherently not supported

Quoted 3 lines

Something as:

	TST_TEST_TCONF("Signal handler for this architecture hasn't been written");

Very good idea, thanks!
I wait little longer for more input and merge later today.

Kind regards,
Petr

Quoted 3 lines

Other than this it looks fine, with a better message:

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#16 lore raw

Re: [LTP] [PATCH 2/2] hugemmap15.c: Use TST_TEST_TCONF() for unsupported archs

Hi all,

FYI merged.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp