From owner-freebsd-hackers@FreeBSD.ORG Wed Sep 3 09:57:05 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B1C5F106567B for ; Wed, 3 Sep 2008 09:57:05 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.24]) by mx1.freebsd.org (Postfix) with ESMTP id 398E18FC16 for ; Wed, 3 Sep 2008 09:57:04 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: by ey-out-2122.google.com with SMTP id 6so1116795eyi.7 for ; Wed, 03 Sep 2008 02:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:date:from:to:cc :subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:sender; bh=CkSim9BCFhJSDFT/dFlKCWL+gSaeEl3vS6fRlHhzKrE=; b=nhHTlU/asK/cH/NGsSEjscMKN4qi1I/WKrS5Nd7nfCOOt5oVdyq3sLhGQrXJKDVj2r v0x+A+Vpwo/H6l9WyvwtKsB9l/LwsBlnIBKnc2eTxPi9RxMf1QKkQsemAwihCQoFsiFB S4kn7N7XmFqOwdEpz5SndSemLMpQPXi9EKgVU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent:sender; b=Turb2Ytirvj8Mhj9YkGXJTJQcqmBxIUlvaSgVP91y8lxlvQBpb2d2cG+6oxEM/4VSf eHD4oJo7XlDq0pyOGjtA79zf2SHfPDDJjgnH5ajaP30bU62xbOc5XfhwvJ2dy4Jza+u2 tWgMCGYU+EYgaPZAj8BFbGg8vgEmGK9V1+/e4= Received: by 10.210.47.7 with SMTP id u7mr9808712ebu.165.1220435823811; Wed, 03 Sep 2008 02:57:03 -0700 (PDT) Received: from alpha.local ( [83.144.140.92]) by mx.google.com with ESMTPS id f13sm1555540gvd.10.2008.09.03.02.57.02 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 03 Sep 2008 02:57:02 -0700 (PDT) Received: by alpha.local (Postfix, from userid 1001) id 13769F2EE; Wed, 3 Sep 2008 10:56:06 +0100 (WEST) Date: Wed, 3 Sep 2008 10:56:06 +0100 From: Rui Paulo To: kr Lekha Message-ID: <20080903095605.GB21178@alpha.local> References: <96b2ec350809030134j73a61369m35395391a1218975@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <96b2ec350809030134j73a61369m35395391a1218975@mail.gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: Rui Paulo Cc: freebsd-hackers@freebsd.org Subject: Re: killing a kthread X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Sep 2008 09:57:05 -0000 On Wed, Sep 03, 2008 at 09:34:47AM +0100, 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. > Does scheduler take care to killing it? > > I read that after 2 min scheduler wakes up the thread and > eventually kills it, > i see the same kthread suspended even after a day > > I would appreciate any thoughts in this reagard. > Thanks, When the thread finishes what it's doing, it should call kthread_exit(). Regards, -- Rui Paulo