Skip to content

Commit aa892f8

Browse files
Daniel Bristot de Oliveirarostedt
authored andcommitted
trace/hwlat: Remove printk from sampling loop
hwlat has some time operation checks on the sample loop, and it is currently using pr_err (printk) to report them. The problem is that this can lead the system to an unresponsible state due to an overflow of printk messages. This problem can be mitigated by writing the error message to the trace buffer. Remove the printk messages from the sampling loop, switching the to messages in the trace buffer. No functional change. Link: https://lkml.kernel.org/r/9d77c34869748aa105e965c769d24642914eea3a.1624372313.git.bristot@redhat.com Cc: Phil Auld <pauld@redhat.com> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Kate Carcia <kcarcia@redhat.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Ingo Molnar <mingo@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Alexandre Chartre <alexandre.chartre@oracle.com> Cc: Clark Willaims <williams@redhat.com> Cc: John Kacur <jkacur@redhat.com> Cc: Juri Lelli <juri.lelli@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: x86@kernel.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent f27a1c9 commit aa892f8

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

kernel/trace/trace_hwlat.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,15 @@ void trace_hwlat_callback(bool enter)
182182
kdata->nmi_count++;
183183
}
184184

185+
/*
186+
* hwlat_err - report a hwlat error.
187+
*/
188+
#define hwlat_err(msg) ({ \
189+
struct trace_array *tr = hwlat_trace; \
190+
\
191+
trace_array_printk_buf(tr->array_buffer.buffer, _THIS_IP_, msg); \
192+
})
193+
185194
/**
186195
* get_sample - sample the CPU TSC and look for likely hardware latencies
187196
*
@@ -225,7 +234,7 @@ static int get_sample(void)
225234
outer_diff = time_to_us(time_sub(t1, last_t2));
226235
/* This shouldn't happen */
227236
if (outer_diff < 0) {
228-
pr_err(BANNER "time running backwards\n");
237+
hwlat_err(BANNER "time running backwards\n");
229238
goto out;
230239
}
231240
if (outer_diff > outer_sample)
@@ -237,7 +246,7 @@ static int get_sample(void)
237246

238247
/* Check for possible overflows */
239248
if (total < last_total) {
240-
pr_err("Time total overflowed\n");
249+
hwlat_err("Time total overflowed\n");
241250
break;
242251
}
243252
last_total = total;
@@ -253,7 +262,7 @@ static int get_sample(void)
253262

254263
/* This shouldn't happen */
255264
if (diff < 0) {
256-
pr_err(BANNER "time running backwards\n");
265+
hwlat_err(BANNER "time running backwards\n");
257266
goto out;
258267
}
259268

0 commit comments

Comments
 (0)