[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190719024242.249429-2-alex.shi@linux.alibaba.com>
Date: Fri, 19 Jul 2019 10:42:42 +0800
From: Alex Shi <alex.shi@...ux.alibaba.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Alex Shi <alex.shi@...ux.alibaba.com>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Frederic Weisbecker <fweisbec@...il.com>,
Wanpeng Li <wanpeng.li@...mail.com>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org
Subject: [PATCH v2 2/2] cputime: remove duplicate code in account_process_tick
The irqtime_account_process_tick path was introduced for precise ns irq
time account from commit abb74cefa9c682fb (sched: Export ns irqtimes through
/proc/stat) while account_process_tick still use jiffes. This divide
isn't neccessary especially now both pathes are ns precison.
Move out the irqtime_account_process_tick func from IRQ_TIME_ACCOUNTING.
So it do generally same things as account_process_tick whenever if
IRQ_TIME_ACCOUNTING set or if sched_clock_irqtime enabled.
Signed-off-by: Alex Shi <alex.shi@...ux.alibaba.com>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Wanpeng Li <wanpeng.li@...mail.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: linux-kernel@...r.kernel.org
---
kernel/sched/cputime.c | 26 ++------------------------
1 file changed, 2 insertions(+), 24 deletions(-)
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 3aaf761ede81..6116f50e1f37 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -332,7 +332,6 @@ void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times)
rcu_read_unlock();
}
-#ifdef CONFIG_IRQ_TIME_ACCOUNTING
/*
* Account a tick to a process and cpustat
* @p: the process that the CPU time gets accounted to
@@ -390,14 +389,13 @@ static void irqtime_account_process_tick(struct task_struct *p, int user_tick,
}
}
+#ifdef CONFIG_IRQ_TIME_ACCOUNTING
static void irqtime_account_idle_ticks(int ticks)
{
irqtime_account_process_tick(current, 0, ticks);
}
#else /* CONFIG_IRQ_TIME_ACCOUNTING */
static inline void irqtime_account_idle_ticks(int ticks) { }
-static inline void irqtime_account_process_tick(struct task_struct *p, int user_tick,
- int nr_ticks) { }
#endif /* CONFIG_IRQ_TIME_ACCOUNTING */
/*
@@ -472,30 +470,10 @@ void thread_group_cputime_adjusted(struct task_struct *p, u64 *ut, u64 *st)
*/
void account_process_tick(struct task_struct *p, int user_tick)
{
- u64 cputime, steal;
-
if (vtime_accounting_cpu_enabled())
return;
- if (sched_clock_irqtime) {
- irqtime_account_process_tick(p, user_tick, 1);
- return;
- }
-
- cputime = TICK_NSEC;
- steal = steal_account_process_time(ULONG_MAX);
-
- if (steal >= cputime)
- return;
-
- cputime -= steal;
-
- if (user_tick)
- account_user_time(p, cputime);
- else if ((p != this_rq()->idle) || (irq_count() != HARDIRQ_OFFSET))
- account_system_time(p, HARDIRQ_OFFSET, cputime);
- else
- account_idle_time(cputime);
+ irqtime_account_process_tick(p, user_tick, 1);
}
/*
--
2.19.1.856.g8858448bb
Powered by blists - more mailing lists