Commit Graph

37 Commits

Author SHA1 Message Date
yongduan 33347536c7 backport wake affine upstream optimization
[upstream]
7332dec0 sched/fair: Only immediately migrate tasks due to interrupts
         if prev and target CPUs share cache
806486c3 sched/fair: Do not migrate if the prev_cpu is idle
082f764a sched/fair: Do not migrate on wake_affine_weight() if weights
         are equal
d8fcb81f sched/fair: Check for idle core in wake_affine

Signed-off-by: yongduan <yongduan@tencent.com>
2021-03-17 08:58:32 +00:00
He Chen 94dd9ddb7e sched: fix offline task inheritance issue
Signed-off-by: heddchen <heddchen@tencent.com>
2020-11-10 17:47:17 +08:00
Chen Xiaoguang 71b4de4965 sched: get rq->lock before changing cpu limit of offline task
Signed-off-by: Xiaoguang Chen <xiaoggchen@tencent.com>
Signed-off-by: He Chen <xiaoggchen@tencent.com>
2020-09-22 11:13:54 +08:00
Xiaoming Gao b6b1feb590 sched: fix build error when CONFIG_BT_GROUP_SCHED disabled
Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
2020-09-14 16:58:39 +08:00
He Chen a6fc45b598 sched: remove bt_rq->nr_running check during pick_next_task_bt
Signed-off-by: He Chen <heddchen@tencent.com>
2020-09-14 16:05:49 +08:00
He Chen 46dedbcaa0 sched: sync child based on tg->offline after fork
Signed-off-by: Xiaoguang Chen <xiaoggchen@tencent.com>
Signed-off-by: Zhiguang Peng <zgpeng@tencent.com>
Signed-off-by: He Chen <heddchen@tencent.com>
2020-09-14 16:05:46 +08:00
Liu Hua 0b99e69c14 sched: fix bug of cpuquota_aware 2020-09-07 14:47:42 +08:00
zgpeng 780a9d604f sched/bt: fix some bugs affecting online business or print exception stack
Signed-off-by: Zhiguang Peng <zgpeng@tencent.com>
2020-07-31 14:28:01 +08:00
He Chen eb1171cd04 sched/bt: pick_next_task should check BT task before idle
Signed-off-by: He Chen <heddchen@tencent.com>
2020-07-29 17:35:20 +08:00
zgpeng fb184d8f68 sched/bt: fix bug of CPU offline when offline_group enabled
Signed-off-by: shookliu <shookliu@tencent.com>
Signed-off-by: Zhiguang Peng <zgpeng@tencent.com>
2020-07-19 17:09:58 +08:00
He Chen dab68d6203 sched: CFS per-task load should not include BT tasks
Signed-off-by: He Chen <heddchen@tencent.com>
2020-07-17 19:26:01 +08:00
He Chen 62497311e4 sched: fix optimization for cfs in pick_next_task
When there is BT task, the optimization for cfs in pick_next_task should
take BT tasks into account.

Signed-off-by: He Chen <heddchen@tencent.com>
2020-07-17 19:25:59 +08:00
Liu Hua 6d0d1ff068 sched: /proc/cpuinfo in docker base on cpu quota
Signed-off-by: Liu Hua <shookliu@tencent.com>
2020-07-16 14:59:05 +08:00
Liu Hua 1fe0578c20 cgroup: add switch for subsystem stats isolated
Statictics of memcg, cpuset, cpuacct and blkio export by /proc/
 when switch enabled.

Signed-off-by: Liu Hua <shookliu@tencent.com>
2020-07-16 14:52:41 +08:00
chen xiaoguang e59390ab76 Revert "sched/BT: add RDT support for BT scheduler class"
This reverts commit a2119393bd.

Signed-off-by: Xiaoguang Chen <xiaoggchen@tencent.com>
2020-07-16 12:41:34 +08:00
He Chen 52dc17e488 sched/bt: BT bandwidth control depends on CONFIG_BT_GROUP_SCHED
Signed-off-by: He Chen <heddchen@tencent.com>
2020-07-16 10:42:01 +08:00
He Chen ec1f174cad sched/bt: fix conditional compilation macro for BT code
Signed-off-by: He Chen <heddchen@tencent.com>
2020-07-16 10:41:59 +08:00
He Chen 21515f0164 sched/bt: fix BT ignore binding error in __migrate_task
Signed-off-by: He Chen <heddchen@tencent.com>
2020-07-16 10:41:58 +08:00
He Chen 7d59fe3c11 sched/bt: do not execute BT load balance when BT is disabled
Signed-off-by: Zhiguang Peng <zgpeng@tencent.com>
Signed-off-by: He Chen <heddchen@tencent.com>
2020-07-16 10:41:55 +08:00
He Chen de8ae6bfd2 sched/bt: cgroup support and ignore cpu binding for offline task
This commit add cpu.offline to cpu cgroup, echo 1 > cpu.offline would
convert all tasks under this cgroup to offline task. Beside, a new
sysctl sysctl_sched_bt_ignore_cpubind is added, which makes offline
tasks ignoring CPU binding and running on any CPU.

Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
Signed-off-by: Hua Liu <shookliu@tencent.com>
Signed-off-by: Xiaogguang Chen <xiaoggchen@tencent.com>
Signed-off-by: Zhiguang Peng <zgpeng@tencent.com>
Signed-off-by: Bin Fan <tombinfan@tencent.com>
Signed-off-by: He Chen <heddchen@tencent.com>
2020-06-24 10:09:06 +08:00
He Chen 92f20d99a7 sched/bt: update rq clock before accessing it
Signed-off-by: He Chen <heddchen@tencent.com>
2020-06-24 10:09:04 +08:00
Xiaoming Gao 6e466f2dca build: fix series of warnings
Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
2020-06-04 18:43:47 +08:00
He Chen a2119393bd sched/BT: add RDT support for BT scheduler class
Offline tasks (BT tasks) may have some performance impact to online
tasks.
In this commit, we introduce Intel RDT features to limit offline tasks
L3 cache usage to avoid the influence caused by offline tasks.

Signed-off-by: Xiaoguang Chen <xiaoggchen@tencent.com>
Signed-off-by: He Chen <heddchen@tencent.com>
2020-05-29 10:40:58 +08:00
chen xiaoguang 38eea51b40 sched/rt: optimize checking group rt scheduler constraints
from upstream commit b4fb015eeff7f3e5518a7dbe806

Signed-off-by: Chen Xiaoguang <xiaoggchen@tencent.com>
2020-05-29 10:40:35 +08:00
chen xiaoguang 282df1f0e0 cpuacct/bt:fix bt_stat and usage compute error
cpuacct.stat and cpuacct.bt_stat show the same thing which
is wrong.

Signed-off-by: Chen Xiaoguang <xiaoggchen@tencent.com>
2020-05-29 10:40:14 +08:00
Qian Cai d199b0aab8 sched/fair: Fix -Wunused-but-set-variable warnings
Commit:

   de53fd7aedb1 ("sched/fair: Fix low cpu usage with high throttling by removing expiration of cpu-local slices")

introduced a few compilation warnings:

  kernel/sched/fair.c: In function '__refill_cfs_bandwidth_runtime':
  kernel/sched/fair.c:4365:6: warning: variable 'now' set but not used [-Wunused-but-set-variable]
  kernel/sched/fair.c: In function 'start_cfs_bandwidth':
  kernel/sched/fair.c:4992:6: warning: variable 'overrun' set but not used [-Wunused-but-set-variable]

Also, __refill_cfs_bandwidth_runtime() does no longer update the
expiration time, so fix the comments accordingly.

Signed-off-by: Qian Cai <cai@lca.pw>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Ben Segall <bsegall@google.com>
Reviewed-by: Dave Chiluk <chiluk+linux@indeed.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: pauld@redhat.com
Fixes: de53fd7aedb1 ("sched/fair: Fix low cpu usage with high throttling by removing expiration of cpu-local slices")
Link: https://lkml.kernel.org/r/1566326455-8038-1-git-send-email-cai@lca.pw
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2020-05-29 10:39:21 +08:00
Dave Chiluk 77d6fbc204 sched/fair: Fix low cpu usage with high throttling by removing expiration of cpu-local slices
It has been observed, that highly-threaded, non-cpu-bound applications
running under cpu.cfs_quota_us constraints can hit a high percentage of
periods throttled while simultaneously not consuming the allocated
amount of quota. This use case is typical of user-interactive non-cpu
bound applications, such as those running in kubernetes or mesos when
run on multiple cpu cores.

This has been root caused to cpu-local run queue being allocated per cpu
bandwidth slices, and then not fully using that slice within the period.
At which point the slice and quota expires. This expiration of unused
slice results in applications not being able to utilize the quota for
which they are allocated.

The non-expiration of per-cpu slices was recently fixed by
'commit 512ac999d275 ("sched/fair: Fix bandwidth timer clock drift
condition")'. Prior to that it appears that this had been broken since
at least 'commit 51f2176d74ac ("sched/fair: Fix unlocked reads of some
cfs_b->quota/period")' which was introduced in v3.16-rc1 in 2014. That
added the following conditional which resulted in slices never being
expired.

if (cfs_rq->runtime_expires != cfs_b->runtime_expires) {
	/* extend local deadline, drift is bounded above by 2 ticks */
	cfs_rq->runtime_expires += TICK_NSEC;

Because this was broken for nearly 5 years, and has recently been fixed
and is now being noticed by many users running kubernetes
(https://github.com/kubernetes/kubernetes/issues/67577) it is my opinion
that the mechanisms around expiring runtime should be removed
altogether.

This allows quota already allocated to per-cpu run-queues to live longer
than the period boundary. This allows threads on runqueues that do not
use much CPU to continue to use their remaining slice over a longer
period of time than cpu.cfs_period_us. However, this helps prevent the
above condition of hitting throttling while also not fully utilizing
your cpu quota.

This theoretically allows a machine to use slightly more than its
allotted quota in some periods. This overflow would be bounded by the
remaining quota left on each per-cpu runqueueu. This is typically no
more than min_cfs_rq_runtime=1ms per cpu. For CPU bound tasks this will
change nothing, as they should theoretically fully utilize all of their
quota in each period. For user-interactive tasks as described above this
provides a much better user/application experience as their cpu
utilization will more closely match the amount they requested when they
hit throttling. This means that cpu limits no longer strictly apply per
period for non-cpu bound applications, but that they are still accurate
over longer timeframes.

This greatly improves performance of high-thread-count, non-cpu bound
applications with low cfs_quota_us allocation on high-core-count
machines. In the case of an artificial testcase (10ms/100ms of quota on
80 CPU machine), this commit resulted in almost 30x performance
improvement, while still maintaining correct cpu quota restrictions.
That testcase is available at https://github.com/indeedeng/fibtest.

Fixes: 512ac999d275 ("sched/fair: Fix bandwidth timer clock drift condition")
Signed-off-by: Dave Chiluk <chiluk+linux@indeed.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Phil Auld <pauld@redhat.com>
Reviewed-by: Ben Segall <bsegall@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: John Hammond <jhammond@indeed.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kyle Anderson <kwa@yelp.com>
Cc: Gabriel Munos <gmunoz@netflix.com>
Cc: Peter Oskolkov <posk@posk.io>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Brendan Gregg <bgregg@netflix.com>
Link: https://lkml.kernel.org/r/1563900266-19734-2-git-send-email-chiluk+linux@indeed.com
2020-05-29 10:39:18 +08:00
He Chen f1ac9bd18b sched/bt: add latency factor for bt load
Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
Signed-off-by: Hua Liu <shookliu@tencent.com>
Signed-off-by: Xiaogguang Chen <xiaoggchen@tencent.com>
Signed-off-by: Zhiguang Peng <zgpeng@tencent.com>
Signed-off-by: Bin Fan <tombinfan@tencent.com>
Signed-off-by: He Chen <heddchen@tencent.com>
2020-03-02 22:03:10 +08:00
He Chen 0b667819c3 sched/bt: BT schduler cgroup support
Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
Signed-off-by: Hua Liu <shookliu@tencent.com>
Signed-off-by: Xiaogguang Chen <xiaoggchen@tencent.com>
Signed-off-by: Zhiguang Peng <zgpeng@tencent.com>
Signed-off-by: Bin Fan <tombinfan@tencent.com>
Signed-off-by: He Chen <heddchen@tencent.com>
2020-03-02 22:03:10 +08:00
He Chen 0dd9de2d2b sched/bt: BT scheduler load balance support
Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
Signed-off-by: Hua Liu <shookliu@tencent.com>
Signed-off-by: Xiaogguang Chen <xiaoggchen@tencent.com>
Signed-off-by: Zhiguang Peng <zgpeng@tencent.com>
Signed-off-by: Bin Fan <tombinfan@tencent.com>
Signed-off-by: He Chen <heddchen@tencent.com>
2020-03-02 22:03:09 +08:00
He Chen e6c42e61db sched/bt: BT scheduler bandwidth limit support
Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
Signed-off-by: Hua Liu <shookliu@tencent.com>
Signed-off-by: Xiaogguang Chen <xiaoggchen@tencent.com>
Signed-off-by: Zhiguang Peng <zgpeng@tencent.com>
Signed-off-by: Bin Fan <tombinfan@tencent.com>
Signed-off-by: He Chen <heddchen@tencent.com>
2020-03-02 22:03:09 +08:00
He Chen b48a63ef2c sched: add offline scheduler class
The offline scheduler named BT sched is based on the CFS scheduler. We
also use the rb-tree as the run queue to save the runnable tasks. And the
vruntime concept is also used in the offline scheduler. And the priority
of offline scheduler is from 140 to 179. So now the schedulers in the
kernel are as follows: stop, RT, CFS, BT and idle.

Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
Signed-off-by: Hua Liu <shookliu@tencent.com>
Signed-off-by: Xiaogguang Chen <xiaoggchen@tencent.com>
Signed-off-by: Zhiguang Peng <zgpeng@tencent.com>
Signed-off-by: Bin Fan <tombinfan@tencent.com>
Signed-off-by: He Chen <heddchen@tencent.com>
2020-03-02 22:03:09 +08:00
Zhiguang Peng 0e74e9c6dd sched:fair: fix crash in list_add_leaf_cfs_rq due to bad tmp_alone_branch
Signed-off-by: Zhiguang Peng <zgpeng@tencent.com>
2020-01-02 12:22:40 +08:00
Chunguang Xu fae2070952 cpuacct: get the uptime of container
add cpuacct.uptime interface to get uptime of container

Signed-off-by: Chunguang Xu <brookxu@tencent.com>
2020-01-02 12:19:36 +08:00
Fuhai Wang 017a907db8 sched: fix poor performace on kvm guest
Signed-off-by: Wang Fuhai <fuhaiwang@tencent.com>
2020-01-02 12:16:13 +08:00
Liu Hua 8e8d690592 cpuset: add cpuinfo and stat show
We add cpuinfo and stat for each container which
used for docker to get cpu stat just for current
container.

Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
Signed-off-by: Weiwei Li <nuonuoli@tencent.com>
Signed-off-by: Liu Hua <shookliu@tencent.com>
2020-01-02 11:46:17 +08:00
Xiaoming Gao 78a8c3c2c2 Init Repo base on 4.14.105 long term, and add base tlinux kernel interfaces
Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
2020-01-02 10:51:04 +08:00