All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Bristot de Oliveira <bristot@redhat.com>
To: "Joel Fernandes (Google)" <joel@joelfernandes.org>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>
Cc: Suleiman Souhlal <suleiman@google.com>,
	Youssef Esmat <youssefesmat@google.com>,
	David Vernet <void@manifault.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	joseph.salisbury@canonical.com,
	Luca Abeni <luca.abeni@santannapisa.it>,
	Tommaso Cucinotta <tommaso.cucinotta@santannapisa.it>,
	Vineeth Pillai <vineeth@bitbyteword.org>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Phil Auld <pauld@redhat.com>
Subject: Re: [PATCH v2 06/15] sched: server: Don't start hrtick for DL server tasks
Date: Fri, 5 Apr 2024 10:49:29 +0200	[thread overview]
Message-ID: <a9dd5c5e-0095-48f9-9628-d5901d469ff3@redhat.com> (raw)
In-Reply-To: <20240313012451.1693807-7-joel@joelfernandes.org>

On 3/13/24 02:24, Joel Fernandes (Google) wrote:
> From: Suleiman Souhlal <suleiman@google.com>
> 
> Otherwise, we might start it even for tasks in a sched class that should
> have it off.
> 
> Signed-off-by: Suleiman Souhlal <suleiman@google.com>
> ---
>  kernel/sched/deadline.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 8fafe3f8b59c..5adfc15803c3 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -2325,11 +2325,12 @@ static struct task_struct *pick_next_task_dl(struct rq *rq)
>  	if (!p)
>  		return p;
>  
> -	if (!p->dl_server)
> +	if (!p->dl_server) {
>  		set_next_task_dl(rq, p, true);
>  
> -	if (hrtick_enabled(rq))
> -		start_hrtick_dl(rq, &p->dl);
> +		if (hrtick_enabled(rq))
> +			start_hrtick_dl(rq, &p->dl);
> +	}

The rational for having hrtick for the dl server too is the following:

This hrtick is reponsible for adding a hr timer for throttling. The throttling
serves as a protection for the other tasks, to avoid them missing their deadlines
because the current task overun for too long. Like, a task with 200us of runtime
actually running for 1 ms because of the non-hr-tick.

For example, let's get the case we have at red hat, where we want to use the
dl server to provide a minimum bandwidth to avoid starvation, keeping the noise
on real-time tasks low.

On this case, we will set the runtime for the fair server with number as low
as 20 us... 40 us. With hrtick, when the fair server is enqueued, it will be
throttle in the us scale... Without the hrtick, the server can run for an entire
tick before being throttled.

here is an example of this scenario using osnoise with/withoutout arming the hrtick
for the server that was set for 20 us of runtime:

There is a kernel compilation in CPU 1. Then osnoise is dispatched as fifo,
on CPU 1.

 # osnoise -c 1 -P f:1

removing hrtick:
 ############
 duration:   0 00:02:00 | time is in us
 CPU Period       Runtime        Noise  % CPU Aval   Max Noise   Max Single          HW          NMI          IRQ      Softirq       Thread
   1 #119       119000000         6482    99.99455        1220         1009           0            0          244           59           50
 ############

See max single noise... it when longer than the 20 us i've set...

With hrtick:
 ############
  duration:   0 00:02:30 | time is in us
  CPU Period       Runtime        Noise  % CPU Aval   Max Noise   Max Single          HW          NMI          IRQ      Softirq       Thread
    1 #149       149000472         3730    99.99749          33           33           0            0          641            3          155
 ############

the max single goes down to 33 us. It is not exactly 20 because there is
one timer to enqueue the server, and another timer to throttle it. Still,
the granularity is in the same order.

So, maybe, what we can do is to get it back to hrtick_enabled_dl() instead
of hrtick_enabled(), to have it only when HRTICK_DL is set.

am I missing a point?

-- Daniel


  reply	other threads:[~2024-04-05  8:49 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13  1:24 [PATCH v2 00/15] Fair scheduling deadline server fixes Joel Fernandes (Google)
2024-03-13  1:24 ` [PATCH v2 01/15] sched/core: Add clearing of ->dl_server in put_prev_task_balance() Joel Fernandes (Google)
2024-04-04 17:46   ` Daniel Bristot de Oliveira
2024-03-13  1:24 ` [PATCH v2 02/15] sched/core: Clear prev->dl_server in CFS pick fast path Joel Fernandes (Google)
2024-04-04 17:52   ` Daniel Bristot de Oliveira
2024-03-13  1:24 ` [PATCH v2 03/15] sched/core: Fix priority checking for DL server picks Joel Fernandes (Google)
2024-03-13  1:24 ` [PATCH v2 04/15] sched/core: Fix picking of tasks for core scheduling with DL server Joel Fernandes (Google)
2024-04-05  9:37   ` Daniel Bristot de Oliveira
2024-03-13  1:24 ` [PATCH v2 05/15] sched/debug: Use unsigned long for cpu variable to prevent cast errors Joel Fernandes (Google)
2024-03-13 20:02   ` Chris Hyser
2024-03-13  1:24 ` [PATCH v2 06/15] sched: server: Don't start hrtick for DL server tasks Joel Fernandes (Google)
2024-04-05  8:49   ` Daniel Bristot de Oliveira [this message]
2024-03-13  1:24 ` [PATCH v2 07/15] selftests/sched: Add a test to verify that DL server works with core scheduling Joel Fernandes (Google)
2024-03-13  1:24 ` [PATCH v2 08/15] selftests/sched: Migrate cs_prctl_test to kselfttest Joel Fernandes (Google)
2024-03-13 18:44   ` Chris Hyser
2024-03-13  1:24 ` [PATCH v2 09/15] admin-guide/hw-vuln: Correct prctl() argument description Joel Fernandes (Google)
2024-03-13 19:14   ` Chris Hyser
2024-03-13 19:26     ` Chris Hyser
2024-04-05  9:32   ` Daniel Bristot de Oliveira
2024-03-13  1:24 ` [PATCH v2 10/15] sched: Fix build error in "sched/rt: Remove default bandwidth control" Joel Fernandes (Google)
2024-03-13 20:06   ` Chris Hyser
2024-03-13  1:24 ` [PATCH v2 11/15] sched/deadline: Mark DL server as unthrottled before enqueue Joel Fernandes (Google)
2024-04-05  8:54   ` Daniel Bristot de Oliveira
2024-03-13  1:24 ` [PATCH v2 12/15] sched/deadline: Reverse args to dl_time_before in replenish Joel Fernandes (Google)
2024-04-05  8:54   ` Daniel Bristot de Oliveira
2024-03-13  1:24 ` [PATCH v2 13/15] sched/deadline: Make start_dl_timer callers more robust Joel Fernandes (Google)
2024-04-05  9:10   ` Daniel Bristot de Oliveira
2024-03-13  1:24 ` [PATCH v2 14/15] sched/deadline: Do not restart the DL server on replenish from timer Joel Fernandes (Google)
2024-04-05  9:11   ` Daniel Bristot de Oliveira
2024-03-13  1:24 ` [PATCH v2 15/15] sched/deadline: Always start a new period if CFS exceeded DL runtime Joel Fernandes (Google)
2024-04-05  9:19   ` Daniel Bristot de Oliveira

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=a9dd5c5e-0095-48f9-9628-d5901d469ff3@redhat.com \
    --to=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=joel@joelfernandes.org \
    --cc=joseph.salisbury@canonical.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca.abeni@santannapisa.it \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=pauld@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=skhan@linuxfoundation.org \
    --cc=suleiman@google.com \
    --cc=tglx@linutronix.de \
    --cc=tommaso.cucinotta@santannapisa.it \
    --cc=vincent.guittot@linaro.org \
    --cc=vineeth@bitbyteword.org \
    --cc=void@manifault.com \
    --cc=vschneid@redhat.com \
    --cc=youssefesmat@google.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 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.