From: Rik van Riel <[email protected]>

Add a cpu parameter to irqtime_account_process_tick, to specify what
cpu to run the statistics for.

In order for this to actually work on a different cpu, all the functions
called by irqtime_account_process_tick need to be able to handle workng
for another CPU.

Signed-off-by: Rik van Riel <[email protected]>
---
 kernel/sched/cputime.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 84b2d24a2238..7df761cd6dfc 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -336,12 +336,14 @@ void thread_group_cputime(struct task_struct *tsk, struct 
task_cputime *times)
  * p->stime and friends are only updated on system time and not on irq
  * softirq as those do not count in task exec_runtime any more.
  */
-static void irqtime_account_process_tick(struct task_struct *p, int user_tick,
+static void irqtime_account_process_tick(struct task_struct *p, int cpu,
+                                        int user_tick,
                                         struct rq *rq, int ticks)
 {
        cputime_t scaled = cputime_to_scaled(cputime_one_jiffy);
+       struct kernel_cpustat *kstat = &kcpustat_cpu(cpu);
        u64 cputime = (__force u64) cputime_one_jiffy;
-       u64 *cpustat = kcpustat_this_cpu->cpustat;
+       u64 *cpustat = kstat->cpustat;
 
        if (steal_account_process_tick())
                return;
@@ -374,12 +376,14 @@ static void irqtime_account_process_tick(struct 
task_struct *p, int user_tick,
 static void irqtime_account_idle_ticks(int ticks)
 {
        struct rq *rq = this_rq();
+       int cpu = smp_processor_id();
 
-       irqtime_account_process_tick(current, 0, rq, ticks);
+       irqtime_account_process_tick(current, cpu, 0, rq, 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,
+static inline void irqtime_account_process_tick(struct task_struct *p, int cpu,
+                                               int user_tick,
                                                struct rq *rq, int nr_ticks) {}
 #endif /* CONFIG_IRQ_TIME_ACCOUNTING */
 
@@ -475,7 +479,7 @@ void account_process_tick(struct task_struct *p, int 
user_tick)
                return;
 
        if (sched_clock_irqtime) {
-               irqtime_account_process_tick(p, user_tick, rq, 1);
+               irqtime_account_process_tick(p, cpu, user_tick, rq, 1);
                return;
        }
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to