android_kernel_samsung_a7y1.../kernel/sched
Xuewei Zhang a04e40f2c4 sched/fair: Scale bandwidth quota and period without losing quota/period ratio precision
commit 4929a4e6faa0f13289a67cae98139e727f0d4a97 upstream.

The quota/period ratio is used to ensure a child task group won't get
more bandwidth than the parent task group, and is calculated as:

  normalized_cfs_quota() = [(quota_us << 20) / period_us]

If the quota/period ratio was changed during this scaling due to
precision loss, it will cause inconsistency between parent and child
task groups.

See below example:

A userspace container manager (kubelet) does three operations:

 1) Create a parent cgroup, set quota to 1,000us and period to 10,000us.
 2) Create a few children cgroups.
 3) Set quota to 1,000us and period to 10,000us on a child cgroup.

These operations are expected to succeed. However, if the scaling of
147/128 happens before step 3, quota and period of the parent cgroup
will be changed:

  new_quota: 1148437ns,   1148us
 new_period: 11484375ns, 11484us

And when step 3 comes in, the ratio of the child cgroup will be
104857, which will be larger than the parent cgroup ratio (104821),
and will fail.

Scaling them by a factor of 2 will fix the problem.

Tested-by: Phil Auld <pauld@redhat.com>
Signed-off-by: Xuewei Zhang <xueweiz@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Phil Auld <pauld@redhat.com>
Cc: Anton Blanchard <anton@ozlabs.org>
Cc: Ben Segall <bsegall@google.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Fixes: 2e8e19226398 ("sched/fair: Limit sched_cfs_period_timer() loop to avoid hard lockup")
Link: https://lkml.kernel.org/r/20191004001243.140897-1-xueweiz@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-07 12:45:36 +02:00
..
auto_group.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
auto_group.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
clock.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
completion.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
core.c sched/core: Fix CPU controller for !RT_GROUP_SCHED 2020-04-07 07:37:59 +02:00
cpuacct.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cpuacct.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cpudeadline.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cpudeadline.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cpufreq_schedutil.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cpufreq.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cpupri.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cpupri.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cputime.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
deadline.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
debug.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
energy.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
fair.c sched/fair: Scale bandwidth quota and period without losing quota/period ratio precision 2020-04-07 12:45:36 +02:00
features.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
idle_task.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
idle.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
loadavg.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Makefile A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
rt.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sched.h sched: Add sched_smt_active() 2020-04-06 16:51:01 +02:00
stats.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
stats.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
stop_task.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tune.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tune.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
wait.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
walt.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
walt.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30