Re: [RFC] [PATCH] Pre-emption control for userspace

From: Khalid Aziz
Date: Tue Mar 04 2014 - 16:41:20 EST


On 03/04/2014 02:12 PM, H. Peter Anvin wrote:

Shades of the Android wakelocks, no?

This seems to effectively give userspace an option to turn preemptive
multitasking into cooperative multitasking, which of course is
unacceptable for a privileged process (the same reason why unprivileged
processes aren't allowed to run at above-normal priority, including RT
priority.)

I have several issues with this interface:

1. First, a process needs to know if it *should* have been preempted
before it calls sched_yield(). So there needs to be a second flag set
by the scheduler when granting amnesty.

Good idea. I like it. I will add it.


2. A process which fails to call sched_yield() after being granted
amnesty must be penalized.

I agree. Is it fair to say that such a process sees the penalty by being charged that extra timeslice and being pushed to the right side of RB tree since its p->se.vruntime would have gone up, which then delays the time when it can get CPU again? I am open to adding a more explicit penalty - maybe deny its next preemption delay request if it failed to call sched_yield() the last time when it should have?


3. I'm not keen on occupying a full page for this. I'm wondering if
doing a pointer into user space, futex-style, might make more sense.
The downside, of course, is what happens if the page being pointed to is
swapped out.

Using a full page for what is effectively a single bit flag does not sit well with me either. Doing it through proc forces minimum size of a page (please correct me there if I am wrong). I will explore your idea some more to see if that can be made to work.


Keep in mind this HAS to be per thread.


Thanks, hpa!

--
Khalid

--
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/