From: seantywork Date: Fri, 19 Sep 2025 00:04:32 +0000 (+0000) Subject: name change for thread rcu X-Git-Url: https://git.feebdaed.xyz/?a=commitdiff_plain;h=b8d7950e68a943fa8add70dbf5eff4db6f65ac25;p=linuxyz.git name change for thread rcu --- diff --git a/krcu-deadly/Makefile b/krcu-deadly/Makefile deleted file mode 100644 index ec3c2d2..0000000 --- a/krcu-deadly/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -obj-m := rcudeadly.o - -all: -ifneq ($(IACCEPTITWILLKILLKERNEL),y) - @echo "needs 'IACCEPTITWILLKILLKERNEL=y' specified" - @exit 1 -endif - make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) modules -clean: - make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) clean \ No newline at end of file diff --git a/krcu-deadly/README.md b/krcu-deadly/README.md deleted file mode 100644 index 136000e..0000000 --- a/krcu-deadly/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# kernel-rcu-deadly - -- source: [linuxyz/krcu-deadly](https://github.com/seantywork/linuxyz/tree/main/krcu-deadly) -- date: 2509- - diff --git a/krcu-deadly/rcudeadly.c b/krcu-deadly/rcudeadly.c index 23cd927..faa1225 100644 --- a/krcu-deadly/rcudeadly.c +++ b/krcu-deadly/rcudeadly.c @@ -11,6 +11,11 @@ #define OP_COUNT 10 +struct + +static LIST_HEAD(); +static spinlock_t + static struct task_struct *task_write; static struct task_struct *task_read; static int w = 10; diff --git a/kthread-rcu/Makefile b/kthread-rcu/Makefile new file mode 100644 index 0000000..37a38c4 --- /dev/null +++ b/kthread-rcu/Makefile @@ -0,0 +1,6 @@ +obj-m := threadrcu.o + +all: + make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) modules +clean: + make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) clean \ No newline at end of file diff --git a/kthread-rcu/README.md b/kthread-rcu/README.md new file mode 100644 index 0000000..c7848a2 --- /dev/null +++ b/kthread-rcu/README.md @@ -0,0 +1,5 @@ +# kernel-thread-rcu + +- source: [linuxyz/kthread-rcu](https://github.com/seantywork/linuxyz/tree/main/kthread-rcu) +- date: 2509- + diff --git a/kthread-rcu/threadrcu.c b/kthread-rcu/threadrcu.c new file mode 100644 index 0000000..2173ac8 --- /dev/null +++ b/kthread-rcu/threadrcu.c @@ -0,0 +1,86 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define OP_COUNT 10 + +struct myelement { + + struct list_head node; + struct rcu_head rcu; +}; + +static LIST_HEAD(myelements); +static spinlock_t myelements_lock; + +static struct task_struct *task_write; +static struct task_struct *task_read; +static int w = 10; +static int r = 11; + +static int task_writer(void *arg){ + + int v = *(int *)arg; + + for(int i = 0; i < OP_COUNT; i++){ + printk(KERN_INFO "rcudeadly: v: %d: w: %d\n", v, i); + mdelay(1000); + } + + return 0; +} + +static int task_reader(void *arg){ + + int v = *(int *)arg; + + for(int i = 0; i < OP_COUNT; i++){ + printk(KERN_INFO "rcudeadly: v: %d: r: %d\n", v, i); + mdelay(1000); + } + + return 0; +} + + +static int __init rcu_deadly_init(void){ + + spin_lock_init(&myelements_lock); + + task_write = kthread_run(task_writer, (void*)&w, "tw/%d", w); + if(IS_ERR(task_write)){ + printk(KERN_ERR "rcudeadly: failed to create task_write thread\n"); + return -1; + } + task_read = kthread_run(task_reader, (void*)&r, "tr/%d", r); + if(IS_ERR(task_read)){ + printk(KERN_ERR "rcudeadly: failed to create task_read thread\n"); + return -1; + } + get_task_struct(task_write); + get_task_struct(task_read); + + printk(KERN_INFO "rcudeadly: loaded\n"); + + return 0; +} + +static void __exit rcu_deadly_exit(void){ + kthread_stop(task_write); + kthread_stop(task_read); + + printk(KERN_INFO "rcudeadly: unloaded\n"); + +} + +module_init(rcu_deadly_init); +module_exit(rcu_deadly_exit); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("seantywork"); \ No newline at end of file