linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tracing/timerlat: Move hrtimer_init to timerlat_fd open()
@ 2024-02-01 15:13 Daniel Bristot de Oliveira
  2024-02-01 15:25 ` Steven Rostedt
  2024-02-01 15:44 ` Greg KH
  0 siblings, 2 replies; 10+ messages in thread
From: Daniel Bristot de Oliveira @ 2024-02-01 15:13 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Daniel Bristot de Oliveira, Masami Hiramatsu, Mathieu Desnoyers,
	linux-kernel, linux-trace-kernel, stable

Currently, the timerlat's hrtimer is initialized at the first read of
timerlat_fd, and destroyed at close(). It works, but it causes an error
if the user program open() and close() the file without reading.

Move hrtimer_init to timerlat_fd open() to avoid this problem.

No functional changes.

Fixes: e88ed227f639 ("tracing/timerlat: Add user-space interface")
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
---
 kernel/trace/trace_osnoise.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index bd0d01d00fb9..a8e28f9b9271 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -2444,6 +2444,9 @@ static int timerlat_fd_open(struct inode *inode, struct file *file)
 	tlat = this_cpu_tmr_var();
 	tlat->count = 0;
 
+	hrtimer_init(&tlat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
+	tlat->timer.function = timerlat_irq;
+
 	migrate_enable();
 	return 0;
 };
@@ -2526,9 +2529,6 @@ timerlat_fd_read(struct file *file, char __user *ubuf, size_t count,
 		tlat->tracing_thread = false;
 		tlat->kthread = current;
 
-		hrtimer_init(&tlat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
-		tlat->timer.function = timerlat_irq;
-
 		/* Annotate now to drift new period */
 		tlat->abs_period = hrtimer_cb_get_time(&tlat->timer);
 
-- 
2.43.0


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

end of thread, other threads:[~2024-02-01 18:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-01 15:13 [PATCH] tracing/timerlat: Move hrtimer_init to timerlat_fd open() Daniel Bristot de Oliveira
2024-02-01 15:25 ` Steven Rostedt
2024-02-01 15:27   ` Daniel Bristot de Oliveira
2024-02-01 15:44 ` Greg KH
2024-02-01 16:02   ` Daniel Bristot de Oliveira
2024-02-01 16:10     ` Steven Rostedt
2024-02-01 18:05     ` Greg KH
2024-02-01 18:08       ` Steven Rostedt
2024-02-01 18:12         ` Greg KH
2024-02-01 18:24           ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).