mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	bristot@redhat.com, vschneid@redhat.com,
	linux-kernel@vger.kernel.org, parth@linux.ibm.com,
	qais.yousef@arm.com, chris.hyser@oracle.com,
	valentin.schneider@arm.com, patrick.bellasi@matbug.net,
	David.Laight@aculab.com, pjt@google.com, pavel@ucw.cz,
	tj@kernel.org, qperret@google.com, tim.c.chen@linux.intel.com,
	joshdon@google.com
Subject: Re: [PATCH v4 5/8] sched/fair: Take into account latency priority at wakeup
Date: Thu, 22 Sep 2022 00:41:40 +0200	[thread overview]
Message-ID: <04c65f4f-5072-2a07-cbe0-63046a7bc58f@arm.com> (raw)
In-Reply-To: <CAKfTPtDvWsq8YUEzK=xm+S22p=f1kR87a4hT38Ni_t4ZfZ0Zag@mail.gmail.com>

On 20/09/2022 17:49, Vincent Guittot wrote:
> On Tue, 20 Sept 2022 at 15:18, Dietmar Eggemann
> <dietmar.eggemann@arm.com> wrote:
>>
>> On 19/09/2022 17:39, Vincent Guittot wrote:
>>> On Mon, 19 Sept 2022 at 12:05, Dietmar Eggemann
>>> <dietmar.eggemann@arm.com> wrote:
>>>>
>>>> On 16/09/2022 10:03, Vincent Guittot wrote:

[...]

>>>>> +      * the idle thread and don't set next buddy as a candidate for being
>>>>> +      * picked in priority.
>>>>> +      * In case of simultaneous wakeup from idle, the latency sensitive tasks
>>>>> +      * lost opportunity to preempt non sensitive tasks which woke up
>>>>> +      * simultaneously.
>>>>> +      */
>>>>
>>>> The position of this comment block within this function is somehow
>>>> misleading since it describes the reason for the function rather then a
>>>> particular condition within this function. Wouldn't it be more readable
>>>> when it would be a function header comment instead?
>>>
>>> I put it after the usual early return tests to put the comment close
>>> to the useful part: the use of next buddy and __pick_first_entity()
>>
>> So you want to have the `wakeup_preempt_entity(se, pse) == 1` condition
>> from check_preempt_wakeup() also for cfs_task woken up by others.
> 
> I wake the wakeup_preempt_entity(cfs_rq->next, left) < 1 in
> pick_next_entity() to pick the task with highest latency constraint
> when another class is running while waking up

That's correct. This is where you potentially pick this task since it is
the next_buddy.
All I wanted to say is that check_preempt_from_others() and its `next &&
wakeup_preempt_entity(next, se) == 1` is the counterpart of the
`wakeup_preempt_entity(se, pse) == 1` in check_preempt_wakeup() to be
able to set next_buddy even curr is from an other class than CFS.

[...]

>>>> I still don't get the rationale behind why when either one (se or curr)
>>>> of the latency_nice values is negative, we use the diff between them but
>>>> if not, we only care about se's value. Why don't you always use the diff
>>>> between se and curr? Since we have a range [-20 ... 19] why shouldn't we
>>>> use the difference between let's say se = 19 and curr = 5?
>>>> You discussed this with Tao Zhou on the v1 but I didn't understand it fully.
>>>
>>> Let say that current has a latency nice prio of 19 and a task A with a
>>> latency nice of 10 wakes up. Both tasks don't care about scheduling
>>> latency (current more than task A). If we use the diff, the output of
>>> wakeup_latency_gran() would be negative (-10ms) which reflects the
>>> fact that the waking task is sensitive to the latency and wants to
>>> preempt current even if its vruntime is after. But obviously both
>>> current and task A don't care to preempt at wakeup.
>>
>> OK, I understand but there is a certain level of unsteadiness here.
>>
>> If p has >0 it gets treated differently in case current has >=0 and case
> 
> "If p >=0"; 0 has same behavior than [1..19]
> 
>> current has <0.

Not quite. It depends on curr. With sysctl_sched_latency = 24ms:

(1) p = 10 curr =  19 -> wakeup_latency_gran() returns 12ms

(2) p = 10 curr = -10 -> wakeup_latency_gran() returns 24ms

In (1) only p's own latency counts whereas in (2) we take the diff,

In (A) we 'punish' p even though it competes against curr which has an
even lower latency requirement than p,

>> Do we expect that tasks set their value to [1..19] in this case, when
>> the default 0 already indicates a 'don't care'?
> 
> I'm not sure that I understand your concern as [0..19] are treated in
> the same way. Only tasks (curr or se) with offset <0 need a relative
> comparison to the other. If curr and se has both a latency nice of
> -19, se should not blindly preempt curr but only if curr already run
> for its amount of time

With p = -19 and curr = -19 we would take the diff, so 0ms.

With p = 19 and curr = 19, if we would use `latency_offset -=
curr->latency_offset` wakeup_latency_gran() would return 973/1024*24ms -
973/1024*24ms = 0ms and nothing will shift.

OTHA, in case (1) wakeup_latency_gran() would return 512/1024*24ms -
973/1024*24ms = - 10.80ms. So p would gain an advantage here instead of
a penalty.

Essentially using the full [-20 .. 19] nice scope for `se vs. curr`
comparison.

  reply	other threads:[~2022-09-21 22:41 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16  8:02 [PATCH v4 0/8] Add latency priority for CFS class Vincent Guittot
2022-09-16  8:02 ` [PATCH v4 1/8] sched: Introduce latency-nice as a per-task attribute Vincent Guittot
2022-09-16  8:02 ` [PATCH v4 2/8] sched/core: Propagate parent task's latency requirements to the child task Vincent Guittot
2022-09-16  8:03 ` [PATCH v4 3/8] sched: Allow sched_{get,set}attr to change latency_nice of the task Vincent Guittot
2022-09-16  8:03 ` [PATCH v4 4/8] sched/core: Add permission checks for setting the latency_nice value Vincent Guittot
2022-09-19  8:52   ` timj
2022-09-19  8:52     ` timj
2022-09-19 12:41     ` Vincent Guittot
2022-09-20 10:18       ` Tim Janik
2022-09-20 14:56         ` Vincent Guittot
2022-09-21 16:11           ` Vincent Guittot
2022-09-16  8:03 ` [PATCH v4 5/8] sched/fair: Take into account latency priority at wakeup Vincent Guittot
     [not found]   ` <20220916120245.2951-1-hdanton@sina.com>
2022-09-16 13:36     ` Vincent Guittot
     [not found]       ` <20220917225819.817-1-hdanton@sina.com>
2022-09-18 10:46         ` Vincent Guittot
     [not found]           ` <20220920113238.1176-1-hdanton@sina.com>
2022-09-20 15:17             ` Vincent Guittot
2022-09-19 10:05   ` Dietmar Eggemann
2022-09-19 15:39     ` Vincent Guittot
2022-09-20 13:18       ` Dietmar Eggemann
2022-09-20 15:49         ` Vincent Guittot
2022-09-21 22:41           ` Dietmar Eggemann [this message]
2022-09-22  7:12             ` Vincent Guittot
2022-09-22 16:50               ` Dietmar Eggemann
2022-09-23  6:01                 ` Vincent Guittot
2022-09-16  8:03 ` [PATCH v4 6/8] sched/fair: Add sched group latency support Vincent Guittot
2022-09-19 11:55   ` Dietmar Eggemann
2022-09-19 15:49     ` Vincent Guittot
2022-09-19 17:34       ` Tejun Heo
2022-09-20  7:03         ` Vincent Guittot
2022-09-21 16:07         ` Qais Yousef
2022-09-21 16:48           ` Tejun Heo
2022-09-21 17:02             ` Vincent Guittot
2022-09-21 17:12               ` Tejun Heo
2022-09-22  6:40                 ` Vincent Guittot
2022-09-22 10:49                   ` Qais Yousef
2022-09-20 18:17       ` Dietmar Eggemann
2022-09-21  7:48         ` Vincent Guittot
2022-09-19 17:34     ` Tejun Heo
2022-09-20  7:02       ` Vincent Guittot
2022-09-16  8:03 ` [PATCH v4 7/8] sched/core: support latency priority with sched core Vincent Guittot
2022-09-16  8:03 ` [PATCH v4 8/8] sched/fair: Add latency list Vincent Guittot
2022-09-21 16:08 ` [PATCH v4 0/8] Add latency priority for CFS class Qais Yousef
2022-09-22  7:19   ` Vincent Guittot
2022-09-22 11:00     ` Qais Yousef
2022-09-22 13:03       ` Vincent Guittot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=04c65f4f-5072-2a07-cbe0-63046a7bc58f@arm.com \
    --to=dietmar.eggemann@arm.com \
    --cc=David.Laight@aculab.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=chris.hyser@oracle.com \
    --cc=joshdon@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=parth@linux.ibm.com \
    --cc=patrick.bellasi@matbug.net \
    --cc=pavel@ucw.cz \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    --cc=qais.yousef@arm.com \
    --cc=qperret@google.com \
    --cc=rostedt@goodmis.org \
    --cc=tim.c.chen@linux.intel.com \
    --cc=tj@kernel.org \
    --cc=valentin.schneider@arm.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®