Skip to content

Commit d315685

Browse files
Prakash Sangappajfvogel
authored andcommitted
Sched: Add scheduler stat for cpu time slice extension
Add scheduler stat to record number of times the thread was granted cpu time slice extension. Orabug: 37583007 Signed-off-by: Prakash Sangappa <[email protected]> Reviewed-by: Chris Hyser <[email protected]>
1 parent 4203ff4 commit d315685

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

include/linux/sched.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ extern void io_schedule_finish(int token);
328328
extern long io_schedule_timeout(long timeout);
329329
extern void io_schedule(void);
330330
extern void hrtick_local_start(u64 delay);
331+
extern void update_stat_preempt_delayed(struct task_struct *t);
331332

332333
/**
333334
* struct prev_cputime - snapshot of system and user cputime
@@ -533,6 +534,7 @@ struct sched_statistics {
533534
u64 nr_wakeups_affine_attempts;
534535
u64 nr_wakeups_passive;
535536
u64 nr_wakeups_idle;
537+
u64 nr_preempt_delay_granted;
536538

537539
#ifdef CONFIG_SCHED_CORE
538540
u64 core_forceidle_sum;

kernel/rseq.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ bool rseq_delay_resched(void)
364364
return false;
365365

366366
t->rseq_sched_delay = 1;
367+
update_stat_preempt_delayed(t);
367368

368369
return true;
369370
}

kernel/sched/core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,11 @@ void hrtick_local_start(u64 delay)
918918
rq_unlock(rq, &rf);
919919
}
920920

921+
void update_stat_preempt_delayed(struct task_struct *t)
922+
{
923+
schedstat_inc(t->stats.nr_preempt_delay_granted);
924+
}
925+
921926
static void hrtick_rq_init(struct rq *rq)
922927
{
923928
#ifdef CONFIG_SMP

kernel/sched/debug.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,7 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
12161216
P_SCHEDSTAT(nr_wakeups_affine_attempts);
12171217
P_SCHEDSTAT(nr_wakeups_passive);
12181218
P_SCHEDSTAT(nr_wakeups_idle);
1219+
P_SCHEDSTAT(nr_preempt_delay_granted);
12191220

12201221
avg_atom = p->se.sum_exec_runtime;
12211222
if (nr_switches)

0 commit comments

Comments
 (0)