2005-01-10 10:28:45

by Jan Engelhardt

[permalink] [raw]
Subject: keventd gives exceptional priority to usermode helpers

Hi,


on SUSE 9.2, we experienced that plugging in an USB stick slows the system
down considerably. In the end, I tracked (one half of the problem) down to
kernelspace, where keventd starts the /sbin/hotplug usermode helper with
priority -20. This is bad because hotplug, udev or the programs that ship with
the whole hotplug subsystem (possibly including SUSE's own scripts) require
some CPU -- and with nice -20 get it definitely.

keventd itself should stay at nice level -20, since it also spawns kreiserfsd,
just to name one. So the (attached) patch reprioritizes *user*mode
helpers/tasks back to nice 0.

Signed-off-by: Jan Engelhardt <[email protected]>



Jan Engelhardt
--
ENOSPC


Attachments:
renice_keventd_usermode.diff (1.24 kB)

2005-01-10 11:42:08

by Chris Wright

[permalink] [raw]
Subject: Re: keventd gives exceptional priority to usermode helpers

* Jan Engelhardt ([email protected]) wrote:
> --- usr_A/src/kotd/linux-2.6.8-20041204030200/kernel/kmod.c 2004-12-06 14:28:44.000000000 +0100
> +++ usr_B/src/kotd/linux-2.6.8-20041204030200/kernel/kmod.c 2005-01-06 11:44:04.130600000 +0100
> @@ -165,6 +165,7 @@ static int ____call_usermodehelper(void
>
> /* We can run anywhere, unlike our parent keventd(). */
> set_cpus_allowed(current, CPU_MASK_ALL);
> + set_user_nice(current, 0);

Seems reasonable. Although, I don't see a niceval of -20, but -5 on
keventd (workqueues do set_user_nice(-5)). Also, this patch is
whitespace damaged, should be tab not spaces.

thanks,
-chris
--
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net

2005-01-10 11:51:05

by Jan Engelhardt

[permalink] [raw]
Subject: Re: keventd gives exceptional priority to usermode helpers

>> @@ -165,6 +165,7 @@ static int ____call_usermodehelper(void
>>
>> /* We can run anywhere, unlike our parent keventd(). */
>> set_cpus_allowed(current, CPU_MASK_ALL);
>> + set_user_nice(current, 0);
>
>Seems reasonable. Although, I don't see a niceval of -20, but -5 on
>keventd (workqueues do set_user_nice(-5)). Also, this patch is

Right, `ps` only shows "<" for <0, "" for 0 and "N" for >0. But -5 is still a
hard thing.

>whitespace damaged, should be tab not spaces.

the neverending debate...



Jan Engelhardt
--
ENOSPC

2005-01-11 12:12:11

by Jan Engelhardt

[permalink] [raw]
Subject: Re: keventd gives exceptional priority to usermode helpers

Signed-off-by: Jan Engelhardt <[email protected]>


--- linux-2.6.8-20041204030200/kernel/kmod.c 2004-12-06 14:28:44.000000000 +0100
+++ linux-2.6.8-20041204030200/kernel/kmod.c 2005-01-06 11:44:04.130600000 +0100
@@ -165,6 +165,7 @@ static int ____call_usermodehelper(void

/* We can run anywhere, unlike our parent keventd(). */
set_cpus_allowed(current, CPU_MASK_ALL);
+ set_user_nice(current, 0);

retval = -EPERM;
if (current->fs->root)




Jan Engelhardt
--
ENOSPC


Attachments:
renice_keventd_usermode.diff (1.17 kB)