Commit Graph

73 Commits

Author SHA1 Message Date
yongduan 985a0aad22 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 17:00:12 +08:00
yongduan 772d6366c7 net: rps using pvipi
In the virtualization scenario, you can use pvipi to optimize the sending of
IPI interrupts and reduce the number of vmexit.

rps_using_pvipi test
Test guest: 32 core, 64G memory, virtio-net 8 queues, rss interrupt is bound
to 24-31 core. Observe the number of vmexit of 31 cores.

1. 1000000pps
100 iperf instances, 10000pps per instance.
disable rps_using_pvipi  68077 vmexit/s
enable  rps_using_pvipi  21138 vmexit/s

2. 2000000pps
1000 iperf instances, 2000pps per instance.
disable rps_using_pvipi  40879 vmexit/s
enable  rps_using_pvipi  9195  vmexit/s

3. 2000000pps
2000 iperf instances, 1000pps per instance.
disable rps_using_pvipi  24746 vmexit/s
enable  rps_using_pvipi  7292  vmexit/s

Enabling rps_using_pvipi can greatly reduce the number of vmexit.

Signed-off-by: yongduan <yongduan@tencent.com>
2020-12-01 10:36:20 +08:00
yongduan 3853775fa6 smp: smp_call_function_many_async
Run an asynchronous function on a many cpus.
smp_call_function_many_async_begin
for_each_csd
        smp_call_function_many_async
smp_call_function_many_async_end

Signed-off-by: yongduan <yongduan@tencent.com>
2020-12-01 10:34:56 +08:00
zgpeng 8cbbd36a38 proc: fix the display error of the processes field in /proc/stat
Signed-off-by: zhiguang peng <zgpeng@tencent.com>
2020-11-12 14:39:06 +08: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
gxm-newtonf a26f554ca5
Merge pull request #35 from charliecgxu/softirq
softirq: enhance network latency
2020-10-28 11:16:06 +08:00
charliecgxu f7860a5c86 softirq: enhance network latency
Enhance network tail latency by directly handling softirq
when detecting long scheduling latency of ksoftirqd.

Signed-off-by: yongduan <yongduan@tencent.com>
Signed-off-by: charliecgxu <charliecgxu@tencent.com>
2020-10-16 11:55:22 +08:00
charliecgxu 61219f7c16 memcg: add scheduling point while showing memcg usage
Without preemption, if syscall excutes too long it will significantly
affect performance of other important processes. So add a shceduling
point when showing root memcg usage.

Signed-off-by: yongduan <yongduan@tencent.com>
Signed-off-by: charliecgxu <charliecgxu@tencent.com>
2020-10-13 10:13:59 +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
chen xiaoguang 8fe0499fd3 cgroup/memory: add schedule point while showing memory stat
Also a switch had been added to control whether show the
subtree or not.

Signed-off-by: Chen He <heddchen@tencent.com>
Signed-off-by: Peng Zhiguang <zgpeng@tencent.com>
Signed-off-by: Chen Xiaoguang <xiaoggchen@tencent.com>
2020-05-29 10:41:01 +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
Xiaoming Gao 205fee4e55 clocksource: add kernel.clocksource_unstable_cnt to track tsc unstable
since we disable clocksource switch when tsc not stable, we need a
counter to track tsc unstable did happend.

Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
2020-05-29 10:40:52 +08:00
Xiaoming Gao 7c59213786 clocksource: add debug information and disable tsc switch
output more information when clocksource got unstable,
and add kernel.clocksource_switch_unstable_cs to control
whether to switch off unstable clocksource.

Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
2020-05-29 10:40:44 +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
Kaixu Xia b0e23ef723 pagecachelimit: add the slab(dentry&inode) limit support
Add the support that controlling slab(dentry&inode) limit and the
corresponding sysctl interface.

Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
2020-05-29 10:40:24 +08:00
Xiaoming Gao 9de8b674e2 slub: add fast_slub_nr_free to track free objects
use lightweight track method to count free objects in
slub, remove heavy logic in spin_lock_irqsave.

Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
2020-05-29 10:40:21 +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
zgpeng f2ba303dbd vm: add max_map_count isolate switch
Add the max_map_count isolation switch kernel.isolate_max_map_count;
The isolation of max_map_count is turned on by default. If you want
to turn it off, set kernel.isolate_max_map_count to 0;

Signed-off-by: Zhiguang Peng <zgpeng@tencent.com>
2020-05-29 10:38:28 +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
Xiaoming Gao f540f245de vm: fix isolate max_map_count, inherit the value of the parent namespace instead
Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
2020-01-21 12:05:14 +08:00
Xiaoming Gao 42c43458cb tools: add ttools module to support ptrace protect
Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
2020-01-02 15:12:03 +08:00
Fuhai Wang 9d289d8cff epoll: introduce min_wait_time
epoll hrtimer patch may increase loop times if timeout set to 1ms.
This patch add new sysctl control the minimal wait time, and default
to 1 jiffies.

Signed-off-by: Samuel Liao <samuelliao@tencent.com>
Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
Signed-off-by: Fuhai Wang <fuhaiwang@tencent.com>
2020-01-02 14:53:48 +08:00
Fuhai Wang b068df7b27 Revert "epoll: introduce min_wait_time" 2020-01-02 14:53:11 +08:00
Fan Bin f030ef831c build: Fix build issue introduced by kpatch
Signed-off-by: Fan Bin <tombinfan@tencent.com>
2020-01-02 14:51:55 +08:00
Liu Yu f39de73b07 sysctl: fix build issue if CONFIG_CPUSETS disabled
Signed-off-by: Liu Yu <allanyuliu@tencent.com>
2020-01-02 12:24:19 +08:00