Commit Graph

240 Commits

Author SHA1 Message Date
Liu Hua 0b99e69c14 sched: fix bug of cpuquota_aware 2020-09-07 14:47:42 +08:00
Hongbo Li 6444bf5cff net: update mlx drv
comment "echo "%__os_install_post %{nil}" >> ~/.rpmmacros"
to make compile success in chroot envrionment.

Signed-off-by: Hongbo Li <herberthbli@tencent.com>
2020-08-14 10:32:09 +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
Hongbo Li 5f36de68e0 mlx drv update
Signed-off-by: Hongbo Li <herberthbli@tencent.com>
2020-07-17 15:54:17 +08:00
Hongbo Li 70433937ca add mlx drv
Make mlx driver build with kernel.

Signed-off-by: Hongbo Li <herberthbli@tencent.com>
2020-07-17 15:54:04 +08:00
Xiaoming Gao eddeadbd7e Merge branch 'master' of https://github.com/Tencent/TencentOS-kernel 2020-07-17 15:04:03 +08:00
gxm-newtonf 909e59b0ef
Merge pull request #19 from kenieevan/master
ipvs-ebpf: add non-masqurade-agent support.
2020-07-16 15:23:20 +08:00
chen xiaoguang 2a3f62dd59 sched/bt: eliminate warning when booting with offline_class
offline_class was defined as an early_param. But the callback
function return 1 which lead to a warning message
"[    0.000000] Malformed early option 'offline_class'"
when booting.

Signed-off-by: Xiaoguang Chen <xiaoggchen@tencent.com>
2020-07-16 15:05:18 +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
jianmingfan 7d6e19b3c6 fix coding sytle and check mask length
Signed-off-by: jianmingfan <jianmingfan@tencent.com>
2020-07-08 18:51:32 +08:00
Hongbo Li 5a2b338a2a net: sched when reading conntrack proc
cat/proc/net/nf_conntrack may cause long latency.
Add cond_resched_rcu() when reading this proc file.

Signed-off-by: Hongbo Li <herberthbli@tencent.com>
2020-07-08 16:07:58 +08:00
Hongbo Li 0b46e0dbd4 net: sched when reading udp proc
cat /proc/net/udp may cause long latency.
Add cond_resched() when reading this proc file.

Signed-off-by: Hongbo Li <herberthbli@tencent.com>
2020-07-08 16:07:57 +08:00
Hongbo Li 61d7e2b266 net: sched when reading tcp proc
cat /proc/net/tcp may cause long latency.
Add cond_resched() when reading this proc file.

Signed-off-by: Hongbo Li <herberthbli@tencent.com>
2020-07-08 16:07:55 +08:00
Hongbo Li fcf7481192 net: more entropy from net_hash_mix
upstream: 5424ea27390f ("netns: get more entropy from net_hash_mix()")

struct net are effectively allocated from order-1 pages on x86,
with one object per slab, meaning that the 13 low order bits
of their addresses are zero.

Once shifted by L1_CACHE_SHIFT, this leaves 7 zero-bits,
meaning that net_hash_mix() does not help spreading
objects on various hash tables.

For example, TCP listen table has 32 buckets, meaning that
all netns use the same bucket for port 80 or port 443.

Signed-off-by: Hongbo Li <herberthbli@tencent.com>
2020-07-08 16:07:52 +08:00
Hongbo Li 7ab7c64182 net: increase listening hash size
increase listening hash size from 32 to 4096

Signed-off-by: Hongbo Li <herberthbli@tencent.com>
2020-07-08 16:07:50 +08:00
Zhiping du de427fd173 getsockopt: add SO_MARK2 to get the MARK of flow
[tkernel2 commit c6f2e27f7ad]

add SO_MARK2 to get the MARK of flow

Signed-off-by: brookxu <brookxu@tencent.com>

Signed-off-by: Zhiping Du <zhipingdu@tencent.com>
2020-07-08 16:04:22 +08:00
Xiaoming Gao cf69d8f3c0 mpt3sas: sort sas by slot before sas_attach
currently sas disk detected order is decided by the first interrupt
generated order, not by slot number, fix it by slot number.

Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
2020-07-08 15:58:51 +08:00
Kaixu Xia e160ea10b7 drivers: update megaraid drivers to 07.713.02.00
Update from 07.707.51.00-rc1 to 07.713.02.00.

Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
2020-07-08 15:55:26 +08:00
jianmingfan 9465674790 ipvs-ebpf: add non-masqurade-agent support.
previously, for clusterIP type service, no SNAT is done.
However, in some case, user may add rs ip outside vpc which may require
SNAT.

To address this issue, a non snat ip table of max 64 entries are added.

Usage:

1. echo -n "0.0.0.0/0" > /proc/net/ip_vs_non_masq_cidrs will make all ip
bypass snat.

2. echo -n ":" > /proc/net/ip_vs_non_masq_cidrs will make all ip do snat.

3. echo "a.b.c.d/24:a.b.c.e/24" >  /proc/net/ip_vs_non_masq_cidrs

Test case:

create a cluster with 9 PODS

172.19.0.175  172.19.0.176   172.19.0.177 172.19.0.241 172.19.0.242
172.19.0.243 172.19.0.244 172.19.0.100  172.19.0.101

0)

/proc/net/ip_vs_non_masq_cidrs is empty, curl cluster ip shall do SNAT
result: pass

1)

Three ip/32 in  /proc/net/ip_vs_non_masq_cidrs

echo "172.19.0.175/32:172.19.0.176/32:172.19.0.177/32" > /proc/net/ip_vs_non_masq_cidrs

Test:  curl the clusterip, and watch the tcpdump log

Expected result:

access to the ip in list no SNAT; access to the ip not in list do SNAT.

Result: pass, no leak.

2)  stress test

wrk  the clusterip , at the same time, run a program to modify the ip_vs_non_masq_cidrs in a loop

Expected result: curl ok. lo leak

    while [ 1 ]
    do
            echo "172.19.0.175/32:172.19.0.176/32:172.19.0.177/32" > /proc/net/ip_vs_non_masq_cidrs

            sleep 1
            cat /proc/net/ip_vs_non_masq_cidrs
            echo ""
            echo "172.19.0.175/32" > /proc/net/ip_vs_non_masq_cidrs
            sleep 1
            cat /proc/net/ip_vs_non_masq_cidrs
            echo ""
    done

result:  no leak;

3) corner test

write "0.0.0.0/0" to it.

expected result: shall not do SNAT.

result:  ok

echo  -n ":
expected result: do SNAT
result: ok

Signed-off-by: jianmingfan <jianmingfan@tencent.com>
2020-07-07 18:11:48 +08:00
Zhiping du 7204bad0ed ceph: quota: fix null pointer dereference in quota check
[upstream commit 71f2cc64d027d7]

MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This patch fixes a possible null pointer dereference in
check_quota_exceeded, detected by the static checker smatch, with the
following warning:

   fs/ceph/quota.c:240 check_quota_exceeded()
    error: we previously assumed 'realm' could be null (see line 188)

Fixes: b7a2921765cf ("ceph: quota: support for ceph.quota.max_files")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

Signed-off-by: Zhiping Du <zhipingdu@tencent.com>
2020-07-06 14:35:32 +08:00
David Lin 01bad2abca
Fixed typo in thread_info.h (#16)
* Fixed typo in thread_info.h

user-thead -> user-thread
2020-07-02 14:46:02 +08:00
Xiaoming Gao a85a2f815b Merge branch 'master' of https://github.com/Tencent/TencentOS-kernel 2020-06-24 10:29:31 +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
gxm-newtonf f23f5f6fbf
Merge pull request #17 from Tencent/ipvs-avoid-drop-first-packet-by-reusing-conntrack
ipvs: avoid drop first packet by reusing conntrack
2020-06-23 21:56:39 +08:00
YangYuxi a01a9445c0 ipvs: avoid drop first packet by reusing conntrack
Since 'commit f719e3754ee2 ("ipvs: drop first packet to
redirect conntrack")', when a new TCP connection meet
the conditions that need reschedule, the first syn packet
is dropped, this cause one second latency for the new
connection, more discussion about this problem can easy
search from google, such as:

1)One second connection delay in masque
https://marc.info/?t=151683118100004&r=1&w=2

2)IPVS low throughput #70747
https://github.com/kubernetes/kubernetes/issues/70747

3)Apache Bench can fill up ipvs service proxy in seconds #544
https://github.com/cloudnativelabs/kube-router/issues/544

4)Additional 1s latency in `host -> service IP -> pod`
https://github.com/kubernetes/kubernetes/issues/90854

5)kube-proxy ipvs conn_reuse_mode setting causes errors
with high load from single client
https://github.com/kubernetes/kubernetes/issues/81775

The root cause is when the old session is expired, the
conntrack related to the session is dropped by
ip_vs_conn_drop_conntrack. The code is as follows:
```
static void ip_vs_conn_expire(struct timer_list *t)
{
...

     if ((cp->flags & IP_VS_CONN_F_NFCT) &&
         !(cp->flags & IP_VS_CONN_F_ONE_PACKET)) {
             /* Do not access conntracks during subsys cleanup
              * because nf_conntrack_find_get can not be used after
              * conntrack cleanup for the net.
              */
             smp_rmb();
             if (ipvs->enable)
                     ip_vs_conn_drop_conntrack(cp);
     }
...
}
```
As shown in the code, only when condition (cp->flags & IP_VS_CONN_F_NFCT)
is true, the function ip_vs_conn_drop_conntrack will be called.

So we optimize this by following steps (Administrators
can choose the following optimization by setting
net.ipv4.vs.conn_reuse_old_conntrack=1):
1) erase the IP_VS_CONN_F_NFCT flag (it is safely because
   no packets will use the old session)
2) call ip_vs_conn_expire_now to release the old session,
   then the related conntrack will not be dropped
3) then ipvs unnecessary to drop the first syn packet, it
   just continue to pass the syn packet to the next process,
   create a new ipvs session, and the new session will related
   to the old conntrack(which is reopened by conntrack as a new
   one), the next whole things is just as normal as that the old
   session isn't used to exist.

The above processing has no problems except for passive FTP,
for passive FTP situation, ipvs can judging from
condition (atomic_read(&cp->n_control)) and condition (cp->control).
So, for other conditions(means not FTP), ipvs should give users
the right to choose,they can choose a high performance one processing
logical by setting net.ipv4.vs.conn_reuse_old_conntrack=1. It is necessary
because most business scenarios (such as kubernetes) are very sensitive
to TCP short connection latency.

This patch has been verified on our thousands of kubernets
node servers on Tencent Inc.

Signed-off-by: YangYuxi <yx.atom1@gmail.com>
2020-06-23 19:45:04 +08:00
Xiaoming Gao c1d41dd03c config: open more virtualization support
Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
2020-06-05 12:43:25 +08:00
Xiaoming Gao 1193d389ae config: open CONFIG_VMD
Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
2020-06-05 11:00:01 +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
jianmingfan 07a6e5ff63 constrain the fix in conn_reuse_mode==0 && no_route_to_host_fix==1
Signed-off-by: jianmingfan <jianmingfan@tencent.com>
2020-05-29 10:41:08 +08:00
jianmingfan 8ec35911f7 add no_route_to_host_fix switch to turn on/off the fix in bpf mode
Test case
	1) conn_reuse_mode = 1 && no_route_to_host_fix==1
	result: wrk performance good
	2) conn_reuse_mode = 1 && no_route_to_host_fix==0
	result: wrk performance bad, packet loss
	3) conn_reuse_mode = 0 && no_route_to_host_fix==0
	result: wrk performance good. icmp no route to host error
	4) conn_reuse_mode = 0 && no_route_to_host_fix==1
	result: wrk performance good. no icmp no route to host error

Signed-off-by: jianmingfan <jianmingfan@tencent.com>
2020-05-29 10:41:05 +08:00
jianmingfan ef8004f8fe 1) fix conn_reuse_mode=1 performance degradation as introduced in commit
year 2015 d752c364571743d696c2a54a449ce77550c35ac5
year 2016 f719e3754ee2f7275437e61a6afd520181fdd43b

current only fix it in bpf mode. It will later be promoted to ipvs mode.

The key is that add a ref count in ct so that old/new ip_vs_conn can share it
without packet loss.

Test case
./wrk http 1.0 test, the cps increases from 1.5K to 30K.

2) solve no route to host bug

when conn_reuse_mode = 0, new connection may be redirect to rs with weight=0
if client  port reuse. This cause icmp no route to host if the rs is
terminating

Test case:
 1. wrk http1.0 from client
 2. set rs to zero on lb, then kill the rs

in ipvs mode, you can see icmp error like
14:17:28.509454 IP 10.0.0.4 > 10.0.0.17: ICMP host 172.16.0.16 unreachable, length 68

in bpf mode, this is fixed.

Signed-off-by: jianmingfan <jianmingfan@tencent.com>
2020-05-29 10:41:03 +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 f2ebfe3050 config: open CONFIG_PREEMPT_VOLUNATRY
Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
2020-05-29 10:40:56 +08:00
Yuxi Yang a44d7f91a8 ip_vs: add sysctl to bypass estimation
Signed-off-by: Fuhai Wang <fuhaiwang@tencent.com>
2020-05-29 10:40:54 +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
brookxu 82ac1bb32d block: bio_iov_iter_get_pages: pin more pages for multi-segment IOs
commit <0aa69fd32a5f766e997ca8ab4723c5a1146efa8b>
commit <17d51b10d7773e4618bcac64648f30f12d4078fb>

bio_iov_iter_get_pages() currently only adds pages for the next non-zero
segment from the iov_iter to the bio. That's suboptimal for callers,
which typically try to pin as many pages as fit into the bio. This patch
converts the current bio_iov_iter_get_pages() into a static helper, and
introduces a new helper that allocates as many pages as

 1) fit into the bio,
 2) are present in the iov_iter,
 3) and can be pinned by MM.

Error is returned only if zero pages could be pinned. Because of 3), a
zero return value doesn't necessarily mean all pages have been pinned.
Callers that have to pin every page in the iov_iter must still call this
function in a loop (this is currently the case).

This change matters most for __blkdev_direct_IO_simple(), which calls
bio_iov_iter_get_pages() only once. If it obtains less pages than
requested, it returns a "short write" or "short read", and
__generic_file_write_iter() falls back to buffered writes, which may
lead to data corruption.

Signed-off-by: Chunguang Xu <brookxu@tencent.com>
2020-05-29 10:40:50 +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
Kaixu Xia 59f0f72b8a xfs: catch inode allocation state mismatch corruption and retry to allocate ino
Catch the inode allocation state mismatch corruption, and then return
an corruption error when creating a file. Retry to allocate inode and
find a fine inode no..

Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
2020-05-29 10:40:42 +08:00