On 9/7/05, Kristis Makris <mkgnu@xxxxxxx> wrote: > Hello, > > I'm trying to kill a kernel thread gracefully, in particular kswapd, > without any success. > > The goal is to start another kernel thread that contains updated kswapd > functionality, through a loadable module; no kernel recompilation. > > I noticed that kernel threads block SIGKILL. Hence, on module load I'm > running: > > task = find_task_by_name("kswapd"); > if (task != NULL) { > spin_lock_irq(&task->sigmask_lock); > sigdelset(&task->blocked, SIGKILL); > recalc_sigpending(task); > spin_unlock_irq(&task->sigmask_lock); > // Also tried issuing here a: kill_proc(task->pid, SIGKILL, 1); > } > > Then from userspace I issue: > > # ps aux |grep -i swap > root 4 0.0 0.0 0 0 ? SW 18:36 0:00 [kswapd] > $ kill -9 4 > > After the kill is issued, kswapd taking up 99.9% of CPU time and remains > at a runnable state: > # ps aux |grep -i swap > root 4 0.2 0.0 0 0 ? RW 18:36 0:02 [kswapd] > > > Can anyone explain why this is happening ? I've tried this with linux > kernels 2.2.19 and 2.4.27 (with patch kdb-4.3). I don't think that kswapd can be killed by loading modules or after when it started during boot time ..... As I havn't saw any break or getting kill or other signals in the code of kswapd, this means that when it goes into for(;;) loop it won't break out of it through any killing signal send from outside. I may be wrong b/c I havn't worked on it but telling what I can get by just seeing on the code of kswapd fucntion. > What is the proper way of gracefully killing a kernel thread launched from the original kernel > image (not a module) in kernels < 2.6 (ie. without the new kernel thread > API that contains the stop_kthread call from > http://www.scs.ch/~frey/linux/kernelthreads.html) > I m not able to understand what you want to ask !!!! -- Fawad Lateef -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/