On 5/1/05, Andrew Morton <[EMAIL PROTECTED]> wrote:
> Alan Stern <[EMAIL PROTECTED]> wrote:
> >
> > On Sun, 1 May 2005, Andrey Borzenkov wrote:
> >
> > > Hub driver is using SIGKILL to terminate khubd. Unfortunately on a number 
> > > of
> > > distributions switching init levels implicitly does "killall -9", killing
> > > khubd. The only way to restart it is to reload USB subsystem.
> > >
> > > Is signal usage in this case really needed? What about replacing it with
> > > simple flag (i.e. will patch be accepted)?
> >
> > IMO the problem lies in those distributions.  They should not
> > indiscrimately kill processes when switching init levels.
> 
> Nevertheless it's better that kernel internals not be exposed to userspace
> actions in this manner, and using signals for in-kernel IPC is crufty, IMO.
> 
> It's pretty simple to convert khubd to use the kthread API.  Something like
> this (untested):
> 
>  drivers/usb/core/hub.c |   40 +++++++++++-----------------------------
>  1 files changed, 11 insertions(+), 29 deletions(-)
> 
> diff -puN drivers/usb/core/hub.c~hub-use-kthread drivers/usb/core/hub.c
> --- 25/drivers/usb/core/hub.c~hub-use-kthread   2005-05-01 15:22:24.634539928 
> -0700
> +++ 25-akpm/drivers/usb/core/hub.c      2005-05-01 15:29:55.739961480 -0700

<snip>

>  static int hub_thread(void *__unused)

<snip>

> -       /* 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()? Then the do-while() can be gotten rid of,
as the only reason it is there currently, I guess, is to ignore
signals?

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)

Thanks,
Nish


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r 
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to