scheduler fixes
Linus,
Please pull the latest sched-urgent-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched-urgent-for-linus
# HEAD: 68e7a4d66b0ce04bf18ff2ffded5596ab3618585 sched/vtime: Fix guest/system mis-accounting on task switch
Two fixes: a guest-cputime accounting fix, and a cgroup bandwidth quota precision fix.
Thanks,
Ingo
------------------>
Frederic Weisbecker (1):
sched/vtime: Fix guest/system mis-accounting on task switch
Xuewei Zhang (1):
sched/fair: Scale bandwidth quota and period without losing quota/period ratio precision
kernel/sched/cputime.c | 6 +++--- kernel/sched/fair.c | 36 ++++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 17 deletions(-)
kernel/sched/cputime.c +3 -3
@@ -740,7 +740,7 @@ void vtime_account_system(struct task_struct *tsk)write_seqcount_begin (&vtime->seqcount);/* We might have scheduled out from guest path */ -if (current->flags &PF_VCPU ) +if (tsk->flags &PF_VCPU )vtime_account_guest (tsk, vtime);else __vtime_account_system (tsk, vtime);
@@ -783,7 +783,7 @@ void vtime_guest_enter(struct task_struct *tsk)*/ write_seqcount_begin (&vtime->seqcount);__vtime_account_system (tsk, vtime); - current->flags |=PF_VCPU ; + tsk->flags |=PF_VCPU ;write_seqcount_end (&vtime->seqcount); }EXPORT_SYMBOL_GPL (vtime_guest_enter);
@@ -794,7 +794,7 @@ void vtime_guest_exit(struct task_struct *tsk)write_seqcount_begin (&vtime->seqcount);vtime_account_guest (tsk, vtime); - current->flags &= ~PF_VCPU ; + tsk->flags &= ~PF_VCPU ;write_seqcount_end (&vtime->seqcount); }EXPORT_SYMBOL_GPL (vtime_guest_exit);
kernel/sched/fair.c +22 -14
@@ -4926,20 +4926,28 @@ static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer)if (++count >3 ) {u64 new, old =ktime_to_ns (cfs_b->period); - new = (old *147 ) /128 ;/* ~115% */ - new =min (new, max_cfs_quota_period); - - cfs_b->period =ns_to_ktime (new); - -/* since max is 1s, this is limited to 1e9^2, which fits in u64 */ - cfs_b->quota *= new; - cfs_b->quota =div64_u64 (cfs_b->quota, old); - -pr_warn_ratelimited ( -"cfs_period_timer[cpu%d]: period too short, scaling up (new cfs_period_us %lld, cfs_quota_us = %lld)\n" , -smp_processor_id (), -div_u64 (new,NSEC_PER_USEC ), -div_u64 (cfs_b->quota,NSEC_PER_USEC )); +/* +* Grow period by a factor of 2 to avoid losing precision. +* Precision loss in the quota/period ratio can cause __cfs_schedulable +* to fail. +*/ + new = old *2 ; +if (new < max_cfs_quota_period) { + cfs_b->period =ns_to_ktime (new); + cfs_b->quota *=2 ; + +pr_warn_ratelimited ( +"cfs_period_timer[cpu%d]: period too short, scaling up (new cfs_period_us = %lld, cfs_quota_us = %lld)\n" , +smp_processor_id (), +div_u64 (new,NSEC_PER_USEC ), +div_u64 (cfs_b->quota,NSEC_PER_USEC )); + }else { +pr_warn_ratelimited ( +"cfs_period_timer[cpu%d]: period too short, but cannot scale up without losing precision (cfs_period_us = %lld, cfs_quota_us = %lld)\n" , +smp_processor_id (), +div_u64 (old,NSEC_PER_USEC ), +div_u64 (cfs_b->quota,NSEC_PER_USEC )); + }/* reset count so we don't come right back in here */ count =0 ;
The pull request you sent on Sat, 12 Oct 2019 16:58:36 +0200:
The pull request you sent on Sat, 12 Oct 2019 16:58:36 +0200:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitsched-urgent-for-linus
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/328fefadd9cfa15cd6ab746553d9ef13303c11a6
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker