Tuesday, February 27, 2018

update kernel defconfig



make ARCH=arm xxx_defconfig
make ARCH=arm menuconfig
make savedefconfig
cp ./defconfig ./arch/arm/configs/xxx_defconfig

Tuesday, February 13, 2018

time measurement in kernel

ktime_t start_time, end_time;
s64 delay_time;

start_time = ktime_get();
udelay(10);
end_time = ktime_get();

delay_time = ktime_to_ns(end_time) - ktime_to_ns(start_time);
printk("delay_time %lld nsec\n", delay_time);

Friday, February 2, 2018

tc - linux traffic control

sudo tc qdisc add dev eth0 root fq_codel

sudo sysctl -w net.core.default_qdisc=fq_codel

* man tc fq_codel

FQ_CoDel(8)                                                        Linux                                                   
NAME
       CoDel - Fair Queuing (FQ) with Controlled Delay (CoDel)

SYNOPSIS
       tc qdisc ... fq_codel [ limit PACKETS ] [ flows NUMBER ] [ target TIME ] [ interval TIME ] [ quantum BYTES ] [ ecn | noecn ]

qdisc fq_codel 8001: dev wlan0 root refcnt 5 limit 1024p flows 1024 quantum 300 target 5.0ms interval 100.0ms ecn

qdisc
        [ add | change | replace | link | delete ]
dev DEV

[ parent qdisc-id | root ]

qdisc name [qdisc specific parameters ]

tc change dev wifi0 root cake bandwidth 10mbit

sudo tc -s qdisc show
       -s, -stats, -statistics
              output more statistics about packet usage.

Adding this to /etc/sysctl.conf or /etc/sysctl.d/bufferbloat.conf is
generally what we do

net.core.default_qdisc=fq_codel

A lot of us are running ecn by default and put in ecn on also:

net.ipv4.tcp_ecn=1

tc qdisc add dev wlan0 root fq_codel target 50.0ms interval 1000.0ms ecn
tc -s qdisc show wlan0 ap0
tc qdisc change dev wlan0 root fq_codel target 10.0ms interval 1000.0ms noecn
tc qdisc del dev wlan0 root fq_codel

Wednesday, January 31, 2018

about linux kernel memory map

cat /proc/vmallocinfo

0xbf000000-0xbf007000   28672 module_alloc_update_bounds+0xc/0x5c pages=6 vmalloc
0xbf009000-0xbf011000   32768 module_alloc_update_bounds+0xc/0x5c pages=7 vmalloc
0xbf015000-0xbf052000  249856 module_alloc_update_bounds+0xc/0x5c pages=60 vmalloc
0xbf05b000-0xbf060000   20480 module_alloc_update_bounds+0xc/0x5c pages=4 vmalloc
0xbf062000-0xbf0c7000  413696 module_alloc_update_bounds+0xc/0x5c pages=100 vmalloc
0xbf0d6000-0xbf147000  462848 module_alloc_update_bounds+0xc/0x5c pages=112 vmalloc
0xbf151000-0xbf15d000   49152 module_alloc_update_bounds+0xc/0x5c pages=11 vmalloc
0xbf160000-0xbf1ca000  434176 module_alloc_update_bounds+0xc/0x5c pages=105 vmalloc
0xbf1d1000-0xbf1d8000   28672 module_alloc_update_bounds+0xc/0x5c pages=6 vmalloc
0xbf1db000-0xbf1ff000  147456 module_alloc_update_bounds+0xc/0x5c pages=35 vmalloc
0xbf206000-0xbf211000   45056 module_alloc_update_bounds+0xc/0x5c pages=10 vmalloc
0xbf216000-0xbf241000  176128 module_alloc_update_bounds+0xc/0x5c pages=42 vmalloc
0xbf24a000-0xbf307000  774144 module_alloc_update_bounds+0xc/0x5c pages=188 vmalloc
0xbf328000-0xbf331000   36864 module_alloc_update_bounds+0xc/0x5c pages=8 vmalloc
0xbf334000-0xbf339000   20480 module_alloc_update_bounds+0xc/0x5c pages=4 vmalloc
0xe0800000-0xe0802000    8192 of_iomap+0x2c/0x34 phys=b000000 ioremap
0xe0802000-0xe0804000    8192 of_iomap+0x2c/0x34 phys=b002000 ioremap
0xe0810000-0xe0a11000 2101248 atomic_pool_init+0x0/0x100 phys=9f600000 user
0xe0a12000-0xe0a14000    8192 devm_ioremap_nocache+0x38/0x70 phys=7700000 ioremap
0xe0a14000-0xe0a16000    8192 devm_ioremap+0x38/0x70 phys=78b7000 ioremap
0xe0a16000-0xe0a18000    8192 devm_ioremap+0x38/0x70 phys=78b8000 ioremap
0xe0a18000-0xe0a1a000    8192 devm_ioremap_nocache+0x38/0x70 phys=1948000 ioremap

Friday, January 26, 2018

Thursday, January 25, 2018

tcpdump option and filters

tcpdump -Q in -xxx -ni ap0 port 42424

(ip.src == 192.168.12.2 && ip.dst == 192.168.12.1) && (udp.length < 80) && (frame contains a5:b8:a5:b8:00:38:00:00:40:00)

Wednesday, January 24, 2018

timestamp in linux shell commandline / file operations


touch /root/client-01-$(date +%s)


[ -f /etc/hosts ] && echo "Found" || echo "Not found"


[ ! -f /etc/hosts ] && echo "File does not exist" || echo "File exits"


#!/bin/bash
file="/etc/hosts"
if [ -f "$file" ]
then
echo "$file found."
else
echo "$file not found."
fi


#!/bin/bash
file="/.config/backup.cfg"
if [ ! -f "$file" ]
then
    echo "$0: File '${file}' not found."
fi


File test operators
The following operators returns true if file exists:

if [ operator FileName ]
then
     echo "FileName - Found, take some action here"
else
   echo "FileName - Not found, take some action here"
fi


       -b FILE
              FILE exists and is block special

       -c FILE
              FILE exists and is character special

       -d FILE
              FILE exists and is a directory

       -e FILE
              FILE exists

       -f FILE
              FILE exists and is a regular file

       -g FILE
              FILE exists and is set-group-ID

       -G FILE
              FILE exists and is owned by the effective group ID

       -h FILE
              FILE exists and is a symbolic link (same as -L)

       -k FILE
              FILE exists and has its sticky bit set

       -L FILE
              FILE exists and is a symbolic link (same as -h)

       -O FILE
              FILE exists and is owned by the effective user ID

       -p FILE
              FILE exists and is a named pipe

       -r FILE
              FILE exists and read permission is granted

       -s FILE
              FILE exists and has a size greater than zero

       -S FILE
              FILE exists and is a socket

       -t FD  file descriptor FD is opened on a terminal

       -u FILE
              FILE exists and its set-user-ID bit is set

       -w FILE
              FILE exists and write permission is granted

       -x FILE
              FILE exists and execute (or search) permission is granted