Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lock_module/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EXTRA_CFLAGS = -Wall -g

obj-m = modul.o
13 changes: 13 additions & 0 deletions lock_module/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
KDIR = /lib/modules/`uname -r`/build
MODULE_NAME=modul
kbuild:
make -C $(KDIR) M=`pwd`

clean:
make -C $(KDIR) M=`pwd` clean

install: kbuild
sudo insmod $(MODULE_NAME).ko

uninstall:
sudo rmmod $(MODULE_NAME)
24 changes: 24 additions & 0 deletions lock_module/bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
LOCK_PATH=/sys/kernel/debug/lock_benchmark
CPU=$1

echo $CPU > $LOCK_PATH/cpu
dmesg -c > /dev/null
echo 1 > $LOCK_PATH/trigger
READY=$(cat $LOCK_PATH/ready)
while [ "$READY" -eq 0 ]
do
sleep 1
READY=$(cat $LOCK_PATH/ready)
done

echo 2 > $LOCK_PATH/trigger
READY=$(cat $LOCK_PATH/ready)
while [ "$READY" -eq 0 ]
do
sleep 1
READY=$(cat $LOCK_PATH/ready)
done

echo "CPU:$CPU" >> result
python3 parse_dmesg.py $1 >> result

74 changes: 74 additions & 0 deletions lock_module/list_bench.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include <linux/list.h>

struct list_param {
struct list_head *arg[2];
};

void* cc_list_move(void *params) {
struct list_param *list_param;

list_param = (struct list_param *)params;
list_move(list_param->arg[0], list_param->arg[1]);
return NULL;
}

void* cc_list_move_tail(void *params) {
struct list_param *list_param;

list_param = (struct list_param *)params;
list_move_tail(list_param->arg[0], list_param->arg[1]);
return NULL;
}


void* cc_list_del(void *params) {
struct list_param *list_param;

list_param = (struct list_param *)params;
list_del(list_param->arg[0]);
return NULL;
}

void* cc_list_del_init(void *params) {
struct list_param *list_param;

list_param = (struct list_param *)params;
list_del_init(list_param->arg[0]);
return NULL;
}

void* cc_list_add(void *params) {
struct list_param *list_param;

list_param = (struct list_param *)params;
list_add(list_param->arg[0], list_param->arg[1]);
return NULL;
}

void* cc_list_add_tail(void *params) {
struct list_param *list_param;

list_param = (struct list_param *)params;
list_add_tail(list_param->arg[0], list_param->arg[1]);
return NULL;
}

void* cc_list_replace(void *params) {
struct list_param *list_param;

list_param = (struct list_param *)params;
list_replace(list_param->arg[0], list_param->arg[1]);
return NULL;
}

void* cc_list_replace_init(void *params) {
struct list_param *list_param;

list_param = (struct list_param *)params;
list_replace_init(list_param->arg[0], list_param->arg[1]);
return NULL;
}
struct list_head cc_head __attribute__((aligned(4096))) = LIST_HEAD_INIT(cc_head);
struct list_head spin_head __attribute__((aligned(4096))) = LIST_HEAD_INIT(spin_head);

#define LIST_LEN 2000
28 changes: 28 additions & 0 deletions lock_module/list_bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
LOCK_PATH=/sys/kernel/debug/lock_benchmark
CPU=$1
BENCH=$2
DELAY=$3

echo $CPU > $LOCK_PATH/cpu
echo $BENCH > $LOCK_PATH/nr_bench
echo $DELAY > $LOCK_PATH/delay

dmesg -c > /dev/null
echo 3 > $LOCK_PATH/trigger
READY=$(cat $LOCK_PATH/ready)
while [ "$READY" -eq 0 ]
do
sleep 1
READY=$(cat $LOCK_PATH/ready)
done

echo 4 > $LOCK_PATH/trigger
READY=$(cat $LOCK_PATH/ready)
while [ "$READY" -eq 0 ]
do
sleep 1
READY=$(cat $LOCK_PATH/ready)
done

python3 parse_dmesg_list.py $1 >> result

Loading