public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/2] __builtin___clear_cache() => __clear_cache()
@ 2025-10-12 19:49 Petr Vorel
  2025-10-12 19:49 ` [LTP] [PATCH v2 1/2] m4: mprotect04: Replace __builtin___clear_cache with __clear_cache Petr Vorel
  2025-10-12 19:49 ` [LTP] [PATCH v2 2/2] hugemmap15: Check for __clear_cache() Petr Vorel
  0 siblings, 2 replies; 7+ messages in thread
From: Petr Vorel @ 2025-10-12 19:49 UTC (permalink / raw)
  To: ltp; +Cc: Hui Min Mina Chou, Khem Raj

Hi,

I'm sorry for the noise. Changes v1->v2:
* Add missing #endif in the second commit.

Link to v1:
https://patchwork.ozlabs.org/project/ltp/list/?series=477318&state=*
https://lore.kernel.org/ltp/20251012194007.370008-1-petr.vorel@gmail.com/T/#t

Petr Vorel (2):
  m4: mprotect04: Replace __builtin___clear_cache with __clear_cache
  hugemmap15: Check for __clear_cache()

 configure.ac                                  |  2 +-
 m4/ltp-builtin_clear_cache.m4                 | 19 ------------------
 m4/ltp-clear_cache.m4                         | 20 +++++++++++++++++++
 .../kernel/mem/hugetlb/hugemmap/hugemmap15.c  |  4 ++++
 .../kernel/syscalls/mprotect/mprotect04.c     |  7 +++----
 5 files changed, 28 insertions(+), 24 deletions(-)
 delete mode 100644 m4/ltp-builtin_clear_cache.m4
 create mode 100644 m4/ltp-clear_cache.m4

-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH v2 1/2] m4: mprotect04: Replace __builtin___clear_cache with __clear_cache
  2025-10-12 19:49 [LTP] [PATCH v2 0/2] __builtin___clear_cache() => __clear_cache() Petr Vorel
@ 2025-10-12 19:49 ` Petr Vorel
  2025-12-18 12:22   ` Andrea Cervesato via ltp
  2026-01-22 10:23   ` Jan Stancek via ltp
  2025-10-12 19:49 ` [LTP] [PATCH v2 2/2] hugemmap15: Check for __clear_cache() Petr Vorel
  1 sibling, 2 replies; 7+ messages in thread
From: Petr Vorel @ 2025-10-12 19:49 UTC (permalink / raw)
  To: ltp; +Cc: Hui Min Mina Chou, Khem Raj

__clear_cache() should be quite common now and we already use it in
hugemmap15.c. Convert autotools m4 check to detect it.

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
Same as v1.

 configure.ac                                  |  2 +-
 m4/ltp-builtin_clear_cache.m4                 | 19 ------------------
 m4/ltp-clear_cache.m4                         | 20 +++++++++++++++++++
 .../kernel/syscalls/mprotect/mprotect04.c     |  7 +++----
 4 files changed, 24 insertions(+), 24 deletions(-)
 delete mode 100644 m4/ltp-builtin_clear_cache.m4
 create mode 100644 m4/ltp-clear_cache.m4

diff --git a/configure.ac b/configure.ac
index 0480f46ca2..461fa2b577 100644
--- a/configure.ac
+++ b/configure.ac
@@ -393,9 +393,9 @@ AC_CONFIG_COMMANDS([syscalls.h], [cd ${ac_top_srcdir}/include/lapi/syscalls; ./g
 # NOTE: don't create custom functions for simple checks, put them into this file
 LTP_CHECK_ACL_SUPPORT
 LTP_CHECK_ATOMIC_MEMORY_MODEL
-LTP_CHECK_BUILTIN_CLEAR_CACHE
 LTP_CHECK_CAPABILITY_SUPPORT
 LTP_CHECK_CC_WARN_OLDSTYLE
+LTP_CHECK_CLEAR_CACHE
 LTP_CHECK_CRYPTO
 LTP_CHECK_FORTIFY_SOURCE
 LTP_CHECK_KERNEL_DEVEL
diff --git a/m4/ltp-builtin_clear_cache.m4 b/m4/ltp-builtin_clear_cache.m4
deleted file mode 100644
index 86e1cfc914..0000000000
--- a/m4/ltp-builtin_clear_cache.m4
+++ /dev/null
@@ -1,19 +0,0 @@
-dnl SPDX-License-Identifier: GPL-2.0-or-later
-dnl Copyright (c) Linux Test Project, 2016
-
-AC_DEFUN([LTP_CHECK_BUILTIN_CLEAR_CACHE],[
-	AC_MSG_CHECKING([for __builtin___clear_cache])
-	AC_LINK_IFELSE([AC_LANG_SOURCE([[
-int main(void) {
-	char arr[16];
-	__builtin___clear_cache(arr, arr + sizeof(arr));
-        return 0;
-}]])],[has_bcc="yes"])
-
-if test "x$has_bcc" = xyes; then
-	AC_DEFINE(HAVE_BUILTIN_CLEAR_CACHE,1,[Define to 1 if you have __builtin___clear_cache])
-	AC_MSG_RESULT(yes)
-else
-	AC_MSG_RESULT(no)
-fi
-])
diff --git a/m4/ltp-clear_cache.m4 b/m4/ltp-clear_cache.m4
new file mode 100644
index 0000000000..99c6a1b653
--- /dev/null
+++ b/m4/ltp-clear_cache.m4
@@ -0,0 +1,20 @@
+dnl SPDX-License-Identifier: GPL-2.0-or-later
+dnl Copyright (c) Linux Test Project, 2016
+dnl Copyright (c) Linux Test Project, 2025
+
+AC_DEFUN([LTP_CHECK_CLEAR_CACHE],[
+	AC_MSG_CHECKING([for __clear_cache])
+	AC_LINK_IFELSE([AC_LANG_SOURCE([[
+int main(void) {
+	char arr[16];
+	__clear_cache(arr, arr + sizeof(arr));
+        return 0;
+}]])],[has_clear_cache="yes"])
+
+if test "x$has_clear_cache" = xyes; then
+	AC_DEFINE(HAVE_CLEAR_CACHE, 1, [Define to 1 if you have __clear_cache])
+	AC_MSG_RESULT(yes)
+else
+	AC_MSG_RESULT(no)
+fi
+])
diff --git a/testcases/kernel/syscalls/mprotect/mprotect04.c b/testcases/kernel/syscalls/mprotect/mprotect04.c
index 6c7f6bd017..fa4d3be4ba 100644
--- a/testcases/kernel/syscalls/mprotect/mprotect04.c
+++ b/testcases/kernel/syscalls/mprotect/mprotect04.c
@@ -152,11 +152,10 @@ static int page_present(void *p)
 
 static void clear_cache(void *start, int len)
 {
-#if HAVE_BUILTIN_CLEAR_CACHE == 1
-	__builtin___clear_cache(start, start + len);
+#ifdef HAVE_CLEAR_CACHE
+	__clear_cache(start, start + len);
 #else
-	tst_brkm(TCONF, cleanup,
-		"compiler doesn't have __builtin___clear_cache()");
+	tst_brkm(TCONF, cleanup, "compiler doesn't have __clear_cache()");
 #endif
 }
 
-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH v2 2/2] hugemmap15: Check for __clear_cache()
  2025-10-12 19:49 [LTP] [PATCH v2 0/2] __builtin___clear_cache() => __clear_cache() Petr Vorel
  2025-10-12 19:49 ` [LTP] [PATCH v2 1/2] m4: mprotect04: Replace __builtin___clear_cache with __clear_cache Petr Vorel
@ 2025-10-12 19:49 ` Petr Vorel
  2026-03-26 10:31   ` Andrea Cervesato via ltp
  1 sibling, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2025-10-12 19:49 UTC (permalink / raw)
  To: ltp; +Cc: Hui Min Mina Chou, Khem Raj

It fails to compile at least on riscv64 with older compiler.
It looks like it requires clang >= 20.1.0.

Reported-by: Khem Raj <raj.khem@gmail.com>
Cc: Hui Min Mina Chou <minachou@andestech.com>
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
Changes v1->v2:
* Add missing #endif

 testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c
index 1dde9e87ba..f2984e2dc0 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c
@@ -46,7 +46,11 @@ static void cacheflush(void *p)
 #if defined(__powerpc__)
 	asm volatile("dcbst 0,%0; sync; icbi 0,%0; isync" : : "r"(p));
 #elif defined(__arm__) || defined(__aarch64__) || defined(__riscv) || defined(__loongarch__)
+# ifdef HAVE_CLEAR_CACHE
 	__clear_cache(p, p + COPY_SIZE);
+# else
+	tst_brk(TCONF, "compiler doesn't have __clear_cache()");
+# endif
 #else
 	(void)p;
 #endif
-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH v2 1/2] m4: mprotect04: Replace __builtin___clear_cache with __clear_cache
  2025-10-12 19:49 ` [LTP] [PATCH v2 1/2] m4: mprotect04: Replace __builtin___clear_cache with __clear_cache Petr Vorel
@ 2025-12-18 12:22   ` Andrea Cervesato via ltp
  2026-01-22 10:23   ` Jan Stancek via ltp
  1 sibling, 0 replies; 7+ messages in thread
From: Andrea Cervesato via ltp @ 2025-12-18 12:22 UTC (permalink / raw)
  To: Petr Vorel, ltp; +Cc: Hui Min Mina Chou, Khem Raj

Hi!

I'm re-checking this patch, but I couldn't find many info about the real
implementation among many compilers. gcc seems to have it for a long
time, on clang is the default, so I guess we can merge __clear_cache
usage already.

Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>


-- 
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH v2 1/2] m4: mprotect04: Replace __builtin___clear_cache with __clear_cache
  2025-10-12 19:49 ` [LTP] [PATCH v2 1/2] m4: mprotect04: Replace __builtin___clear_cache with __clear_cache Petr Vorel
  2025-12-18 12:22   ` Andrea Cervesato via ltp
@ 2026-01-22 10:23   ` Jan Stancek via ltp
  1 sibling, 0 replies; 7+ messages in thread
From: Jan Stancek via ltp @ 2026-01-22 10:23 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Hui Min Mina Chou, Khem Raj, ltp

On Sun, Oct 12, 2025 at 9:50 PM Petr Vorel <petr.vorel@gmail.com> wrote:
>
> __clear_cache() should be quite common now and we already use it in
> hugemmap15.c. Convert autotools m4 check to detect it.
>
> Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
> ---

To series:
Acked-by: Jan Stancek <jstancek@redhat.com>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH v2 2/2] hugemmap15: Check for __clear_cache()
  2025-10-12 19:49 ` [LTP] [PATCH v2 2/2] hugemmap15: Check for __clear_cache() Petr Vorel
@ 2026-03-26 10:31   ` Andrea Cervesato via ltp
  2026-03-26 11:05     ` Petr Vorel
  0 siblings, 1 reply; 7+ messages in thread
From: Andrea Cervesato via ltp @ 2026-03-26 10:31 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Hui Min Mina Chou, Khem Raj, ltp

Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>

Feel free to merge.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH v2 2/2] hugemmap15: Check for __clear_cache()
  2026-03-26 10:31   ` Andrea Cervesato via ltp
@ 2026-03-26 11:05     ` Petr Vorel
  0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2026-03-26 11:05 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: Hui Min Mina Chou, Khem Raj, ltp

Hi all,

thanks for your review, merged!

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2026-03-26 11:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-12 19:49 [LTP] [PATCH v2 0/2] __builtin___clear_cache() => __clear_cache() Petr Vorel
2025-10-12 19:49 ` [LTP] [PATCH v2 1/2] m4: mprotect04: Replace __builtin___clear_cache with __clear_cache Petr Vorel
2025-12-18 12:22   ` Andrea Cervesato via ltp
2026-01-22 10:23   ` Jan Stancek via ltp
2025-10-12 19:49 ` [LTP] [PATCH v2 2/2] hugemmap15: Check for __clear_cache() Petr Vorel
2026-03-26 10:31   ` Andrea Cervesato via ltp
2026-03-26 11:05     ` Petr Vorel

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