mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: Christoph Hellwig <hch@infradead.org>
Cc: Ben Collins <bcollins@ubuntu.com>,
	"Serge E. Hallyn" <serue@us.ibm.com>,
	weihs@ict.tuwien.ac.at, linux1394-devel@lists.sourceforge.net,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kthread conversion: convert ieee1394 from kernel_thread
Date: Sat, 17 Jun 2006 20:44:26 +0200	[thread overview]
Message-ID: <44944D8A.6090808@s5r6.in-berlin.de> (raw)
In-Reply-To: <20060610183703.GA1497@infradead.org>

Christoph Hellwig wrote on 2006-06-17:
> Below is a draft patch to convert it to the kthread API and replace the
> reset_sem with a simple wake_up_process scheme.  I removed the down_trylock
> loop there which I think should be fine because we get the wakeup again
> ASAP, but please double-check.
[...]
[in nodemgr_host_thread(), top of event loop]
> @@ -1579,15 +1573,14 @@
>  		unsigned int generation = 0;
>  		int i;
>  
> -		if (down_interruptible(&hi->reset_sem) ||
> -		    down_interruptible(&nodemgr_serialize)) {
> +		if (down_interruptible(&nodemgr_serialize)) {

This won't work. "down_interruptible(&hi->reset_sem)" was there to put 
the thread to sleep after it did its work, until the next bus reset. Now 
the event loop would be entered continuously without an actual bus reset 
event.

(nodemgr_serialize is just a mutex disguised as a semaphore which 
prevents multiple nodemgr host threads to enter their event loop 
concurrently.)

>  			if (try_to_freeze())
>  				continue;
>  			printk("NodeMgr: received unexpected signal?!\n" );
>  			break;
>  		}
>  
> -		if (hi->kill_me) {
> +		if (kthread_should_stop()) {
>  			up(&nodemgr_serialize);
>  			break;
>  		}
> @@ -1608,13 +1601,8 @@
>  			 * returning bogus data. */
>  			generation = get_hpsb_generation(host);
>  
> -			/* If we get a reset before we are done waiting, then
> -			 * start the the waiting over again */
> -			while (!down_trylock(&hi->reset_sem))
> -				i = 0;
[...]

Another minor issue: This check cannot be removed without replacement. 
However we could implement this check easily without a counting 
semaphore. (We could check the bus generation before and after the sleep.)

I will try to rework this patch and split it into more patches: One 
which converts nodemgr to the kthread API but keeps the reset_sem, one 
patch which gets rid of the counting semaphore reset_sem, one patch 
which converts nodemgr_serialize to a mutex.

BTW, it may be possible to remove nodemgr_serialize too. There are other 
exclusion mechanisms in nodemgr.c which should already prevent most if 
not all undesirable concurrency, notably the semaphores 
dev->bus->subsys.rwsem and class->subsys.rwsem.
-- 
Stefan Richter
-=====-=-==- -==- =---=
http://arcgraph.de/sr/

  reply	other threads:[~2006-06-17 18:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-10 14:31 Serge E. Hallyn
2006-06-10 14:42 ` Christoph Hellwig
2006-06-10 15:11   ` Stefan Richter
2006-06-10 15:42     ` Christoph Hellwig
2006-06-10 16:34       ` Ben Collins
2006-06-10 16:38         ` Christoph Hellwig
2006-06-10 18:08           ` Ben Collins
2006-06-10 18:37             ` Christoph Hellwig
2006-06-17 18:44               ` Stefan Richter [this message]
2006-06-18 10:29                 ` Stefan Richter
2006-06-18 16:57                 ` [PATCH 2.6.17-rc6-mm2 0/6] ieee1394: nodemgr: misc API conversions Stefan Richter
2006-06-18 16:57                   ` [PATCH 2.6.17-rc6-mm2 1/6] ieee1394: nodemgr: remove unnecessary includes Stefan Richter
2006-06-18 16:59                     ` [PATCH 2.6.17-rc6-mm2 2/6] ieee1394: do not spawn a kernel_thread for user-initiated bus rescan Stefan Richter
2006-06-18 17:00                       ` [PATCH 2.6.17-rc6-mm2 3/6] ieee1394: make module parameter ignore_drivers writable Stefan Richter
2006-06-18 17:02                         ` [PATCH 2.6.17-rc6-mm2 4/6] ieee1394: nodemgr: switch to kthread API Stefan Richter
2006-06-18 17:03                           ` [PATCH 2.6.17-rc6-mm2 5/6] ieee1394: nodemgr: replace reset semaphore Stefan Richter
2006-06-18 17:05                             ` [PATCH 2.6.17-rc6-mm2 6/6] ieee1394: convert nodemgr_serialize semaphore to mutex Stefan Richter
2006-06-10 18:12           ` [PATCH] kthread conversion: convert ieee1394 from kernel_thread Stefan Richter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44944D8A.6090808@s5r6.in-berlin.de \
    --to=stefanr@s5r6.in-berlin.de \
    --cc=bcollins@ubuntu.com \
    --cc=ebiederm@xmission.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux1394-devel@lists.sourceforge.net \
    --cc=serue@us.ibm.com \
    --cc=weihs@ict.tuwien.ac.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®