Skip to content

Commit

Permalink
sched/cputime: move rq parameter in irqtime_account_process_tick
Browse files Browse the repository at this point in the history
Every time we call irqtime_account_process_tick() is in a interrupt,
Every caller will get and assign a parameter rq = this_rq(), This is
unnecessary and increase the code size a little bit. Move the rq getting
action to irqtime_account_process_tick internally is better.

             base               with this patch
cputime.o    578792 bytes        577888 bytes

Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/1577959674-255537-1-git-send-email-alex.shi@linux.alibaba.com
  • Loading branch information
Alex Shi authored and Peter Zijlstra committed Jan 17, 2020
1 parent 35f4cd9 commit 9dec1b6
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions kernel/sched/cputime.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times)
* 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,
struct rq *rq, int ticks)
int ticks)
{
u64 other, cputime = TICK_NSEC * ticks;

Expand All @@ -381,7 +381,7 @@ static void irqtime_account_process_tick(struct task_struct *p, int user_tick,
account_system_index_time(p, cputime, CPUTIME_SOFTIRQ);
} else if (user_tick) {
account_user_time(p, cputime);
} else if (p == rq->idle) {
} else if (p == this_rq()->idle) {
account_idle_time(cputime);
} else if (p->flags & PF_VCPU) { /* System time or guest time */
account_guest_time(p, cputime);
Expand All @@ -392,14 +392,12 @@ 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();

irqtime_account_process_tick(current, 0, rq, 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,
struct rq *rq, int nr_ticks) { }
int nr_ticks) { }
#endif /* CONFIG_IRQ_TIME_ACCOUNTING */

/*
Expand Down Expand Up @@ -473,13 +471,12 @@ 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;
struct rq *rq = this_rq();

if (vtime_accounting_enabled_this_cpu())
return;

if (sched_clock_irqtime) {
irqtime_account_process_tick(p, user_tick, rq, 1);
irqtime_account_process_tick(p, user_tick, 1);
return;
}

Expand All @@ -493,7 +490,7 @@ void account_process_tick(struct task_struct *p, int user_tick)

if (user_tick)
account_user_time(p, cputime);
else if ((p != rq->idle) || (irq_count() != HARDIRQ_OFFSET))
else if ((p != this_rq()->idle) || (irq_count() != HARDIRQ_OFFSET))
account_system_time(p, HARDIRQ_OFFSET, cputime);
else
account_idle_time(cputime);
Expand Down

0 comments on commit 9dec1b6

Please sign in to comment.