Skip to content

Commit

Permalink
kernel/latencytop.c: remove unnecessary checks for latencytop_enabled
Browse files Browse the repository at this point in the history
1. In latencytop source codes, we only have such calling chain:

account_scheduler_latency(struct task_struct *task, int usecs, int inter)
{
        if (unlikely(latencytop_enabled)) /* the outtermost check */
                __account_scheduler_latency(task, usecs, inter);
}
__account_scheduler_latency
    account_global_scheduler_latency
        if (!latencytop_enabled)

So, the inner check for latencytop_enabled is not necessary at all.

2. In clear_all_latency_tracing and now is called
   clear_tsk_latency_tracing the check for latencytop_enabled is redundant
   and buggy to some extent.

   We have no reason to refuse clearing the /proc/$pid/latency if
   latencytop_enabled is set to 0, considering that if we use latencytop
   manually by echo 0 > /proc/sys/kernel/latencytop, then we want to clear
   /proc/$pid/latency and failed.

   Also we don't have such check in brother function
   clear_global_latency_tracing.

Notes: These changes are only visible to users who set
   CONFIG_LATENCYTOP and won't change user tool latencytop's behavior.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Lin Feng <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Fabian Frederick <[email protected]>
Cc: Arjan van de Ven <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
linfeng2999 authored and torvalds committed May 15, 2019
1 parent 8312465 commit 0cc7588
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions kernel/latencytop.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ void clear_all_latency_tracing(struct task_struct *p)
{
unsigned long flags;

if (!latencytop_enabled)
return;

raw_spin_lock_irqsave(&latency_lock, flags);
memset(&p->latency_record, 0, sizeof(p->latency_record));
p->latency_record_count = 0;
Expand All @@ -96,9 +93,6 @@ account_global_scheduler_latency(struct task_struct *tsk,
int firstnonnull = MAXLR + 1;
int i;

if (!latencytop_enabled)
return;

/* skip kernel threads for now */
if (!tsk->mm)
return;
Expand Down

0 comments on commit 0cc7588

Please sign in to comment.