Skip to content

Instantly share code, notes, and snippets.

@kay21s
kay21s / Fix DPDK huge page sharing
Created June 13, 2017 01:57
Fix DPDK huge page sharing between primary and secondary process
Use DPDK, running primary process on the host and secondary process in docker. Following error would occur:
EAL: Cannot mmap device resource file /sys/bus/pci/devices/0000:02:00.0/resource3 to address: 0x7ffff7feb000
CAUSE: if addr is given when using mmap(), it’s just a hint, but not a must.
FIX:
In file: lib/librte_eal/common/eal_common_pci_uio.c
Add flag MAP_FIXED when calling mmap() in pci_map_resource(), that means:
78 void *mapaddr = pci_map_resource(uio_res->maps[i].addr,
@kay21s
kay21s / Disable ASLR
Last active October 27, 2019 01:00
Disable ASLR in the system
Disable: echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
Enable: echo 2 | sudo tee /proc/sys/kernel/randomize_va_space
But the above configuration will be canceled after a reboot.
For permanent configuration:
Add a file /etc/sysctl.d/01-disable-aslr.conf containing: kernel.randomize_va_space = 0
sudo docker run -it --network none --privileged --device=/dev/uio1:/dev/uio1 -v /var/run:/var/run -v /mnt/huge/:/mnt/huge/ -v /home/kai/openNetVM/:/openNetVM -w=/ --name=test ubuntu:14.04 /bin/bash
@kay21s
kay21s / 10Gbps calculation
Last active September 23, 2020 07:28
The calculations: 10Gbit/s wirespeed
In this blogpost, I'll try to make you understand the engineering challenge behind processing 10Gbit/s wirespeed, at the smallest Ethernet packet size.
The peak packet rate is 14.88 Mpps (million packets per sec) uni-directional on 10Gbit/s with the smallest frame size.
Details: What is the smalles Ethernet frame
Ethernet frame overhead:
Ethernet specific (20 bytes)
12 bytes = inter-frame gap (https://en.wikipedia.org/wiki/Interpacket_gap)
8 bytes = MAC preamble
@kay21s
kay21s / GPU set clock
Last active June 15, 2017 07:42
GPU set clock
nvidia-smi -q -d SUPPORTED_CLOCKS
nvidia-smi -ac 715,1328 //set the clock <MEMCLOCK, GPUCLOCK>
nvidia-smi -q -d CLOCK //view the clock in use
nvidia-smi -rac //set clock back to the base clock
@kay21s
kay21s / Poseidon CMD
Last active August 17, 2017 13:23
Poseidon CMD
====== SETUP =======
echo export RTE_SDK=$(pwd) >> ~/.bashrc
echo export RTE_TARGET=x86_64-native-linuxapp-gcc >> ~/.bashrc
source ~/.bashrc
======  END  =======
cores = [0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13]
sockets = [0]
@kay21s
kay21s / fix cuda
Last active June 16, 2017 08:05
Fix CUDA
sudo ldconfig /usr/local/cuda/lib64
sudo service lightdm stop

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@kay21s
kay21s / Linux Container
Created January 22, 2015 23:45
Linux Container
LXC depends on the control group filesystem being mounted. The standard location for it is /sys/fs/cgroup.
Containers are stored in /var/lib/lxc/CONTAINER_NAME directory.
The main configuration file is /var/lib/lxc/CONTAINER_NAME/config
root filesystem under /var/lib/lxc/CONTAINER_NAME/rootfs
List Container:
lxc-ls -f
lxc-start -n CONTAINER_NAME -d
@kay21s
kay21s / MICA
Created December 15, 2014 20:55
MICA
sudo ./netbench_server conf_machines_0_EREW_0.5 server 0 0 conf_prepopulation_empty
@kay21s
kay21s / OProfile
Last active August 29, 2015 14:06
OProfile
sudo opcontrol --init
sudo opcontrol --vmlinux=/boot/vmlinuz-'uname -r'
OR uname -r ==> 3.13.0-35-generic
sudo opcontrol --vmlinux=/boot/vmlinuz-3.13.0-35-generic
sudo operf --event=CPU_CLK_UNHALTED:100000
OR sudo opcontrol --event=CPU_CLK_UNHALTED:100000
operf --event=CPU_CLK_UNHALTED:100000 --event=LLC_MISSES:100000 ./build/megakv