Re: [RFC PATCH 07/11] sched: Add proxy execution

From: Qais Yousef
Date: Mon Oct 24 2022 - 20:15:15 EST


On 10/17/22 09:26, Peter Zijlstra wrote:

> Additionally, the highest priotiy waiter will get the lock next.

True for RT. But for CFS, priority is share and there will be no guarantee the
'highest priority' task will run as soon as the lock is released to grab it,
no?

For example I can envisage:

+--------+----------------+--------+--------
| p0 | p1 | p0 | p1
+--------+----------------+--------+--------
^ ^ ^ ^ ^
| | | | |
| | | | Fails to hold the lock
holds lock releases lock | and proxy execs for p0 again
| |
| |
tries to hold lock holds lock again
proxy execs for p0

The notion of priority in CFS as it stands doesn't help in providing any
guarantees in who will be able to hold the lock next. I haven't looked at the
patches closely, so this might be handled already. I think the situation will
be worse if there're more tasks contending for the lock. Priority will
influences the chances, but the end result who holds the lock next is
effectively random, AFAICT.

I had a conversation once with an app developer who came from iOS world and
they were confused why their higher priority task is not preempting the lower
priority one when they ported it to Android.

I wonder sometimes if we need to introduce a true notion of priority for CFS.
I don't see why an app developer who would like to create 3 tasks and give them
strict priority order relative to each others can't do that. At the moment they
have little option in controlling execution order.

Actually I think we need two types of priorities:

* global priorities for a sys admin to say which apps are more
important to run over other apps. Or fairly share it if
equal priority.
* local priorities for an app to control which of its tasks are more
important to run over other tasks it owns.

The concept of share doesn't allow controlling execution order - and forces us
to look at things like latency_nice to, somewhat, overcome this limitation.


Thanks

--
Qais Yousef