linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] printk: Export console trace point for kcsan/kasan/kfence/kmsan
@ 2023-04-13 10:08 Pavankumar Kondeti
  2023-04-14  8:11 ` Petr Mladek
  2023-04-15  6:58 ` Sergey Senozhatsky
  0 siblings, 2 replies; 4+ messages in thread
From: Pavankumar Kondeti @ 2023-04-13 10:08 UTC (permalink / raw)
  To: Marco Elver, Dmitry Vyukov, Petr Mladek, Sergey Senozhatsky,
	Steven Rostedt, John Ogness, Andrey Ryabinin,
	Alexander Potapenko, Andrey Konovalov, Vincenzo Frascino,
	Andrew Morton
  Cc: kasan-dev, linux-kernel, linux-mm, Pavankumar Kondeti

The console tracepoint is used by kcsan/kasan/kfence/kmsan test
modules. Since this tracepoint is not exported, these modules iterate
over all available tracepoints to find the console trace point.
Export the trace point so that it can be directly used.

Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
---
 kernel/kcsan/kcsan_test.c | 20 ++++++--------------
 kernel/printk/printk.c    |  2 ++
 mm/kasan/kasan_test.c     | 22 ++--------------------
 mm/kfence/kfence_test.c   | 22 ++--------------------
 mm/kmsan/kmsan_test.c     | 22 ++--------------------
 5 files changed, 14 insertions(+), 74 deletions(-)

diff --git a/kernel/kcsan/kcsan_test.c b/kernel/kcsan/kcsan_test.c
index a60c561724be..0ddbdab5903d 100644
--- a/kernel/kcsan/kcsan_test.c
+++ b/kernel/kcsan/kcsan_test.c
@@ -1572,34 +1572,26 @@ static void test_exit(struct kunit *test)
 }
 
 __no_kcsan
-static void register_tracepoints(struct tracepoint *tp, void *ignore)
+static void register_tracepoints(void)
 {
-	check_trace_callback_type_console(probe_console);
-	if (!strcmp(tp->name, "console"))
-		WARN_ON(tracepoint_probe_register(tp, probe_console, NULL));
+	register_trace_console(probe_console, NULL);
 }
 
 __no_kcsan
-static void unregister_tracepoints(struct tracepoint *tp, void *ignore)
+static void unregister_tracepoints(void)
 {
-	if (!strcmp(tp->name, "console"))
-		tracepoint_probe_unregister(tp, probe_console, NULL);
+	unregister_trace_console(probe_console, NULL);
 }
 
 static int kcsan_suite_init(struct kunit_suite *suite)
 {
-	/*
-	 * Because we want to be able to build the test as a module, we need to
-	 * iterate through all known tracepoints, since the static registration
-	 * won't work here.
-	 */
-	for_each_kernel_tracepoint(register_tracepoints, NULL);
+	register_tracepoints();
 	return 0;
 }
 
 static void kcsan_suite_exit(struct kunit_suite *suite)
 {
-	for_each_kernel_tracepoint(unregister_tracepoints, NULL);
+	unregister_tracepoints();
 	tracepoint_synchronize_unregister();
 }
 
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index a5ed2e53547c..8bb9e8752d65 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -71,6 +71,8 @@ EXPORT_SYMBOL_GPL(console_printk);
 atomic_t ignore_console_lock_warning __read_mostly = ATOMIC_INIT(0);
 EXPORT_SYMBOL(ignore_console_lock_warning);
 
+EXPORT_TRACEPOINT_SYMBOL_GPL(console);
+
 /*
  * Low level drivers may need that to know if they can schedule in
  * their unblank() callback or not. So let's export it.
diff --git a/mm/kasan/kasan_test.c b/mm/kasan/kasan_test.c
index 74cd80c12b25..edf3158fc075 100644
--- a/mm/kasan/kasan_test.c
+++ b/mm/kasan/kasan_test.c
@@ -56,19 +56,6 @@ static void probe_console(void *ignore, const char *buf, size_t len)
 		WRITE_ONCE(test_status.async_fault, true);
 }
 
-static void register_tracepoints(struct tracepoint *tp, void *ignore)
-{
-	check_trace_callback_type_console(probe_console);
-	if (!strcmp(tp->name, "console"))
-		WARN_ON(tracepoint_probe_register(tp, probe_console, NULL));
-}
-
-static void unregister_tracepoints(struct tracepoint *tp, void *ignore)
-{
-	if (!strcmp(tp->name, "console"))
-		tracepoint_probe_unregister(tp, probe_console, NULL);
-}
-
 static int kasan_suite_init(struct kunit_suite *suite)
 {
 	if (!kasan_enabled()) {
@@ -86,12 +73,7 @@ static int kasan_suite_init(struct kunit_suite *suite)
 	 */
 	multishot = kasan_save_enable_multi_shot();
 
-	/*
-	 * Because we want to be able to build the test as a module, we need to
-	 * iterate through all known tracepoints, since the static registration
-	 * won't work here.
-	 */
-	for_each_kernel_tracepoint(register_tracepoints, NULL);
+	register_trace_console(probe_console, NULL);
 	return 0;
 }
 
@@ -99,7 +81,7 @@ static void kasan_suite_exit(struct kunit_suite *suite)
 {
 	kasan_kunit_test_suite_end();
 	kasan_restore_multi_shot(multishot);
-	for_each_kernel_tracepoint(unregister_tracepoints, NULL);
+	unregister_trace_console(probe_console, NULL);
 	tracepoint_synchronize_unregister();
 }
 
diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c
index b5d66a69200d..6aee19a79236 100644
--- a/mm/kfence/kfence_test.c
+++ b/mm/kfence/kfence_test.c
@@ -825,33 +825,15 @@ static void test_exit(struct kunit *test)
 	test_cache_destroy();
 }
 
-static void register_tracepoints(struct tracepoint *tp, void *ignore)
-{
-	check_trace_callback_type_console(probe_console);
-	if (!strcmp(tp->name, "console"))
-		WARN_ON(tracepoint_probe_register(tp, probe_console, NULL));
-}
-
-static void unregister_tracepoints(struct tracepoint *tp, void *ignore)
-{
-	if (!strcmp(tp->name, "console"))
-		tracepoint_probe_unregister(tp, probe_console, NULL);
-}
-
 static int kfence_suite_init(struct kunit_suite *suite)
 {
-	/*
-	 * Because we want to be able to build the test as a module, we need to
-	 * iterate through all known tracepoints, since the static registration
-	 * won't work here.
-	 */
-	for_each_kernel_tracepoint(register_tracepoints, NULL);
+	register_trace_console(probe_console, NULL);
 	return 0;
 }
 
 static void kfence_suite_exit(struct kunit_suite *suite)
 {
-	for_each_kernel_tracepoint(unregister_tracepoints, NULL);
+	unregister_trace_console(probe_console, NULL);
 	tracepoint_synchronize_unregister();
 }
 
diff --git a/mm/kmsan/kmsan_test.c b/mm/kmsan/kmsan_test.c
index 088e21a48dc4..06e18f76c641 100644
--- a/mm/kmsan/kmsan_test.c
+++ b/mm/kmsan/kmsan_test.c
@@ -541,33 +541,15 @@ static void test_exit(struct kunit *test)
 {
 }
 
-static void register_tracepoints(struct tracepoint *tp, void *ignore)
-{
-	check_trace_callback_type_console(probe_console);
-	if (!strcmp(tp->name, "console"))
-		WARN_ON(tracepoint_probe_register(tp, probe_console, NULL));
-}
-
-static void unregister_tracepoints(struct tracepoint *tp, void *ignore)
-{
-	if (!strcmp(tp->name, "console"))
-		tracepoint_probe_unregister(tp, probe_console, NULL);
-}
-
 static int kmsan_suite_init(struct kunit_suite *suite)
 {
-	/*
-	 * Because we want to be able to build the test as a module, we need to
-	 * iterate through all known tracepoints, since the static registration
-	 * won't work here.
-	 */
-	for_each_kernel_tracepoint(register_tracepoints, NULL);
+	register_trace_console(probe_console, NULL);
 	return 0;
 }
 
 static void kmsan_suite_exit(struct kunit_suite *suite)
 {
-	for_each_kernel_tracepoint(unregister_tracepoints, NULL);
+	unregister_trace_console(probe_console, NULL);
 	tracepoint_synchronize_unregister();
 }
 
-- 
2.25.1



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

* Re: [PATCH] printk: Export console trace point for kcsan/kasan/kfence/kmsan
  2023-04-13 10:08 [PATCH] printk: Export console trace point for kcsan/kasan/kfence/kmsan Pavankumar Kondeti
@ 2023-04-14  8:11 ` Petr Mladek
  2023-04-15  6:58 ` Sergey Senozhatsky
  1 sibling, 0 replies; 4+ messages in thread
From: Petr Mladek @ 2023-04-14  8:11 UTC (permalink / raw)
  To: Pavankumar Kondeti
  Cc: Marco Elver, Dmitry Vyukov, Sergey Senozhatsky, Steven Rostedt,
	John Ogness, Andrey Ryabinin, Alexander Potapenko,
	Andrey Konovalov, Vincenzo Frascino, Andrew Morton, kasan-dev,
	linux-kernel, linux-mm

On Thu 2023-04-13 15:38:59, Pavankumar Kondeti wrote:
> The console tracepoint is used by kcsan/kasan/kfence/kmsan test
> modules. Since this tracepoint is not exported, these modules iterate
> over all available tracepoints to find the console trace point.
> Export the trace point so that it can be directly used.
> 
> Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>

Makes sense. From the printk side:

Acked-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr


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

* Re: [PATCH] printk: Export console trace point for kcsan/kasan/kfence/kmsan
  2023-04-13 10:08 [PATCH] printk: Export console trace point for kcsan/kasan/kfence/kmsan Pavankumar Kondeti
  2023-04-14  8:11 ` Petr Mladek
@ 2023-04-15  6:58 ` Sergey Senozhatsky
  2023-04-17 12:25   ` Alexander Potapenko
  1 sibling, 1 reply; 4+ messages in thread
From: Sergey Senozhatsky @ 2023-04-15  6:58 UTC (permalink / raw)
  To: Pavankumar Kondeti
  Cc: Marco Elver, Dmitry Vyukov, Petr Mladek, Sergey Senozhatsky,
	Steven Rostedt, John Ogness, Andrey Ryabinin,
	Alexander Potapenko, Andrey Konovalov, Vincenzo Frascino,
	Andrew Morton, kasan-dev, linux-kernel, linux-mm

On (23/04/13 15:38), Pavankumar Kondeti wrote:
> The console tracepoint is used by kcsan/kasan/kfence/kmsan test
> modules. Since this tracepoint is not exported, these modules iterate
> over all available tracepoints to find the console trace point.
> Export the trace point so that it can be directly used.
> 
> Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>

Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> # printk


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

* Re: [PATCH] printk: Export console trace point for kcsan/kasan/kfence/kmsan
  2023-04-15  6:58 ` Sergey Senozhatsky
@ 2023-04-17 12:25   ` Alexander Potapenko
  0 siblings, 0 replies; 4+ messages in thread
From: Alexander Potapenko @ 2023-04-17 12:25 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: Pavankumar Kondeti, Marco Elver, Dmitry Vyukov, Petr Mladek,
	Steven Rostedt, John Ogness, Andrey Ryabinin, Andrey Konovalov,
	Vincenzo Frascino, Andrew Morton, kasan-dev, linux-kernel,
	linux-mm

On Sat, Apr 15, 2023 at 8:58 AM Sergey Senozhatsky
<senozhatsky@chromium.org> wrote:
>
> On (23/04/13 15:38), Pavankumar Kondeti wrote:
> > The console tracepoint is used by kcsan/kasan/kfence/kmsan test
> > modules. Since this tracepoint is not exported, these modules iterate
> > over all available tracepoints to find the console trace point.
> > Export the trace point so that it can be directly used.
> >
> > Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
>
> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> # printk
Reviewed-by: Alexander Potapenko <glider@google.com>


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

end of thread, other threads:[~2023-04-17 12:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13 10:08 [PATCH] printk: Export console trace point for kcsan/kasan/kfence/kmsan Pavankumar Kondeti
2023-04-14  8:11 ` Petr Mladek
2023-04-15  6:58 ` Sergey Senozhatsky
2023-04-17 12:25   ` Alexander Potapenko

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