mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Nish Aravamudan <nish.aravamudan@gmail.com>
Cc: stern@rowland.harvard.edu, arvidjaar@mail.ru,
	linux-usb-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [linux-usb-devel] init 1 kill khubd on 2.6.11
Date: Sun, 1 May 2005 15:55:35 -0700	[thread overview]
Message-ID: <20050501155535.3855d31f.akpm@osdl.org> (raw)
In-Reply-To: <29495f1d050501154625ee7087@mail.gmail.com>

Nish Aravamudan <nish.aravamudan@gmail.com> wrote:
>
> > -       /* Send me a signal to get me die (for debugging) */
> >         do {
> >                 hub_events();
> > -               wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list));
> > +               wait_event_interruptible(khubd_wait,
> > +                               !list_empty(&hub_event_list) ||
> > +                               kthread_should_stop());
> >                 try_to_freeze(PF_FREEZE);
> > -       } while (!signal_pending(current));
> > +       } while (!kthread_should_stop() || !list_empty(&hub_event_list));
> 
> Shouldn't this simply be a wait_event(), instead of
> wait_event_interruptible()?

That would cause uninterruptible sleep, which contributes to load average.

> Then the do-while() can be gotten rid of,
> as the only reason it is there currently, I guess, is to ignore
> signals?

Nope, the do-while is a basic part of the daemon's operation: keep doing
stuff until either there's no stuff to do or until we're told to exit.

> Also, the while's conditional should be (!kthread_should_stop() ||
> list_empty(&hub_event_list) to match the negation of wait_event's?
> (wait_event() expects the condition to stop on, while while() expects
> the condition to continue on)

Nope, the wait_event_interruptible test says

  "sleep unless the list is not empty or I am being asked to exit"

the while termination test says

  "loop until the list is empty and I am being asked to stop".

I think.  I had to scratch my head for a while over that code ;)

  reply	other threads:[~2005-05-01 22:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-01 16:21 Andrey Borzenkov
2005-05-01 21:01 ` [linux-usb-devel] " Alan Stern
2005-05-01 21:21   ` Lee Revell
2005-05-01 22:30   ` Andrew Morton
2005-05-01 22:46     ` Nish Aravamudan
2005-05-01 22:55       ` Andrew Morton [this message]
2005-05-02  0:42         ` Nish Aravamudan
2005-05-02  0:31       ` Dmitry Torokhov
2005-05-02  8:00     ` Andrey Borzenkov
2005-05-02  9:30       ` Andrew Morton
2005-05-02 12:18         ` Andrey Borzenkov
2005-05-02 17:58           ` Andrey Borzenkov

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=20050501155535.3855d31f.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=arvidjaar@mail.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=nish.aravamudan@gmail.com \
    --cc=stern@rowland.harvard.edu \
    /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®