kernel/latencytop.c: rename clear_all_latency_tracing to clear_tsk_latency_tracing
Subsystems (4)
PATCH 1/2 kernel/latencytop.c: rename clear_all_latency_tracing to clear_tsk_latency_tracing
The name clear_all_latency_tracing is misleading, in fact which only clear per task's latency_record[], and we do have another function named clear_global_latency_tracing which clear the global latency_record[] buffer.
--- fs/proc/base.c | 2 +- include/linux/latencytop.h | 4 ++-- kernel/fork.c | 2 +- kernel/latencytop.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
fs/proc/base.c +1 -1
@@ -511,7 +511,7 @@ static ssize_t lstats_write(struct file *file, const char __user *buf,if (!task)return -ESRCH ; -clear_all_latency_tracing (task); +clear_tsk_latency_tracing (task);put_task_struct (task);return count;
include/linux/latencytop.h +2 -2
@@ -36,7 +36,7 @@ account_scheduler_latency(struct task_struct *task, int usecs, int inter)__account_scheduler_latency (task, usecs, inter); } -void clear_all_latency_tracing (struct task_struct *p); +void clear_tsk_latency_tracing (struct task_struct *p);extern int sysctl_latencytop (struct ctl_table *table,int write,void __user *buffer,size_t *lenp,loff_t *ppos);
@@ -48,7 +48,7 @@ account_scheduler_latency(struct task_struct *task, int usecs, int inter) { } -static inline void clear_all_latency_tracing (struct task_struct *p) +static inline void clear_tsk_latency_tracing (struct task_struct *p) { }
kernel/fork.c +1 -1
@@ -1963,7 +1963,7 @@ static __latent_entropy struct task_struct *copy_process(#ifdef TIF_SYSCALL_EMU clear_tsk_thread_flag (p,TIF_SYSCALL_EMU );#endif -clear_all_latency_tracing (p); +clear_tsk_latency_tracing (p);/* ok, now we should be set up.. */ p->pid =pid_nr (pid);
kernel/latencytop.c +1 -1
@@ -67,7 +67,7 @@ static struct latency_record latency_record[MAXLR];int latencytop_enabled; -void clear_all_latency_tracing (struct task_struct *p) +void clear_tsk_latency_tracing (struct task_struct *p) {unsigned long flags;
Signature · 1 line
2.20.1
PATCH 2/2 kernel/latencytop.c: remove unnecessary checks for latencytop_enabled
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.
Aslo we don't have such check in brother function clear_global_latency_tracing.
Notes: These changes only visible to users who sets CONFIG_LATENCYTOP and won't change user tool latencytop's behaviors.
--- kernel/latencytop.c | 6 ------ 1 file changed, 6 deletions(-)
kernel/latencytop.c +0 -6
@@ -71,9 +71,6 @@ void clear_tsk_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 ;
@@ -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 ;
Signature · 1 line
2.20.1