From owner-freebsd-current@FreeBSD.ORG Mon Sep 8 21:30:55 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 49A5910656C0 for ; Mon, 8 Sep 2008 21:30:55 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id DFA9A8FC27 for ; Mon, 8 Sep 2008 21:30:54 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from zion.baldwin.cx (zion.baldwin.cx [IPv6:2001:470:1f11:75:2a0:d2ff:fe18:8b38]) (authenticated bits=0) by server.baldwin.cx (8.14.2/8.14.2) with ESMTP id m88LUZtS096483; Mon, 8 Sep 2008 17:30:48 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-current@freebsd.org Date: Mon, 8 Sep 2008 17:26:12 -0400 User-Agent: KMail/1.9.7 References: <96b2ec350809030232v5586ea44nf6ead7d856f72634@mail.gmail.com> In-Reply-To: <96b2ec350809030232v5586ea44nf6ead7d856f72634@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200809081726.13043.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [IPv6:2001:470:1f11:75::1]); Mon, 08 Sep 2008 17:30:49 -0400 (EDT) X-Virus-Scanned: ClamAV 0.93.1/8162/Thu Sep 4 12:38:45 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00,NO_RELAYS autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: kr Lekha Subject: Re: Kthread kill X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Sep 2008 21:30:55 -0000 On Wednesday 03 September 2008 05:32:00 am kr Lekha wrote: > Hi, > i wanted to kill a kthread created by my module, There is no actual > kthread_kill to kill it > > hence I tried to send kill signal to thread > psignal(p, SIGTERM); > psignal(p, SIGKILL); > killproc(p,"messeage"); > and kthread_suspend() > > Nothing seems to be killing the kthread, I still see it > [root@ /usr/src]# ps awx -l | grep kernel > UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME > COMMAND 0 1048 1 0 20 0 0 8 ktsusp > DL ?? 0:00.01 [new_kernel_thread] > > > I have noticed that generally if kernel module wanted to kill a thread then > it calls > { > wakeup(p); > msleep(p,0); /*or tsleep*/ > } > > This puts the thread to sleep forever. However kthread_suspend also > performs same actions. Your kthread has to explicitly check for a kill request in its main loop and call kthread_exit() or some such. There is no force-kill for kthreads. -- John Baldwin