All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tommaso Cucinotta <tommaso.cucinotta@santannapisa.it>
To: Tim Blechmann <tim@klingt.org>, Juri Lelli <juri.lelli@gmail.com>
Cc: Daniel Bristot de Oliveira <daniel@bristot.me>,
	linux-rt-users@vger.kernel.org,
	Luca Abeni <luca.abeni@santannapisa.it>,
	Alessio Balsini <alessio.balsini@santannapisa.it>
Subject: Re: SCHED_DEADLINE as user
Date: Tue, 21 Aug 2018 09:17:27 +0200	[thread overview]
Message-ID: <0a8f899a-589d-a84b-dadb-50def9c0b4c3@santannapisa.it> (raw)
In-Reply-To: <d7cd5c88-dbe6-c74d-43e8-724ac0b463ce@klingt.org>

[copying Alessio]

Hi,

On 20/08/2018 13:54, Tim Blechmann wrote:
> that's a tricky question and depends on the use-case: for me it's "good
> enough" to use something like:
>
> main audio thread:
> while running:
>    snd_pcm_read  // blocks until data is delivered from ALSA
>    wake helper(s)
>    do work()
>    sync_with_helper(s)
>    snd_pcm_write // blocks until data is delivered to ALSA
>
> alsa is basically driven by the hardware, which delivers/requests data
> every ~1.3ms.

this is exactly the use-case we considered in that old paper back in LAC 2011, and let me just add that there is more 
experimentation and details and results in Giacomo's MSc thesis:

   https://retis.sssup.it/?q=node/77

FYI, we restarted activities on this use-case just recently, considering a couple of further dimensions:

1) support for heterogeneous platforms with the aim of achieving a sound support for Arm big.LITTLE on Android, and 
apply it to the Android video & audio processing pipelines;

2) proper consideration of power switching capabilities of the platform (assuming the user would block the CPU frequency 
to its maximum is not really multimedia-friendly);

3) support for multi-threaded processing workflows on multi-cores, as typically needed by (high-performance) audio 
applications, either with a single multi-threaded audio processing client, or, e.g., with JACK, with a DAG of 
computations that can take advantage of underlying multi-core processing.

In this context, we've been playing also with the hierarchical extension to SCHED_DEADLINE we sent last year on LKML

   https://lkml.org/lkml/2017/3/31/658

I hope we can share some good write-up & experimental results pretty soon about some of the above...
> distributing the work is a little tricky: to avoid excessive scheduling
> overhead, the worker threads are typically woken up (after snd_pcm_read)
> and the result is collected where sync_with_helper() typically boils
> down to busy waiting. in this case, the workers as rate-monotonic in a
> similar manner as the main audio thread.
>
> one could also use lock-free queues with semaphores to wake only as many
> threads as needed for the graph topology (which can depend on user
> input). in this case SCHED_FIFO sounds more suitable.

proper handling of task dependencies & synchronization, and associated priority inversion issues, is also an aspect 
we've been and we're still working on, as when you mix DEADLINE tasks in the picture, it's a big mess.
> from a practical point of view: i'm not targeting a safety critical
> system. one advantage i'm seeing of DEADLINE over FIFO/RR is that it's
> easier to prevent lockups (e.g. when a user overloads the system). in
> the linux audio world this is typically done by a watchdog thread. the
> other part of the unix world (mach) is using time-constraint threads by
> default for audio use cases. so i'd assume that DEADLINE would free me
> from the need to spawn the watchdog thread ...

I'm not sure I'm getting this: AFAIU, from this viewpoint, what you could get
with DEADLINE, is very similar to what you can get already with RT throttling
on RT (RR/FIFO), setting up properly CPU cgroups & limits. Why do you think
DEADLINE would allow you to avoid a watchdog thread, that you need with
RT instead ?

Thanks,

     T.

-- 
Tommaso Cucinotta, Computer Engineering PhD
Associate Professor at the Real-Time Systems Laboratory (ReTiS)
Scuola Superiore Sant'Anna, Pisa, Italy
http://retis.sssup.it/people/tommaso

  parent reply	other threads:[~2018-08-21 10:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-15  6:08 SCHED_DEADLINE as user Tim Blechmann
2018-08-15  8:21 ` Daniel Bristot de Oliveira
2018-08-17  9:51   ` Juri Lelli
2018-08-17 10:08     ` Tim Blechmann
2018-08-17 10:28       ` Juri Lelli
     [not found]         ` <513fd544-bc51-7ea6-8b94-983d28922a66@klingt.org>
2018-08-20  8:54           ` Juri Lelli
2018-08-20 11:54             ` Tim Blechmann
2018-08-20 12:38               ` Daniel Bristot de Oliveira
2018-08-20 13:55                 ` Tim Blechmann
     [not found]                   ` <e207a65d-b1af-3fb1-8802-d1c05c0a9118@bristot.me>
     [not found]                     ` <05fbd5a4-f354-e084-cf40-8488548d7cb1@klingt.org>
2018-08-21  6:55                       ` Tommaso Cucinotta
2018-08-21  7:38                       ` Juri Lelli
2018-08-22  8:49                         ` Juri Lelli
2018-08-21  7:17               ` Tommaso Cucinotta [this message]
2018-08-21  7:59                 ` Tim Blechmann
2018-08-23  9:56             ` luca abeni
2018-08-23 10:23               ` Juri Lelli
2018-08-23 10:43                 ` luca abeni
2018-08-23 12:37                   ` Juri Lelli
2018-08-23 12:58                     ` luca abeni
2018-08-23 13:00                     ` luca abeni
2018-08-23 13:09                       ` Juri Lelli
2018-08-23 13:30                         ` luca abeni
2018-08-23 13:45                       ` Gene Heskett
2018-08-23 16:01                         ` Chris Friesen
2018-08-23 18:07                           ` Gene Heskett

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=0a8f899a-589d-a84b-dadb-50def9c0b4c3@santannapisa.it \
    --to=tommaso.cucinotta@santannapisa.it \
    --cc=alessio.balsini@santannapisa.it \
    --cc=daniel@bristot.me \
    --cc=juri.lelli@gmail.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=luca.abeni@santannapisa.it \
    --cc=tim@klingt.org \
    /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.