Re: [PATCH 5/16] fix-kthread-niceness.diff

Andrew Morton
2007-04-02T05:40:40Z

On Sun, 1 Apr 2007 20:14:40 +0200 (MEST) Jan Engelhardt <jengelh@linux01.gwdg.de> wrote:

> Fix kevent's childs priority greedy-ness. Such tasks were always scheduled
> at nice level -5 and, at that time, udev stole us the CPU time with -5.
>
> Already posted at http://lkml.org/lkml/2005/1/10/85
>
> Signed-off-by: Jan Engelhardt <jengelh@gmx.de>
> Cc: Chris Wright <chrisw@sous-sol.org>
>
> kmod.c | 1 +
> 1 file changed, 1 insertion(+)
>
> Index: linux-2.6.21-rc5/kernel/kmod.c
> ===================================================================
> --- linux-2.6.21-rc5.orig/kernel/kmod.c
> +++ linux-2.6.21-rc5/kernel/kmod.c
> @@ -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)
> #<EOF>

-ETOOOBSCURE.

--- a/kernel/kmod.c~fix-kthread-nicenessdiff-fix
+++ a/kernel/kmod.c
@@ -163,6 +163,11 @@ static int ____call_usermodehelper(void

/* We can run anywhere, unlike our parent keventd(). */
set_cpus_allowed(current, CPU_MASK_ALL);
+
+ /*
+ * Our parent is keventd, which runs with elevated scheduling priority.
+ * Avoid propagating that into the userspace child.
+ */
set_user_nice(current, 0);

retval = -EPERM;
_