lkml.org 
[lkml]   [2004]   [Jul]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Limit number of concurrent hotplug processes
Andrew Morton wrote:
> Hannes Reinecke <hare@suse.de> wrote:
>
>>the attached patch limits the number of concurrent hotplug processes.
>> Main idea behind it is that currently each call to call_usermodehelper
>> will result in an execve() of "/sbin/hotplug", without any check whether
>> enough resources are available for successful execution. This leads to
>> hotplug being stuck and in worst cases to machines being unable to boot.
>>
>> This check cannot be implemented in userspace as the resources are
>> already taken by the time any resource check can be done; for the same
>> reason any 'slim' programs as /sbin/hotplug will only delay the problem.
>
>
> hm, it's a bit sad that this happens. Are you able to tell us more about
> what is causing such an explosion of module probes?
>
As Christian Borntraeger already said, it's not so much an explosion of
module probes but rather the triggering of quite a lot of events.
Imagine loading scsi_debug with 512 devices or more ...

>
>> Any comments/suggestions welcome; otherwise please apply.
>
>
> I suggest you just use a semaphore, initialised to a suitable value:
>
>
> static struct semaphore foo = __SEMAPHORE_INITIALIZER(foo, 50);
>
>
> {
> ...
> down(&foo);
> ...
> up(&foo);
> ...
> }
>
Hmm; looks good, but: It's not possible to reliably change the maximum
number of processes on the fly.

The trivial way of course it when the waitqueue is empty and no
processes are holding the semaphore. But it's quite non-obvious how this
should work if processes are already holding the semaphore.
We would need to wait for those processes to finish, setting the length
of the queue to 0 (to disallow any other process from grabbing the
semaphore), and atomically set the queue length to the new value.
Apart from the fact that we would need a worker thread for that
(otherwise the calling process might block indefinitely), there is no
guarantee that the queue ever will become empty, as hotplug processes
might be generated at any time.

Or is there an easier way?

Cheers,

Hannes
--
Dr. Hannes Reinecke hare@suse.de
SuSE Linux AG S390 & zSeries
Maxfeldstraße 5 +49 911 74053 688
90409 Nürnberg http://www.suse.de
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:04    [W:3.467 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site