Re: [PATCH 1/3] sched: add sched_task_call()

Vojtech Pavlik
2015-02-19T17:48:24Z

On February 19, 2015 6:32:55 PM CET, Josh Poimboeuf <jpoimboe@redhat.com> wrote:

>> Yes. I'm saying that rather than guaranteeing they don't enter the
>> kernel (by having them spin) you can flip them in case they try to do
>> that instead. That solves the race condition just as well.
>
>Ok, gotcha.
>
>We'd still need a safe way to check if they're in user space though.
>
>How about with a TIF_IN_USERSPACE thread flag? It could be cleared/set
>right at the border. Then for running tasks it's as simple as:
>
>if (test_tsk_thread_flag(task, TIF_IN_USERSPACE))
> klp_switch_task_universe(task);

The s390x arch used to have a TIF_SYSCALL, which was doing exactly that (well, negated). I think it would work well, but it isn't entirely for free: two instructions per syscall and an extra TIF bit, which are (near) exhausted on some archs.

--
Vojtech Pavlik
Director SuSE Labs