kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

X520-T1 Linux内核收发包14Mpps

收包

1
2
3
ethtool -K enp3s0 gro off
PRE_ROUTING 丢包,14Mpps
LOCAL_IN 丢包,待优化

发包(I7-7700k, no_trubo=1)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
timer 8Mpps
timer+gso  tcp:11Mpps; udp:14Mpps,但是是IP分片的包
gso 需要关闭tso??  ethtool -K enp3s0 tso off gso off


kthread pfifo    14Mpps           cpu: 80%
kthread fq_codel 12~14Mpps        cpu: 100%
kthread noqueue  12Mpps           cpu: 100%


kthread pfifo static_skb    14Mpps    cpu: 40%
kthread fq_codel static_skb 14Mpps    cpu: 40%
kthread noqueue static_skb  12Mpps    cpu: 100%


kthread noqueue static_skb skb_list  14Mpps   cpu: 20%
				1cpu: 9Mpps, cpu 100%
				2cpu: 14Mpps, cpu 60%


M.2 SSD 增加收包si 20%,发包10%
I5-6500 只能发送12.5Mpps, netmap也一样 ???

转发

1
2
12Mpps 以上? 待测
把收到的包转发比申请一个包发出更优

细节待更新

GPU温控

目录是 /sys/class/drm/card0/device/hwmon/hwmonX/

换内核之类的操作会改变 hwmonX

调节脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python

import commands;
import time;

t0=0
temp_inc=[90000, 85000, 80000, 70000, 60000, 50000, 40000, 00000];
pwm_inc=[ 245,   205,   165,   125,   105,   85,    65,    45];

temp_dec=[89000, 84000, 79000, 67000, 57000, 47000, 37000, 00000];
pwm_dec=[ 245,   205,   165,   125,   105,   85,    65,    45];


global pwm1
pwm1=0;

def set_pwm(newpwm):
	global pwm1
	if newpwm != pwm1:
		cmd="echo "+str(newpwm)+" > /sys/class/drm/card0/device/hwmon/hwmon3/pwm1";
		r,o = commands.getstatusoutput(cmd);
		pwm1=newpwm;

		#cmd1="cat /sys/class/drm/card0/device/hwmon/hwmon3/pwm1";
		#r,o = commands.getstatusoutput(cmd1);
                #print cmd
                #print r, o

r,o = commands.getstatusoutput("echo 1 > /sys/class/drm/card0/device/hwmon/hwmon3/pwm1_enable");
while 1:
	r,t = commands.getstatusoutput("cat /sys/class/drm/card0/device/hwmon/hwmon3/temp1_input");
	t = int(t);
	if t - t0 > 0:
		for i in range(0, 8):
			if t >= temp_inc[i]:
				break;
		#print "inc ", t, temp_inc[i], pwm_inc[i]
		set_pwm(pwm_inc[i]);
	elif t - t0 < 0:
		for i in range(0, 8):
			if t >= temp_dec[i]:
				break;
		#print "dec ", t, temp_dec[i], pwm_dec[i]
		set_pwm(pwm_dec[i]);

	t0 = t;
	time.sleep(10);

ubuntu 编译内核、模块

https://launchpad.net/ubuntu/+source/linux/+changelog

4.15.0

https://launchpad.net/ubuntu/bionic/+source/linux/+changelog

https://packages.ubuntu.com/xenial/linux-source-4.15.0
http://security.ubuntu.com/ubuntu/pool/main/l/linux-hwe/linux-source-4.15.0_4.15.0-58.64~16.04.1_all.deb

https://launchpad.net/ubuntu/xenial/amd64/linux-image-unsigned-4.15.0-58-generic-dbgsym
http://launchpadlibrarian.net/436393485/linux-image-unsigned-4.15.0-58-generic-dbgsym_4.15.0-58.64~16.04.1_amd64.ddeb

https://launchpad.net/ubuntu/bionic/amd64/linux-image-unsigned-4.15.0-58-generic-dbgsym
http://launchpadlibrarian.net/436226708/linux-image-unsigned-4.15.0-58-generic-dbgsym_4.15.0-58.64_amd64.ddeb

4.18.0

https://launchpad.net/ubuntu/xenial/+source/linux/+changelog

https://packages.ubuntu.com/bionic/linux-source-4.18.0
http://security.ubuntu.com/ubuntu/pool/main/l/linux-hwe/linux-source-4.18.0_4.18.0-25.26~18.04.1_all.deb

https://launchpad.net/ubuntu/bionic/amd64/linux-image-4.18.0-25-generic-dbgsym
http://launchpadlibrarian.net/430863032/linux-image-4.18.0-25-generic-dbgsym_4.18.0-25.26~18.04.1_amd64.ddeb

gcc 7 编译内核模块时无法找到 stdarg.h 的问题

https://blog.gloriousdays.pw/2018/09/09/cannot-find-stdarg-h-on-linux-kernel-4-15-with-gcc-7-3/

这是一个非常奇怪的错误,出现在 Ubuntu 18.04 上,默认安装的内核版本是 4.15,gcc 是 7.3,在编译内核模块时报错:

1
2
3
4
5
6
7
In file included from ./include/linux/list.h:9:0,
                 from ./include/linux/module.h:9,
                 from /root/Software/newbbr/tcp_tsunami.c:59:
./include/linux/kernel.h:6:10: fatal error: stdarg.h: No such file or directory
 #include <stdarg.h>
          ^~~~~~~~~~
compilation terminated.

gcc 认为找不到 stdarg.h。看这个错误的位置,个人认为应该不是我配置的问题或者是我代码的问题,搜索了一下,也有很多在 4.15 内核上出现的同样错误。目前没有什么很好的解决方案,暂时性的方案是在编译的 Makefile 里面加一行:

1
ccflags-y=-I/usr/lib/gcc/x86_64-linux-gnu/7/include

如果是 gcc 8,就相应把版本改成 8 就可以了

编译内核

1
2
3
sudo apt-get install libncurses-dev flex bison openssl-dev libssl-dev dkms libelf-dev

make bindeb-pkg -j8

按这里没成功 https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel

编译perf

1
2
cd tools/perf
make