Skip to contentSkip to conversation

Xenomai with isolcpus and workqueue task

DISCUSSION Alexander Frolov 3 participants 7 messages Jul 11, 2020 – Jul 13, 2020 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi all!

I am using Xenomai 3.1 with 4.19.124 I-pipe patchon a smp motherboard.  For my RT task I allocate few CPU cores with isolcpus option. However, large latency spikes are noticed due to igb watchdog activities (I am using common igb driver, not rt_igb).

Looking into igb sources, it was understood that workqueue is used for some tasks (afaiu, it is used to link status monitoring)

from igb_main.c
...
  INIT_WORK(&adapter->reset_task, igb_reset_task); INIT_WORK(&adapter->watchdog_task, igb_watchdog_task);
...

The Linux kernel scheduler runs this igb activities on isolated CPUs disregarding isolcpus option, ruining real-time system behavior.

So the question, is it a correct way to use normal igb on Xenomai at all or it is not recommended? What can be done to prohibit Linux scheduler to allocate those tasks on isolated cores?

Thank you!

Best,
   Alex

#1 lore raw
Quoted 16 lines

Sent: Saturday, July 11, 2020 10:26 PM

Hi all!

I am using Xenomai 3.1 with 4.19.124 I-pipe patchon a smp motherboard. For my RT task I allocate few CPU cores with isolcpus option. However, large latency spikes are noticed due to igb watchdog activities (I am using common igb driver, not rt_igb).

Looking into igb sources, it was understood that workqueue is used for some tasks (afaiu, it is used to link status monitoring)

from igb_main.c
...
  INIT_WORK(&adapter->reset_task, igb_reset_task); INIT_WORK(&adapter->watchdog_task, igb_watchdog_task); ...

Quoted 5 lines

The Linux kernel scheduler runs this igb activities on isolated CPUs disregarding isolcpus option, ruining real-time system behavior.

So the question, is it a correct way to use normal igb on Xenomai at all or it is not recommended? What can be done to prohibit Linux scheduler to allocate those tasks on isolated cores?

Hi Alex,

On this motherboard, is the basic latency test OK without igb activities? The spike maybe not due to igb driver. In our experience, if the motherboard's BIOS is not aware of real-time system, which mean missing some critical settings items C-State, HyperThreading, SA GV (the power save for bus matrix)...
We are working on de-coupling BIOS setting and RT performance, let the kernel to control system status, but not finished yet.

BR / Fino (孟祥夫)
Intel – IOTG Developer Enabling

Quoted 5 lines

Thank you!

Best,
   Alex

A message that is not in the archive (sent off-list or not yet received): VI1PR05MB5917C0D09456A2D0B2FF2CA1F6600@VI1PR05MB5917.eurprd05.prod.outlook.com

#3 lore raw

(fwd to list)

Quoted 64 lines

-----Original Message-----
From: Lange Norbert
Sent: Montag, 13. Juli 2020 10:34
To: Alexander Frolov <[email protected]>
Subject: RE: Xenomai with isolcpus and workqueue task

Quoted 8 lines

-----Original Message-----
From: Xenomai <[email protected]> On Behalf Of Alexander Frolov via Xenomai
Sent: Samstag, 11. Juli 2020 16:26
To: [email protected]
Subject: Xenomai with isolcpus and workqueue task

NON-ANDRITZ SOURCE: BE CAUTIOUS WITH CONTENT, LINKS OR

ATTACHMENTS.

Quoted 13 lines

Hi all!

I am using Xenomai 3.1 with 4.19.124 I-pipe patchon a smp motherboard. For my RT task I allocate few CPU cores with isolcpus option. However, large latency spikes are noticed due to igb watchdog activities (I am using common igb driver, not rt_igb).

Looking into igb sources, it was understood that workqueue is used for some tasks (afaiu, it is used to link status
monitoring)

Quoted 7 lines

from igb_main.c
...

   INIT_WORK(&adapter->reset_task, igb_reset_task);
   INIT_WORK(&adapter->watchdog_task, igb_watchdog_task); ...

The Linux kernel scheduler runs this igb activities on isolated CPUs disregarding isolcpus option, ruining real-time system behavior.

isolcpus does not mean the CPUs aren't used, it means they are excluded from the normal CPU scheduler. No process will automatically be moved from/to isolated CPUs, but you still need to make sure to free them of any tasks.
Irq-handlers still run anywhere, and processes still can allow those CPUs to be used.

Quoted 3 lines

So the question, is it a correct way to use normal igb on Xenomai at all or it is not recommended? What can be done to prohibit Linux scheduler to allocate those tasks on isolated cores?

I use the normal igb and rt_igb concurrently, I doubt it is recommended but possible ;)

You should add irqaffinity=0 to the cmdline (CPU0 is apparently always used for irqs), then check 'cat /proc/irq/*/smp_affinity'. This keeps the other CPUs free from linux IRQs.
You can use some measures to bind Linux tasks to CPU0 aswell. One of:

(quoted diff) +0 -3
-   isolcpus (sets default affinity mask aswell)
-   set affinity early (like in Ramdisk)
-   Use cgroups (cset-shield)

Only cgroups actually prohibit processes ignoring your defaults and using other CPUs, I did not get around playing with this, and just use isolcpus.

Quoted 8 lines

But the most important part is to dont run RT on cores dealing with Linux interrupts, some handlers/drivers don’t expects being preempted, had the MMC driver bail because of a timeout.

I haven’t solved moving the rtnet-stack, rtnet-rpc off CPU0, and the rt_igb IRQs will use all CPUs.

Norbert

________________________________

This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.

ANDRITZ HYDRO GmbH

Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation

Firmensitz/ Registered seat: Wien

Firmenbuchgericht/ Court of registry: Handelsgericht Wien

Firmenbuchnummer/ Company registration: FN 61833 g

DVR: 0605077

UID-Nr.: ATU14756806

Thank You
________________________________

#4 lore raw

-----Original Message-----

Quoted 60 lines
Quoted 60 lines

From: Lange Norbert
Sent: Montag, 13. Juli 2020 10:34
To: Alexander Frolov <[email protected]>
Subject: RE: Xenomai with isolcpus and workqueue task

Quoted 8 lines

-----Original Message-----
From: Xenomai <[email protected]> On Behalf Of Alexander Frolov via Xenomai
Sent: Samstag, 11. Juli 2020 16:26
To: [email protected]
Subject: Xenomai with isolcpus and workqueue task

NON-ANDRITZ SOURCE: BE CAUTIOUS WITH CONTENT, LINKS OR

ATTACHMENTS.

Quoted 12 lines

Hi all!

I am using Xenomai 3.1 with 4.19.124 I-pipe patchon a smp motherboard. For my RT task I allocate few CPU cores with isolcpus option. However, large latency spikes are noticed due to igb watchdog activities (I am using common igb driver, not rt_igb).

Looking into igb sources, it was understood that workqueue is used for some tasks (afaiu, it is used to link status
monitoring)

Quoted 7 lines

from igb_main.c
...

    INIT_WORK(&adapter->reset_task, igb_reset_task);
    INIT_WORK(&adapter->watchdog_task, igb_watchdog_task); ...

The Linux kernel scheduler runs this igb activities on isolated CPUs disregarding isolcpus option, ruining real-time system behavior.

isolcpus does not mean the CPUs aren't used, it means they are excluded from the normal CPU scheduler. No process will automatically be moved from/to isolated CPUs, but you still need to make sure to free them of any tasks.
Irq-handlers still run anywhere, and processes still can allow those CPUs to be used.

Quoted 3 lines

So the question, is it a correct way to use normal igb on Xenomai at all or it is not recommended? What can be done to prohibit Linux scheduler to allocate those tasks on isolated cores?

I use the normal igb and rt_igb concurrently, I doubt it is recommended but possible ;)

You should add irqaffinity=0 to the cmdline (CPU0 is apparently always used for irqs), then check 'cat /proc/irq/*/smp_affinity'. This keeps the other CPUs free from linux IRQs.
You can use some measures to bind Linux tasks to CPU0 aswell. One of:

(quoted diff) +0 -3
-   isolcpus (sets default affinity mask aswell)
-   set affinity early (like in Ramdisk)
-   Use cgroups (cset-shield)

Only cgroups actually prohibit processes ignoring your defaults and using other CPUs, I did not get around playing with this, and just use isolcpus.

Quoted 8 lines
Quoted 8 lines

But the most important part is to dont run RT on cores dealing with Linux interrupts, some handlers/drivers don’t expects being preempted, had the MMC driver bail because of a timeout.

I haven’t solved moving the rtnet-stack, rtnet-rpc off CPU0, and the rt_igb IRQs will use all CPUs.

Norbert

Thank you! Using an IRQ affinity feature to move handlers to specified cores is very practical, but in this case we experience problem with another artefakt of igb.

Just as example of influence of igb activity (igb_watchdog_task) on CPU4 (which is an isolated one).

# cat /proc/ipipe/trace/frozen | grep '\!'
...
:  +func               -1231!  52.379  igb_rd32+0x0 [igb] (igb_update_stats+0x520 [igb])
:  +func               -1145!  45.864  igb_rd32+0x0 [igb] (igb_update_stats+0x536 [igb])
:  +func               -1099!  51.917  igb_rd32+0x0 [igb] (igb_update_stats+0x75a [igb])
:  +func               -1047!  51.517  igb_rd32+0x0 [igb] (igb_update_stats+0x782 [igb])
:  +func                -996!  51.988  igb_rd32+0x0 [igb] (igb_update_stats+0x54e [igb])
:  +func                -944!  51.436  igb_rd32+0x0 [igb] (igb_update_stats+0x564 [igb])
:  +func                -893!  52.569  igb_rd32+0x0 [igb] (igb_update_stats+0x57a [igb])
:  +func                -840!  52.529  igb_rd32+0x0 [igb] (igb_update_stats+0x590 [igb])
:  +func                -787!  52.018  igb_rd32+0x0 [igb] (igb_update_stats+0x5a6 [igb])
:  +func                -735!  52.058  igb_rd32+0x0 [igb] (igb_update_stats+0x5bc [igb])
:  +func                -683!  51.497  igb_rd32+0x0 [igb] (igb_update_stats+0x5d2 [igb])
:  +func                -632!  51.436  igb_rd32+0x0 [igb] (igb_update_stats+0x5e8 [igb])
:  +func                -580!  51.416  igb_rd32+0x0 [igb] (igb_update_stats+0x5fe [igb])
:  +func                -529!  52.038  igb_rd32+0x0 [igb] (igb_update_stats+0x614 [igb])
:  +func                -477!  52.058  igb_rd32+0x0 [igb] (igb_update_stats+0x62a [igb])
:  +func                -425!  51.436  igb_rd32+0x0 [igb] (igb_update_stats+0x6f4 [igb])
:  +func                -373!  51.416  igb_rd32+0x0 [igb] (igb_update_stats+0x70a [igb])
:  +func                -322!  51.517  igb_rd32+0x0 [igb] (igb_update_stats+0x720 [igb])
:  +func                -271!  51.847  igb_rd32+0x0 [igb] (igb_update_stats+0x736 [igb])
:  +func                -189!  47.247  igb_rd32+0x0 [igb] (igb_ptp_rx_hang+0x1e [igb])
:  +func                -103!  72.735  igb_rd32+0x0 [igb] (igb_watchdog_task+0x66a [igb])

From the other side, rt kernels do not have this issue, probably because of modified workqueue subsystem.

Any ideas how to keep this work out of critical code?

Thank you,
   Alex Frolov

#5 lore raw
Quoted 83 lines

-----Original Message-----
From: Xenomai <[email protected]> On Behalf Of Alexander Frolov via Xenomai
Sent: Montag, 13. Juli 2020 12:27
To: [email protected]
Subject: Re: FW: Xenomai with isolcpus and workqueue task

NON-ANDRITZ SOURCE: BE CAUTIOUS WITH CONTENT, LINKS OR ATTACHMENTS.

-----Original Message-----

Quoted 9 lines
Quoted 9 lines

From: Lange Norbert
Sent: Montag, 13. Juli 2020 10:34
To: Alexander Frolov <[email protected]>
Subject: RE: Xenomai with isolcpus and workqueue task

Quoted 2 lines

-----Original Message-----
From: Xenomai <[email protected]> On Behalf Of

Alexander

Quoted 44 lines
Quoted 44 lines
Quoted 6 lines

Frolov via Xenomai
Sent: Samstag, 11. Juli 2020 16:26
To: [email protected]
Subject: Xenomai with isolcpus and workqueue task

NON-ANDRITZ SOURCE: BE CAUTIOUS WITH CONTENT, LINKS OR

ATTACHMENTS.

Quoted 12 lines

Hi all!

I am using Xenomai 3.1 with 4.19.124 I-pipe patchon a smp motherboard. For my RT task I allocate few CPU cores with isolcpus option. However, large latency spikes are noticed due to igb watchdog activities (I am using common igb driver, not rt_igb).

Looking into igb sources, it was understood that workqueue is used for some tasks (afaiu, it is used to link status monitoring)

Quoted 7 lines

from igb_main.c
...

    INIT_WORK(&adapter->reset_task, igb_reset_task);
    INIT_WORK(&adapter->watchdog_task, igb_watchdog_task); ...

The Linux kernel scheduler runs this igb activities on isolated CPUs disregarding isolcpus option, ruining real-time system behavior.

isolcpus does not mean the CPUs aren't used, it means they are excluded from the normal CPU scheduler. No process will automatically be moved from/to isolated CPUs, but you still need to make sure to free them of any tasks.
Irq-handlers still run anywhere, and processes still can allow those CPUs to be used.

Quoted 3 lines

So the question, is it a correct way to use normal igb on Xenomai at all or it is not recommended? What can be done to prohibit Linux scheduler to allocate those tasks on isolated cores?

I use the normal igb and rt_igb concurrently, I doubt it is recommended but possible ;)

You should add irqaffinity=0 to the cmdline (CPU0 is apparently always used for irqs), then check 'cat /proc/irq/*/smp_affinity'. This keeps the other CPUs free from linux IRQs.
You can use some measures to bind Linux tasks to CPU0 aswell. One of:

Quoted 6 lines
Quoted 6 lines
(quoted diff) +0 -3
-   isolcpus (sets default affinity mask aswell)
-   set affinity early (like in Ramdisk)
-   Use cgroups (cset-shield)

Only cgroups actually prohibit processes ignoring your defaults and using other CPUs, I did not get around playing with this, and just use

isolcpus.

Quoted 8 lines
Quoted 8 lines

But the most important part is to dont run RT on cores dealing with Linux interrupts, some handlers/drivers don’t expects being preempted, had the MMC driver bail because of a timeout.

I haven’t solved moving the rtnet-stack, rtnet-rpc off CPU0, and the rt_igb IRQs will use all CPUs.

Quoted 7 lines
Quoted 1 line
Quoted 1 line

Norbert

Thank you! Using an IRQ affinity feature to move handlers to specified cores is very practical, but in this case we experience problem with another artefakt of igb.

Just as example of influence of igb activity (igb_watchdog_task) on CPU4 (which is an isolated one).

Hmm, I dont have that task.
You can use taskset -p 0 <pidof igb_watchdog_task> to change affinity, If not pretty but should work.

(isolcpus doesn’t work the way you think, it only affects CPU migration)

Quoted 47 lines
# cat /proc/ipipe/trace/frozen | grep '\!'
...
:  +func               -1231!  52.379  igb_rd32+0x0 [igb]
(igb_update_stats+0x520 [igb])
:  +func               -1145!  45.864  igb_rd32+0x0 [igb]
(igb_update_stats+0x536 [igb])
:  +func               -1099!  51.917  igb_rd32+0x0 [igb]
(igb_update_stats+0x75a [igb])
:  +func               -1047!  51.517  igb_rd32+0x0 [igb]
(igb_update_stats+0x782 [igb])
:  +func                -996!  51.988  igb_rd32+0x0 [igb]
(igb_update_stats+0x54e [igb])
:  +func                -944!  51.436  igb_rd32+0x0 [igb]
(igb_update_stats+0x564 [igb])
:  +func                -893!  52.569  igb_rd32+0x0 [igb]
(igb_update_stats+0x57a [igb])
:  +func                -840!  52.529  igb_rd32+0x0 [igb]
(igb_update_stats+0x590 [igb])
:  +func                -787!  52.018  igb_rd32+0x0 [igb]
(igb_update_stats+0x5a6 [igb])
:  +func                -735!  52.058  igb_rd32+0x0 [igb]
(igb_update_stats+0x5bc [igb])
:  +func                -683!  51.497  igb_rd32+0x0 [igb]
(igb_update_stats+0x5d2 [igb])
:  +func                -632!  51.436  igb_rd32+0x0 [igb]
(igb_update_stats+0x5e8 [igb])
:  +func                -580!  51.416  igb_rd32+0x0 [igb]
(igb_update_stats+0x5fe [igb])
:  +func                -529!  52.038  igb_rd32+0x0 [igb]
(igb_update_stats+0x614 [igb])
:  +func                -477!  52.058  igb_rd32+0x0 [igb]
(igb_update_stats+0x62a [igb])
:  +func                -425!  51.436  igb_rd32+0x0 [igb]
(igb_update_stats+0x6f4 [igb])
:  +func                -373!  51.416  igb_rd32+0x0 [igb]
(igb_update_stats+0x70a [igb])
:  +func                -322!  51.517  igb_rd32+0x0 [igb]
(igb_update_stats+0x720 [igb])
:  +func                -271!  51.847  igb_rd32+0x0 [igb]
(igb_update_stats+0x736 [igb])
:  +func                -189!  47.247  igb_rd32+0x0 [igb]
(igb_ptp_rx_hang+0x1e [igb])
:  +func                -103!  72.735  igb_rd32+0x0 [igb]
(igb_watchdog_task+0x66a [igb])
Quoted 4 lines

From the other side, rt kernels do not have this issue, probably because of
modified workqueue subsystem.

Any ideas how to keep this work out of critical code?

Is this task blocking RT from running? I mean it's better to run it at another core, particularly because register accesses are painfully slow on that hardware. But I don’t see why it should make a big impact.

Norbert

________________________________

This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.

ANDRITZ HYDRO GmbH

Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation

Firmensitz/ Registered seat: Wien

Firmenbuchgericht/ Court of registry: Handelsgericht Wien

Firmenbuchnummer/ Company registration: FN 61833 g

DVR: 0605077

UID-Nr.: ATU14756806

Thank You
________________________________

#6 lore raw
Quoted 85 lines · Lange Norbert
Quoted 85 lines

-----Original Message-----
From: Xenomai <[email protected]> On Behalf Of Alexander Frolov via Xenomai
Sent: Montag, 13. Juli 2020 12:27
To: [email protected]
Subject: Re: FW: Xenomai with isolcpus and workqueue task

NON-ANDRITZ SOURCE: BE CAUTIOUS WITH CONTENT, LINKS OR ATTACHMENTS.

-----Original Message-----

Quoted 9 lines
Quoted 9 lines

From: Lange Norbert
Sent: Montag, 13. Juli 2020 10:34
To: Alexander Frolov <[email protected]>
Subject: RE: Xenomai with isolcpus and workqueue task

Quoted 2 lines

-----Original Message-----
From: Xenomai <[email protected]> On Behalf Of

Alexander

Quoted 43 lines
Quoted 43 lines
Quoted 6 lines

Frolov via Xenomai
Sent: Samstag, 11. Juli 2020 16:26
To: [email protected]
Subject: Xenomai with isolcpus and workqueue task

NON-ANDRITZ SOURCE: BE CAUTIOUS WITH CONTENT, LINKS OR

ATTACHMENTS.

Quoted 11 lines

Hi all!

I am using Xenomai 3.1 with 4.19.124 I-pipe patchon a smp motherboard. For my RT task I allocate few CPU cores with isolcpus option. However, large latency spikes are noticed due to igb watchdog activities (I am using common igb driver, not rt_igb).

Looking into igb sources, it was understood that workqueue is used for some tasks (afaiu, it is used to link status monitoring)

Quoted 7 lines

from igb_main.c
...

     INIT_WORK(&adapter->reset_task, igb_reset_task);
     INIT_WORK(&adapter->watchdog_task, igb_watchdog_task); ...

The Linux kernel scheduler runs this igb activities on isolated CPUs disregarding isolcpus option, ruining real-time system behavior.

isolcpus does not mean the CPUs aren't used, it means they are excluded from the normal CPU scheduler. No process will automatically be moved from/to isolated CPUs, but you still need to make sure to free them of any tasks.
Irq-handlers still run anywhere, and processes still can allow those CPUs to be used.

Quoted 3 lines

So the question, is it a correct way to use normal igb on Xenomai at all or it is not recommended? What can be done to prohibit Linux scheduler to allocate those tasks on isolated cores?

I use the normal igb and rt_igb concurrently, I doubt it is recommended but possible ;)

You should add irqaffinity=0 to the cmdline (CPU0 is apparently always used for irqs), then check 'cat /proc/irq/*/smp_affinity'. This keeps the other CPUs free from linux IRQs.
You can use some measures to bind Linux tasks to CPU0 aswell. One of:

Quoted 6 lines
Quoted 6 lines
(quoted diff) +0 -3
-   isolcpus (sets default affinity mask aswell)
-   set affinity early (like in Ramdisk)
-   Use cgroups (cset-shield)

Only cgroups actually prohibit processes ignoring your defaults and using other CPUs, I did not get around playing with this, and just use

isolcpus.

Quoted 8 lines
Quoted 8 lines

But the most important part is to dont run RT on cores dealing with Linux interrupts, some handlers/drivers don’t expects being preempted, had the MMC driver bail because of a timeout.

I haven’t solved moving the rtnet-stack, rtnet-rpc off CPU0, and the rt_igb IRQs will use all CPUs.

Norbert

Thank you! Using an IRQ affinity feature to move handlers to specified cores is very practical, but in this case we experience problem with another artefakt of igb.

Quoted 7 lines
Quoted 2 lines

Just as example of influence of igb activity (igb_watchdog_task) on CPU4 (which is an isolated one).

Hmm, I dont have that task.
You can use taskset -p 0 <pidof igb_watchdog_task> to change affinity, If not pretty but should work.

(isolcpus doesn’t work the way you think, it only affects CPU migration)

Not sure, that I can find out <pidof igb_watchdog_task>, cause it can be kworker thread which takes this task to execution. I can try to move all kworkers to general- purposed cores, which looks a bit crazy.

Quoted 47 lines
Quoted 47 lines
# cat /proc/ipipe/trace/frozen | grep '\!'
...
:  +func               -1231!  52.379  igb_rd32+0x0 [igb]
(igb_update_stats+0x520 [igb])
:  +func               -1145!  45.864  igb_rd32+0x0 [igb]
(igb_update_stats+0x536 [igb])
:  +func               -1099!  51.917  igb_rd32+0x0 [igb]
(igb_update_stats+0x75a [igb])
:  +func               -1047!  51.517  igb_rd32+0x0 [igb]
(igb_update_stats+0x782 [igb])
:  +func                -996!  51.988  igb_rd32+0x0 [igb]
(igb_update_stats+0x54e [igb])
:  +func                -944!  51.436  igb_rd32+0x0 [igb]
(igb_update_stats+0x564 [igb])
:  +func                -893!  52.569  igb_rd32+0x0 [igb]
(igb_update_stats+0x57a [igb])
:  +func                -840!  52.529  igb_rd32+0x0 [igb]
(igb_update_stats+0x590 [igb])
:  +func                -787!  52.018  igb_rd32+0x0 [igb]
(igb_update_stats+0x5a6 [igb])
:  +func                -735!  52.058  igb_rd32+0x0 [igb]
(igb_update_stats+0x5bc [igb])
:  +func                -683!  51.497  igb_rd32+0x0 [igb]
(igb_update_stats+0x5d2 [igb])
:  +func                -632!  51.436  igb_rd32+0x0 [igb]
(igb_update_stats+0x5e8 [igb])
:  +func                -580!  51.416  igb_rd32+0x0 [igb]
(igb_update_stats+0x5fe [igb])
:  +func                -529!  52.038  igb_rd32+0x0 [igb]
(igb_update_stats+0x614 [igb])
:  +func                -477!  52.058  igb_rd32+0x0 [igb]
(igb_update_stats+0x62a [igb])
:  +func                -425!  51.436  igb_rd32+0x0 [igb]
(igb_update_stats+0x6f4 [igb])
:  +func                -373!  51.416  igb_rd32+0x0 [igb]
(igb_update_stats+0x70a [igb])
:  +func                -322!  51.517  igb_rd32+0x0 [igb]
(igb_update_stats+0x720 [igb])
:  +func                -271!  51.847  igb_rd32+0x0 [igb]
(igb_update_stats+0x736 [igb])
:  +func                -189!  47.247  igb_rd32+0x0 [igb]
(igb_ptp_rx_hang+0x1e [igb])
:  +func                -103!  72.735  igb_rd32+0x0 [igb]
(igb_watchdog_task+0x66a [igb])
Quoted 7 lines
Quoted 4 lines

From the other side, rt kernels do not have this issue, probably because of
modified workqueue subsystem.

Any ideas how to keep this work out of critical code?

Is this task blocking RT from running? I mean it's better to run it at another core, particularly because register accesses are painfully slow on that hardware. But I don’t see why it should make a big impact.

Yes, that what it does. I think igb_rd32 is too slow, do not know why, however.

Quoted 25 lines

Norbert

________________________________

This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.

ANDRITZ HYDRO GmbH

Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation

Firmensitz/ Registered seat: Wien

Firmenbuchgericht/ Court of registry: Handelsgericht Wien

Firmenbuchnummer/ Company registration: FN 61833 g

DVR: 0605077

UID-Nr.: ATU14756806

Thank You
________________________________

#7 lore raw
Quoted 108 lines

-----Original Message-----
From: Alexander Frolov <[email protected]>
Sent: Montag, 13. Juli 2020 13:09
To: Lange Norbert <[email protected]>; Xenomai ([email protected]) <[email protected]>
Subject: Re: FW: Xenomai with isolcpus and workqueue task

NON-ANDRITZ SOURCE: BE CAUTIOUS WITH CONTENT, LINKS OR ATTACHMENTS.

Quoted 3 lines · Lange Norbert
Quoted 3 lines

-----Original Message-----
From: Xenomai <[email protected]> On Behalf Of

Alexander

Quoted 6 lines
Quoted 6 lines

Frolov via Xenomai
Sent: Montag, 13. Juli 2020 12:27
To: [email protected]
Subject: Re: FW: Xenomai with isolcpus and workqueue task

NON-ANDRITZ SOURCE: BE CAUTIOUS WITH CONTENT, LINKS OR

ATTACHMENTS.

Quoted 18 lines
Quoted 18 lines

-----Original Message-----

Quoted 9 lines
Quoted 9 lines

From: Lange Norbert
Sent: Montag, 13. Juli 2020 10:34
To: Alexander Frolov <[email protected]>
Subject: RE: Xenomai with isolcpus and workqueue task

Quoted 2 lines

-----Original Message-----
From: Xenomai <[email protected]> On Behalf Of

Alexander

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Frolov via Xenomai
Sent: Samstag, 11. Juli 2020 16:26
To: [email protected]
Subject: Xenomai with isolcpus and workqueue task

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

NON-ANDRITZ SOURCE: BE CAUTIOUS WITH CONTENT, LINKS OR

ATTACHMENTS.

Quoted 3 lines

Hi all!

I am using Xenomai 3.1 with 4.19.124 I-pipe patchon a smp

motherboard.

Quoted 44 lines
Quoted 44 lines
Quoted 33 lines
Quoted 33 lines
Quoted 8 lines

For my RT task I allocate few CPU cores with isolcpus option. However, large latency spikes are noticed due to igb watchdog activities (I am using common igb driver, not rt_igb).

Looking into igb sources, it was understood that workqueue is used for some tasks (afaiu, it is used to link status monitoring)

Quoted 7 lines

from igb_main.c
...

     INIT_WORK(&adapter->reset_task, igb_reset_task);
     INIT_WORK(&adapter->watchdog_task, igb_watchdog_task); ...

The Linux kernel scheduler runs this igb activities on isolated CPUs disregarding isolcpus option, ruining real-time system behavior.

isolcpus does not mean the CPUs aren't used, it means they are excluded from the normal CPU scheduler. No process will automatically be moved from/to isolated CPUs, but you still need to make sure to free them of any tasks.
Irq-handlers still run anywhere, and processes still can allow those CPUs to be used.

Quoted 3 lines

So the question, is it a correct way to use normal igb on Xenomai at all or it is not recommended? What can be done to prohibit Linux scheduler to allocate those tasks on isolated cores?

I use the normal igb and rt_igb concurrently, I doubt it is recommended but possible ;)

You should add irqaffinity=0 to the cmdline (CPU0 is apparently always used for irqs), then check 'cat /proc/irq/*/smp_affinity'. This keeps the other CPUs free from linux IRQs.
You can use some measures to bind Linux tasks to CPU0 aswell. One of:

Quoted 6 lines
Quoted 6 lines
(quoted diff) +0 -3
-   isolcpus (sets default affinity mask aswell)
-   set affinity early (like in Ramdisk)
-   Use cgroups (cset-shield)

Only cgroups actually prohibit processes ignoring your defaults and using other CPUs, I did not get around playing with this, and just use

isolcpus.

Quoted 4 lines
Quoted 4 lines

But the most important part is to dont run RT on cores dealing with Linux interrupts, some handlers/drivers don’t expects being preempted, had the MMC driver bail because of a timeout.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

I haven’t solved moving the rtnet-stack, rtnet-rpc off CPU0, and the rt_igb IRQs will use all CPUs.

Norbert

Thank you! Using an IRQ affinity feature to move handlers to specified

cores

Quoted 9 lines
Quoted 5 lines

is very practical, but in this case we experience problem with another artefakt of igb.

Just as example of influence of igb activity (igb_watchdog_task) on CPU4 (which is an isolated one).

Hmm, I dont have that task.
You can use taskset -p 0 <pidof igb_watchdog_task> to change affinity, If not pretty but should work.

Quoted 7 lines
Quoted 1 line

(isolcpus doesn’t work the way you think, it only affects CPU migration)

Not sure, that I can find out <pidof igb_watchdog_task>, cause it can be
kworker
thread which takes this task to execution. I can try to move all kworkers to
general-
purposed cores, which looks a bit crazy.

Ok, missed the general workqueue part. No, moving kworkers is likely dangerous. Still I wonder why its picking core 4, maybe binding irqs to core #0 will Indirectly affect that.

Quoted 52 lines
Quoted 48 lines
Quoted 48 lines

# cat /proc/ipipe/trace/frozen | grep '\!'
...
:  +func               -1231!  52.379  igb_rd32+0x0 [igb]
(igb_update_stats+0x520 [igb])
:  +func               -1145!  45.864  igb_rd32+0x0 [igb]
(igb_update_stats+0x536 [igb])
:  +func               -1099!  51.917  igb_rd32+0x0 [igb]
(igb_update_stats+0x75a [igb])
:  +func               -1047!  51.517  igb_rd32+0x0 [igb]
(igb_update_stats+0x782 [igb])
:  +func                -996!  51.988  igb_rd32+0x0 [igb]
(igb_update_stats+0x54e [igb])
:  +func                -944!  51.436  igb_rd32+0x0 [igb]
(igb_update_stats+0x564 [igb])
:  +func                -893!  52.569  igb_rd32+0x0 [igb]
(igb_update_stats+0x57a [igb])
:  +func                -840!  52.529  igb_rd32+0x0 [igb]
(igb_update_stats+0x590 [igb])
:  +func                -787!  52.018  igb_rd32+0x0 [igb]
(igb_update_stats+0x5a6 [igb])
:  +func                -735!  52.058  igb_rd32+0x0 [igb]
(igb_update_stats+0x5bc [igb])
:  +func                -683!  51.497  igb_rd32+0x0 [igb]
(igb_update_stats+0x5d2 [igb])
:  +func                -632!  51.436  igb_rd32+0x0 [igb]
(igb_update_stats+0x5e8 [igb])
:  +func                -580!  51.416  igb_rd32+0x0 [igb]
(igb_update_stats+0x5fe [igb])
:  +func                -529!  52.038  igb_rd32+0x0 [igb]
(igb_update_stats+0x614 [igb])
:  +func                -477!  52.058  igb_rd32+0x0 [igb]
(igb_update_stats+0x62a [igb])
:  +func                -425!  51.436  igb_rd32+0x0 [igb]
(igb_update_stats+0x6f4 [igb])
:  +func                -373!  51.416  igb_rd32+0x0 [igb]
(igb_update_stats+0x70a [igb])
:  +func                -322!  51.517  igb_rd32+0x0 [igb]
(igb_update_stats+0x720 [igb])
:  +func                -271!  51.847  igb_rd32+0x0 [igb]
(igb_update_stats+0x736 [igb])
:  +func                -189!  47.247  igb_rd32+0x0 [igb]
(igb_ptp_rx_hang+0x1e [igb])
:  +func                -103!  72.735  igb_rd32+0x0 [igb]
(igb_watchdog_task+0x66a [igb])
Quoted 1 line
Quoted 1 line

From the other side, rt kernels do not have this issue, probably because

of

Quoted 2 lines
Quoted 2 lines

modified workqueue subsystem.

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Any ideas how to keep this work out of critical code?

Is this task blocking RT from running? I mean it's better to run it at another

core,

Quoted 2 lines

particularly because register accesses are painfully slow on that hardware. But I don’t see why it should make a big impact.

Yes, that what it does. I think igb_rd32 is too slow, do not know why, however.

It does some weird stuff, handling PCI read error AFAIU. For the rt_igp part, I have this disabled (not sure if its upstream):

#define rd32(__reg)readl(hw->hw_addr + (__reg))

What kinda spikes are we talking about btw. (ie. normal latency and outliers)?

I don’t think the workqueue should block Xenomai, so those reads alone should not Affect latency by more than ~20musec (atleast on my hardware).

Norbert

________________________________

This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.

ANDRITZ HYDRO GmbH

Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation

Firmensitz/ Registered seat: Wien

Firmenbuchgericht/ Court of registry: Handelsgericht Wien

Firmenbuchnummer/ Company registration: FN 61833 g

DVR: 0605077

UID-Nr.: ATU14756806

Thank You
________________________________