From: luca abeni <luca.abeni@santannapisa.it>
To: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Juri Lelli <juri.lelli@arm.com>,
Tommaso Cucinotta <tommaso.cucinotta@sssup.it>,
Mike Galbraith <efault@gmx.de>,
Romulo Silva de Oliveira <romulo.deoliveira@ufsc.br>
Subject: Re: [PATCH 3/2] sched/deadline: Use deadline instead of period when calculating overflow
Date: Tue, 14 Feb 2017 23:49:26 +0100 [thread overview]
Message-ID: <20170214234926.6b415428@sweethome> (raw)
In-Reply-To: <20170214142848.4e62a91f@gandalf.local.home>
Hi Steven,
On Tue, 14 Feb 2017 14:28:48 -0500
"Steven Rostedt (VMware)" <rostedt@goodmis.org> wrote:
> I was testing Daniel's changes with his test case, and tweaked it a
> little. Instead of having the runtime equal to the deadline, I
> increased the deadline ten fold.
>
> Daniel's test case had:
>
> attr.sched_runtime = 2 * 1000 * 1000; /* 2 ms
> */ attr.sched_deadline = 2 * 1000 * 1000; /* 2 ms */
> attr.sched_period = 2 * 1000 * 1000 * 1000; /* 2 s */
>
> To make it more interesting, I changed it to:
>
> attr.sched_runtime = 2 * 1000 * 1000; /* 2
> ms */ attr.sched_deadline = 20 * 1000 * 1000; /* 20 ms
> */ attr.sched_period = 2 * 1000 * 1000 * 1000; /* 2 s */
>
>
> The results were rather surprising. The behavior that Daniel's patch
> was fixing came back. The task started using much more than .1% of the
> CPU. More like 20%.
>
> Looking into this I found that it was due to the dl_entity_overflow()
> constantly returning true. That's because it uses the relative period
> against relative runtime vs the absolute deadline against absolute
> runtime.
>
> runtime / (deadline - t) > dl_runtime / dl_period
I agree that there is an inconsistency here (again, using equations
from the "period=deadline" case with a relative deadline different from
period).
I am not sure about the correct fix (wouldn't
"runtime / (deadline - t) > dl_runtime / dl_deadline" allow the task to
use a fraction of CPU time equal to dl_runtime / dl_deadline?)
The current code is clearly wrong (as shown by Daniel), but I do not
understand how the current check can allow the task to consume more
than dl_runtime / dl_period... I need some more time to think about
this issue.
Luca
>
> There's even a comment mentioning this, and saying that when relative
> deadline equals relative period, that the equation is the same as
> using deadline instead of period. That comment is backwards! What we
> really want is:
>
> runtime / (deadline - t) > dl_runtime / dl_deadline
>
> We care about if the runtime can make its deadline, not its period.
> And then we can say "when the deadline equals the period, the
> equation is the same as using dl_period instead of dl_deadline".
>
> After correcting this, now when the task gets enqueued, it can
> throttle correctly, and Daniel's fix to the throttling of sleeping
> deadline tasks works even when the runtime and deadline are not the
> same.
>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
> Index: linux-trace.git/kernel/sched/deadline.c
> ===================================================================
> --- linux-trace.git.orig/kernel/sched/deadline.c
> +++ linux-trace.git/kernel/sched/deadline.c
> @@ -445,13 +445,13 @@ static void replenish_dl_entity(struct s
> *
> * This function returns true if:
> *
> - * runtime / (deadline - t) > dl_runtime / dl_period ,
> + * runtime / (deadline - t) > dl_runtime / dl_deadline ,
> *
> * IOW we can't recycle current parameters.
> *
> - * Notice that the bandwidth check is done against the period. For
> + * Notice that the bandwidth check is done against the deadline. For
> * task with deadline equal to period this is the same of using
> - * dl_deadline instead of dl_period in the equation above.
> + * dl_period instead of dl_deadline in the equation above.
> */
> static bool dl_entity_overflow(struct sched_dl_entity *dl_se,
> struct sched_dl_entity *pi_se, u64 t)
> @@ -476,7 +476,7 @@ static bool dl_entity_overflow(struct sc
> * of anything below microseconds resolution is actually
> fiction
> * (but still we want to give the user that illusion >;).
> */
> - left = (pi_se->dl_period >> DL_SCALE) * (dl_se->runtime >>
> DL_SCALE);
> + left = (pi_se->dl_deadline >> DL_SCALE) * (dl_se->runtime >>
> DL_SCALE); right = ((dl_se->deadline - t) >> DL_SCALE) *
> (pi_se->dl_runtime >> DL_SCALE);
>
next prev parent reply other threads:[~2017-02-14 22:49 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-13 19:05 [PATCH V2 0/2] sched/deadline: Fixes for constrained deadline tasks Daniel Bristot de Oliveira
2017-02-13 19:05 ` [PATCH V2 1/2] sched/deadline: Replenishment timer should fire in the next period Daniel Bristot de Oliveira
2017-02-13 19:05 ` [PATCH V2 2/2] sched/deadline: Throttle a constrained deadline task activated after the deadline Daniel Bristot de Oliveira
2017-02-14 15:54 ` Tommaso Cucinotta
2017-02-14 17:31 ` Daniel Bristot de Oliveira
2017-02-14 19:33 ` Steven Rostedt
2017-02-14 19:28 ` [PATCH 3/2] sched/deadline: Use deadline instead of period when calculating overflow Steven Rostedt (VMware)
2017-02-14 22:49 ` luca abeni [this message]
2017-02-15 0:14 ` Steven Rostedt
2017-02-15 7:40 ` Luca Abeni
2017-02-15 10:29 ` Juri Lelli
2017-02-15 11:32 ` Peter Zijlstra
2017-02-15 12:31 ` Luca Abeni
2017-02-15 12:59 ` Juri Lelli
2017-02-15 13:13 ` Luca Abeni
2017-02-15 14:15 ` Juri Lelli
2017-02-15 13:33 ` Daniel Bristot de Oliveira
2017-02-15 13:42 ` Daniel Bristot de Oliveira
2017-02-15 14:09 ` Steven Rostedt
2017-02-15 14:16 ` Juri Lelli
2017-02-16 16:36 ` Tommaso Cucinotta
2017-02-16 16:47 ` Steven Rostedt
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=20170214234926.6b415428@sweethome \
--to=luca.abeni@santannapisa.it \
--cc=bristot@redhat.com \
--cc=efault@gmx.de \
--cc=juri.lelli@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=romulo.deoliveira@ufsc.br \
--cc=rostedt@goodmis.org \
--cc=tommaso.cucinotta@sssup.it \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.