Re: allow non root users to set io priority "idle" ?

From: Andi Kleen
Date: Mon Aug 06 2007 - 06:16:46 EST


dragoran <drago01@xxxxxxxxx> writes:

> Its possible to set the io priority using tools like ionice and syscalls.
> But this works only as root.
> Why can't a non root user change the priority of his processes to idle?
> I understand that realtime priority requires root but why idle?
> For instance the beagle trys to set its priority to idle but fails
> because it does not run as root.
> Any reason for this that I have missed? I can't think of a case where
> setting the io priority to idle would have a negative impact for other
> users or the whole system.

Very low priority can starve others when it holds some kernel resource
needed by another task.

Consider three tasks: one very low priority, one high priority: Low
priority task holds some kernel resource, middle task eats as much CPU
as it gets; high priority task wants to get the resource. High
priority will need to wait for low running, which could take a long
time. With true SCHED_IDLE (i believe the current implementation is
not true) this could be never or at least a very long time.

There are ways to defend against this problem (known as priority inheritance),
but the kernel doesn't do them consistently. The same issue could also
happen for user space managed resources.

For IO I suppose the same could happen too. e.g. low priority
task wants to write out a page and keeps it locked until the IO
is finished. High priority task wants to access the page and has
to wait until it is unlocked. Middle task generates an endless
stream of IO that makes the idle priority writeout never finish.

In general idle priorities are quite risky, even for root.

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/