2019-08-01 11:19:23

by Peter Zijlstra

[permalink] [raw]
Subject: [PATCH 4/5] media/ivtv: Reduce default FIFO priority

The ivtv driver creates a FIFO-99 thread by default, reduce this to
FIFO-1.

FIFO-99 is the very highest priority available to SCHED_FIFO and
it not a suitable default; it would indicate the ivtv work is the
most important work on the machine.

FIFO-1 gets it above all OTHER tasks, which seems high enough lacking
better justification.

Cc: Andy Walls <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Thomas Gleixner <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
---
drivers/media/pci/ivtv/ivtv-driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/media/pci/ivtv/ivtv-driver.c
+++ b/drivers/media/pci/ivtv/ivtv-driver.c
@@ -738,7 +738,7 @@ static void ivtv_process_options(struct
*/
static int ivtv_init_struct1(struct ivtv *itv)
{
- struct sched_param param = { .sched_priority = 99 };
+ struct sched_param param = { .sched_priority = 1 };

itv->base_addr = pci_resource_start(itv->pdev, 0);
itv->enc_mbox.max_mbox = 2; /* the encoder has 3 mailboxes (0-2) */



2019-08-01 12:28:19

by Andy Walls

[permalink] [raw]
Subject: Re: [PATCH 4/5] media/ivtv: Reduce default FIFO priority

Hi Peter:

On Thu, 2019-08-01 at 13:13 +0200, Peter Zijlstra wrote:
> The ivtv driver creates a FIFO-99 thread by default, reduce this to
> FIFO-1.
>
> FIFO-99 is the very highest priority available to SCHED_FIFO and
> it not a suitable default; it would indicate the ivtv work is the
> most important work on the machine.

ivtv based boards are legacy, convential PCI boards. At this point,
these old boards are generally installed in boxes dedicated to video
capture (e.g. MythTV setups) or boxes dedicated to capturing VBI
information, like closed captioning, for business intelligence.

For boxes dedicated to video or VBI capture, the ivtv work may very
well be close to the most important work on the machine, to avoid
dropping video frames or VBI data.


> FIFO-1 gets it above all OTHER tasks, which seems high enough lacking
> better justification.

I agree that FIFO-99 is the wrong default level.

However, in my opinion, threads responsible for real time data
acquisition should have higher priority than the other kernel driver
threads normally running at FIFO-50.

How about FIFO-51 as the default?

Regards,
Andy

> Cc: Andy Walls <[email protected]>
> Cc: Mauro Carvalho Chehab <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: Thomas Gleixner <[email protected]>
> Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
> ---
> drivers/media/pci/ivtv/ivtv-driver.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/drivers/media/pci/ivtv/ivtv-driver.c
> +++ b/drivers/media/pci/ivtv/ivtv-driver.c
> @@ -738,7 +738,7 @@ static void ivtv_process_options(struct
> */
> static int ivtv_init_struct1(struct ivtv *itv)
> {
> - struct sched_param param = { .sched_priority = 99 };
> + struct sched_param param = { .sched_priority = 1 };
>
> itv->base_addr = pci_resource_start(itv->pdev, 0);
> itv->enc_mbox.max_mbox = 2; /* the encoder has 3 mailboxes (0-
> 2) */
>
>

2019-08-01 13:13:58

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH 4/5] media/ivtv: Reduce default FIFO priority

On Thu, Aug 01, 2019 at 08:24:22AM -0400, Andy Walls wrote:
> Hi Peter:
>
> On Thu, 2019-08-01 at 13:13 +0200, Peter Zijlstra wrote:
> > The ivtv driver creates a FIFO-99 thread by default, reduce this to
> > FIFO-1.
> >
> > FIFO-99 is the very highest priority available to SCHED_FIFO and
> > it not a suitable default; it would indicate the ivtv work is the
> > most important work on the machine.
>
> ivtv based boards are legacy, convential PCI boards. At this point,
> these old boards are generally installed in boxes dedicated to video
> capture (e.g. MythTV setups) or boxes dedicated to capturing VBI
> information, like closed captioning, for business intelligence.
>
> For boxes dedicated to video or VBI capture, the ivtv work may very
> well be close to the most important work on the machine, to avoid
> dropping video frames or VBI data.
>
>
> > FIFO-1 gets it above all OTHER tasks, which seems high enough lacking
> > better justification.
>
> I agree that FIFO-99 is the wrong default level.
>
> However, in my opinion, threads responsible for real time data
> acquisition should have higher priority than the other kernel driver
> threads normally running at FIFO-50.
>
> How about FIFO-51 as the default?

If the consumer of the data are RT tasks as well (I hadn't expected that
from a TV capture device) then I'd propose to use FIFO-50 as default.

The thing is, the moment you're doing actual proper RT, the admin needs
to configure things anyway, which then very much includes setting the
priority of interrupt threads and the like.

(that is exacty why pretty much everything defaults to FIFO-50)

2019-08-02 09:38:30

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH 4/5] media/ivtv: Reduce default FIFO priority

On Thu, Aug 01, 2019 at 02:38:06PM +0200, Peter Zijlstra wrote:
> If the consumer of the data are RT tasks as well (I hadn't expected that
> from a TV capture device) then I'd propose to use FIFO-50 as default.
>
> The thing is, the moment you're doing actual proper RT, the admin needs
> to configure things anyway, which then very much includes setting the
> priority of interrupt threads and the like.
>
> (that is exacty why pretty much everything defaults to FIFO-50)

Is the below acceptible?

---
Subject: media/ivtv: Reduce default FIFO priority
From: Peter Zijlstra <[email protected]>
Date: Thu Aug 1 12:56:40 CEST 2019

The ivtv driver creates a FIFO-99 thread by default, reduce this to
FIFO-50.

FIFO-99 is the very highest priority available to SCHED_FIFO and
it not a suitable default; it would indicate the ivtv work is the
most important work on the machine.

Cc: Andy Walls <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Thomas Gleixner <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
---
drivers/media/pci/ivtv/ivtv-driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/media/pci/ivtv/ivtv-driver.c
+++ b/drivers/media/pci/ivtv/ivtv-driver.c
@@ -738,7 +738,7 @@ static void ivtv_process_options(struct
*/
static int ivtv_init_struct1(struct ivtv *itv)
{
- struct sched_param param = { .sched_priority = 99 };
+ struct sched_param param = { .sched_priority = MAX_RT_PRIO / 2 };

itv->base_addr = pci_resource_start(itv->pdev, 0);
itv->enc_mbox.max_mbox = 2; /* the encoder has 3 mailboxes (0-2) */

2019-08-07 09:28:33

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH 4/5] media/ivtv: Reduce default FIFO priority

On 8/2/19 10:58 AM, Peter Zijlstra wrote:
> On Thu, Aug 01, 2019 at 02:38:06PM +0200, Peter Zijlstra wrote:
>> If the consumer of the data are RT tasks as well (I hadn't expected that
>> from a TV capture device) then I'd propose to use FIFO-50 as default.
>>
>> The thing is, the moment you're doing actual proper RT, the admin needs
>> to configure things anyway, which then very much includes setting the
>> priority of interrupt threads and the like.
>>
>> (that is exacty why pretty much everything defaults to FIFO-50)
>
> Is the below acceptible?

I think this should be OK. ivtv is real-time sensitive since certain
tasks have to happen within (if I remember correctly) 1/60th of a second
(the time it takes to capture a single video field). Data is lost if it
can't be done within that time.

Using FIFO-50 means that it competes with other irq threads, and since
irq threads shouldn't take up much time anyway this should be OK.

Andy, what do you think?

Regards,

Hans

>
> ---
> Subject: media/ivtv: Reduce default FIFO priority
> From: Peter Zijlstra <[email protected]>
> Date: Thu Aug 1 12:56:40 CEST 2019
>
> The ivtv driver creates a FIFO-99 thread by default, reduce this to
> FIFO-50.
>
> FIFO-99 is the very highest priority available to SCHED_FIFO and
> it not a suitable default; it would indicate the ivtv work is the
> most important work on the machine.
>
> Cc: Andy Walls <[email protected]>
> Cc: Mauro Carvalho Chehab <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: Thomas Gleixner <[email protected]>
> Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
> ---
> drivers/media/pci/ivtv/ivtv-driver.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/drivers/media/pci/ivtv/ivtv-driver.c
> +++ b/drivers/media/pci/ivtv/ivtv-driver.c
> @@ -738,7 +738,7 @@ static void ivtv_process_options(struct
> */
> static int ivtv_init_struct1(struct ivtv *itv)
> {
> - struct sched_param param = { .sched_priority = 99 };
> + struct sched_param param = { .sched_priority = MAX_RT_PRIO / 2 };
>
> itv->base_addr = pci_resource_start(itv->pdev, 0);
> itv->enc_mbox.max_mbox = 2; /* the encoder has 3 mailboxes (0-2) */
>