Skip to content

Commit 1d21376

Browse files
committed
Merge tag 'sched_urgent_for_v5.16_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler fixes from Borislav Petkov: - Properly init uclamp_flags of a runqueue, on first enqueuing - Fix preempt= callback return values - Correct utime/stime resource usage reporting on nohz_full to return the proper times instead of shorter ones * tag 'sched_urgent_for_v5.16_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: sched/uclamp: Fix rq->uclamp_max not set on first enqueue preempt/dynamic: Fix setup_preempt_mode() return value sched/cputime: Fix getrusage(RUSAGE_THREAD) with nohz_full
2 parents f5d54a4 + 315c4f8 commit 1d21376

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

include/linux/sched/cputime.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@
1818
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
1919

2020
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
21-
extern void task_cputime(struct task_struct *t,
21+
extern bool task_cputime(struct task_struct *t,
2222
u64 *utime, u64 *stime);
2323
extern u64 task_gtime(struct task_struct *t);
2424
#else
25-
static inline void task_cputime(struct task_struct *t,
25+
static inline bool task_cputime(struct task_struct *t,
2626
u64 *utime, u64 *stime)
2727
{
2828
*utime = t->utime;
2929
*stime = t->stime;
30+
return false;
3031
}
3132

3233
static inline u64 task_gtime(struct task_struct *t)

kernel/sched/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,7 @@ static void __init init_uclamp_rq(struct rq *rq)
19181918
};
19191919
}
19201920

1921-
rq->uclamp_flags = 0;
1921+
rq->uclamp_flags = UCLAMP_FLAG_IDLE;
19221922
}
19231923

19241924
static void __init init_uclamp(void)
@@ -6617,11 +6617,11 @@ static int __init setup_preempt_mode(char *str)
66176617
int mode = sched_dynamic_mode(str);
66186618
if (mode < 0) {
66196619
pr_warn("Dynamic Preempt: unsupported mode: %s\n", str);
6620-
return 1;
6620+
return 0;
66216621
}
66226622

66236623
sched_dynamic_update(mode);
6624-
return 0;
6624+
return 1;
66256625
}
66266626
__setup("preempt=", setup_preempt_mode);
66276627

kernel/sched/cputime.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,8 @@ void task_cputime_adjusted(struct task_struct *p, u64 *ut, u64 *st)
615615
.sum_exec_runtime = p->se.sum_exec_runtime,
616616
};
617617

618-
task_cputime(p, &cputime.utime, &cputime.stime);
618+
if (task_cputime(p, &cputime.utime, &cputime.stime))
619+
cputime.sum_exec_runtime = task_sched_runtime(p);
619620
cputime_adjust(&cputime, &p->prev_cputime, ut, st);
620621
}
621622
EXPORT_SYMBOL_GPL(task_cputime_adjusted);
@@ -828,19 +829,21 @@ u64 task_gtime(struct task_struct *t)
828829
* add up the pending nohz execution time since the last
829830
* cputime snapshot.
830831
*/
831-
void task_cputime(struct task_struct *t, u64 *utime, u64 *stime)
832+
bool task_cputime(struct task_struct *t, u64 *utime, u64 *stime)
832833
{
833834
struct vtime *vtime = &t->vtime;
834835
unsigned int seq;
835836
u64 delta;
837+
int ret;
836838

837839
if (!vtime_accounting_enabled()) {
838840
*utime = t->utime;
839841
*stime = t->stime;
840-
return;
842+
return false;
841843
}
842844

843845
do {
846+
ret = false;
844847
seq = read_seqcount_begin(&vtime->seqcount);
845848

846849
*utime = t->utime;
@@ -850,6 +853,7 @@ void task_cputime(struct task_struct *t, u64 *utime, u64 *stime)
850853
if (vtime->state < VTIME_SYS)
851854
continue;
852855

856+
ret = true;
853857
delta = vtime_delta(vtime);
854858

855859
/*
@@ -861,6 +865,8 @@ void task_cputime(struct task_struct *t, u64 *utime, u64 *stime)
861865
else
862866
*utime += vtime->utime + delta;
863867
} while (read_seqcount_retry(&vtime->seqcount, seq));
868+
869+
return ret;
864870
}
865871

866872
static int vtime_state_fetch(struct vtime *vtime, int cpu)

0 commit comments

Comments
 (0)