From: johnnyaiai <[email protected]>
clear_tsk_latency_tracing will called wheather latencytop_enabled
set or not. this bring unnecessary overhead.
Signed-off-by: johnnyaiai <[email protected]>
---
kernel/latencytop.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/kernel/latencytop.c b/kernel/latencytop.c
index e3acead00..daa65b313 100644
--- a/kernel/latencytop.c
+++ b/kernel/latencytop.c
@@ -63,14 +63,15 @@ static struct latency_record latency_record[MAXLR];
int latencytop_enabled;
-void clear_tsk_latency_tracing(struct task_struct *p)
+static void _clear_tsk_latency_tracing(struct task_struct *p)
{
- unsigned long flags;
-
- raw_spin_lock_irqsave(&latency_lock, flags);
memset(&p->latency_record, 0, sizeof(p->latency_record));
p->latency_record_count = 0;
- raw_spin_unlock_irqrestore(&latency_lock, flags);
+}
+
+void clear_tsk_latency_tracing(struct task_struct *p)
+{
+ p->latency_record_count = LT_SAVECOUNT + 1;
}
static void clear_global_latency_tracing(void)
@@ -172,6 +173,9 @@ __account_scheduler_latency(struct task_struct *tsk, int usecs, int inter)
raw_spin_lock_irqsave(&latency_lock, flags);
+ if (unlikely(tsk->latency_record_count == (LT_SAVECOUNT + 1)))
+ _clear_tsk_latency_tracing(tsk);
+
account_global_scheduler_latency(tsk, &lat);
for (i = 0; i < tsk->latency_record_count; i++) {
--
2.27.0