From owner-freebsd-hackers@FreeBSD.ORG Wed Sep 3 12:16:27 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 013CC106567A for ; Wed, 3 Sep 2008 12:16:27 +0000 (UTC) (envelope-from kr.lekha@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.227]) by mx1.freebsd.org (Postfix) with ESMTP id C0FD88FC1C for ; Wed, 3 Sep 2008 12:16:26 +0000 (UTC) (envelope-from kr.lekha@gmail.com) Received: by rv-out-0506.google.com with SMTP id b25so3834433rvf.43 for ; Wed, 03 Sep 2008 05:16:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type:references; bh=a82gXYNMEF2mBmnT5quA2uCaz7C2tJzJukqtAofMXAU=; b=Sr12jOlHvkZLiINJUCuQetD6BgtkbK/32efbhLAw6ug4JURVxv7MDfqbsiSIRzY1vF 251VrkvaRyMDS6XF/fw0d8/dEBNxbBjCLvsPjjs6lx0q5S58m1AcCHn4rpmDVMutuGfv oH1mrxNByajVbz7LlBYzjFbhrwezNkuRpQ5uo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:references; b=RXjzXnE9mz7yhvnZ9l76fx71a1JsEIkR2lZgOT3ngSS8nHcYUXfYDSLw2NscPTfJHm RU0dVvGdGL5XcdgmFLXTLoxwShyHJk7IJkbvnrUCcrdnE9wdB9XA877sz963mEsZMISB 29dGUJCgIjImJZ7MmTWLTYuXa4dG+QT08g5cE= Received: by 10.140.193.16 with SMTP id q16mr4855241rvf.173.1220444186465; Wed, 03 Sep 2008 05:16:26 -0700 (PDT) Received: by 10.141.212.11 with HTTP; Wed, 3 Sep 2008 05:16:26 -0700 (PDT) Message-ID: <96b2ec350809030516y2d6f26d1h3cd7eb39231c4da0@mail.gmail.com> Date: Wed, 3 Sep 2008 13:16:26 +0100 From: "kr Lekha" To: "Rui Paulo" In-Reply-To: <20080903095605.GB21178@alpha.local> MIME-Version: 1.0 References: <96b2ec350809030134j73a61369m35395391a1218975@mail.gmail.com> <20080903095605.GB21178@alpha.local> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 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 12:16:27 -0000 I understand when thread finishes it should call kthread_exit(). but if this thread was suspended before it finished, it might not be able to call kthread_exit(). Due to which we still see the thread suspended. I am unable to kill it even with killproc / psignal with in the kernel module. Thanks, Lekha On 9/3/08, Rui Paulo wrote: > > 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 >