Skip to contentSkip to conversation

Xenomai 2.6.5

Xenomai Gilles Chanteperdrix 3 participants 15 messages Jul 9, 2016 – Aug 1, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

you will find the latest release in Xenomai 2.6 branch here:
https://xenomai.org/downloads/xenomai/stable/xenomai-2.6.5.tar.bz2

It contains fixes for known bugs in the 2.6.4 release, now almost
two years old, notably:
- a scheduler bug, fixed by commit b03e3d08379f236eb75b34c1b705e127c6e3b2e5
https://git.xenomai.org/xenomai-2.6.git/commit/?id=b03e3d08379f236eb75b34c1b705e127c6e3b2e5
- a bug in ARM VFP support, fixed by commit d4e755b2a9909afb7bbd0a522ff1d97718494cd7
https://git.xenomai.org/xenomai-2.6.git/commit/?id=d4e755b2a9909afb7bbd0a522ff1d97718494cd7

Users of the Xenomai 2.6 branch are encouraged to upgrade. It is expected to be the last release in the 2.6 branch. It supports all I-pipe patches up to those for Linux version 3.18. The short log follows.

Thanks to all contributors.

Gilles Chanteperdrix (45):
debian: also include the config directory in the xenomai-kernel-source package
hal: fixups for kernel 3.16
hal/arm: fixup for Linux 3.16
posix: fix user-space interrupt syscalls
hal/arm: simplify fpu handling
nucleus/registry: initialize vfile structure to 0
hal/xnlock: also indicate file, line and function in unlock debugging can/flexcan: avoid dereferencing clocks twice
nucleus/timers: fix the timers situation posix/clock_host_realtime: fix error handling
posix: avoid dereferencing user-space address
autotools: regenerate
sigdebug: add SIGDEBUG_RESCNT_IMBALANCE
posix/mutex: handle recursion count completely in user-space
posix: fix pthread_once
posix/mutex: avoid warnings
posix/once: cosmetic fixes
build: add .gitignore
nucleus: replace do_munmap with vm_munmap
nucleus/shadow: avoid tasklist_lock for find_task_by_pid hal/powerpc64: fix compilation with I-pipe patches >= 3.18 nucleus/shadow: fix crash with debugs enabled testsuite/cond-torture: increase sleep duration testsuite/mutex-torture: increase sleep duration testsuite/mutex-torture: avoid race-condition
nucleus/Kconfig: warn about CONFIG_MIGRATION
hal/arm: fix VFP support
testsuite/switchtest: detect more FPU errors.
x86/fptest: do not use the same value for all the registers
switchtest: set the registers before switching mode
hal/x86: forbid compilation with Linux 4.0+
switchtest: clarify the mode switch
x86/fptest: add missing asm constraints
switchtest: align kernel-space fpu register values posix/mutex,cond: allow static initializer
doc: adapt to different installations of asciidoc and doxygen
doc: fix generate-doc script after removal of docbook documentation posix/clock: remove documentation of internal function doc/sched: move sched documentation under nucleus section
bump version number and bootstrap
hal/arm: update patches
hal/blackfin: update I-pipe patches
hal/powerpc: update I-pipe patches
hal/x86: update I-pipe patches
doc: regenerate

Jeffrey Melville (2):
posix/doc: Fix sched_get_priority(min|max) doc
posix: fix pthread_mutex_timedlock for recursive mutexes.

Jorge Ramirez-Ortiz (2):
drivers/analogy: fix detach logic drivers/analogy: remove unnecessary spinlock

Matthew Lindner (1):
drivers/can: Properly initialize bittime

Philippe Gerum (14):
native: fix user-space interrupt syscalls
hal/arm: add specific calibration value for imx6q can/flexcan: fixup for kernel release >= 3.11 arm/hal: silence C89 warning
nucleus/pipe: care for spurious wakeups waiting for events
nucleus: add default calibration value for imx7
nucleus: fix calibration return for imx7 nucleus/pod: fix missed rescheduling in SMP rtipc/bufp: fix wrong TX timeout
hal/generic: add backward wrappers for legacy cpu mask ops scripts/prepare-kernel: allow building over 4.x kernel series ksrc, include: cope with introduction of user_msghdr testsuite/xeno-test-run: requesting /bin/sh is enough cobalt/x86: fix missing early clobber in asm

Stefan Roese (1):

      hal/arm: Add Zynq v3.14.17 patches
Signature · 1 line
					    Gilles.
#1 lore raw

Hey Gilles,

i just checked out the new release, which came as a surprise. Thanks for publishing that!

Some of the patches prepare for kernel 4.0+ but one specifically makes sure the combination 4.0+ and 2.6.5 wont work.

Am Sat, 9 Jul 2016 15:29:49 +0200
schrieb Gilles Chanteperdrix <[email protected]>:

...

Quoted 1 line

hal/x86: forbid compilation with Linux 4.0+

...

Could you please provide details on how the FPU support is broken. I am successfully using xenomai 2.6 with 4.1.18 for some time now. I am not sure whether the applications on top use the FPU and if so, if there are multiple FPU-users per core.

Henning

Quoted 45 lines

switchtest: clarify the mode switch
x86/fptest: add missing asm constraints
switchtest: align kernel-space fpu register values posix/mutex,cond: allow static initializer
doc: adapt to different installations of asciidoc and doxygen
doc: fix generate-doc script after removal of docbook
documentation posix/clock: remove documentation of internal function
doc/sched: move sched documentation under nucleus section bump version number and bootstrap
hal/arm: update patches
hal/blackfin: update I-pipe patches
hal/powerpc: update I-pipe patches
hal/x86: update I-pipe patches
doc: regenerate

Jeffrey Melville (2):
posix/doc: Fix sched_get_priority(min|max) doc
posix: fix pthread_mutex_timedlock for recursive mutexes.

Jorge Ramirez-Ortiz (2):
drivers/analogy: fix detach logic drivers/analogy: remove unnecessary spinlock

Matthew Lindner (1):
drivers/can: Properly initialize bittime

Philippe Gerum (14):
native: fix user-space interrupt syscalls
hal/arm: add specific calibration value for imx6q can/flexcan: fixup for kernel release >= 3.11 arm/hal: silence C89 warning
nucleus/pipe: care for spurious wakeups waiting for events
nucleus: add default calibration value for imx7
nucleus: fix calibration return for imx7 nucleus/pod: fix missed rescheduling in SMP rtipc/bufp: fix wrong TX timeout
hal/generic: add backward wrappers for legacy cpu mask ops scripts/prepare-kernel: allow building over 4.x kernel series ksrc, include: cope with introduction of user_msghdr testsuite/xeno-test-run: requesting /bin/sh is enough cobalt/x86: fix missing early clobber in asm

Stefan Roese (1):

      hal/arm: Add Zynq v3.14.17 patches
#2 lore raw

Am Mon, 1 Aug 2016 13:29:46 +0200
schrieb Henning Schild <[email protected]>:

Quoted 11 lines

Hey Gilles,

i just checked out the new release, which came as a surprise. Thanks for publishing that!

Some of the patches prepare for kernel 4.0+ but one specifically makes sure the combination 4.0+ and 2.6.5 wont work.

Am Sat, 9 Jul 2016 15:29:49 +0200
schrieb Gilles Chanteperdrix <[email protected]>:

Quoted 8 lines

...

Quoted 1 line

hal/x86: forbid compilation with Linux 4.0+

...

Could you please provide details on how the FPU support is broken. I am successfully using xenomai 2.6 with 4.1.18 for some time now. I am not sure whether the applications on top use the FPU and if so, if there are multiple FPU-users per core.

In continous integration the switchtest FPU test never triggered, not in 64 nor in 32-bit mode.

Henning

Quoted 53 lines

Henning

Quoted 42 lines

switchtest: clarify the mode switch
x86/fptest: add missing asm constraints
switchtest: align kernel-space fpu register values posix/mutex,cond: allow static initializer
doc: adapt to different installations of asciidoc and doxygen
doc: fix generate-doc script after removal of docbook
documentation posix/clock: remove documentation of internal function
doc/sched: move sched documentation under nucleus section bump version number and bootstrap
hal/arm: update patches
hal/blackfin: update I-pipe patches
hal/powerpc: update I-pipe patches
hal/x86: update I-pipe patches
doc: regenerate

Jeffrey Melville (2):
posix/doc: Fix sched_get_priority(min|max) doc
posix: fix pthread_mutex_timedlock for recursive mutexes.

Jorge Ramirez-Ortiz (2):
drivers/analogy: fix detach logic drivers/analogy: remove unnecessary spinlock

Matthew Lindner (1):
drivers/can: Properly initialize bittime

Philippe Gerum (14):
native: fix user-space interrupt syscalls
hal/arm: add specific calibration value for imx6q can/flexcan: fixup for kernel release >= 3.11 arm/hal: silence C89 warning
nucleus/pipe: care for spurious wakeups waiting for events
nucleus: add default calibration value for imx7
nucleus: fix calibration return for imx7 nucleus/pod: fix missed rescheduling in SMP rtipc/bufp: fix wrong TX timeout
hal/generic: add backward wrappers for legacy cpu mask ops scripts/prepare-kernel: allow building over 4.x kernel series ksrc, include: cope with introduction of user_msghdr testsuite/xeno-test-run: requesting /bin/sh is enough cobalt/x86: fix missing early clobber in asm

Quoted 3 lines

Stefan Roese (1):

      hal/arm: Add Zynq v3.14.17 patches

_______________________________________________
Xenomai mailing list
[email protected]
https://xenomai.org/mailman/listinfo/xenomai

#3 lore raw
Quoted 18 lines · Henning Schild

Am Mon, 1 Aug 2016 13:29:46 +0200
schrieb Henning Schild <[email protected]>:

Quoted 15 lines

Hey Gilles,

i just checked out the new release, which came as a surprise. Thanks for publishing that!

Some of the patches prepare for kernel 4.0+ but one specifically makes sure the combination 4.0+ and 2.6.5 wont work.

Am Sat, 9 Jul 2016 15:29:49 +0200
schrieb Gilles Chanteperdrix <[email protected]>:

...

Quoted 1 line

hal/x86: forbid compilation with Linux 4.0+

...

Quoted 7 lines
Quoted 4 lines

Could you please provide details on how the FPU support is broken. I am successfully using xenomai 2.6 with 4.1.18 for some time now. I am not sure whether the applications on top use the FPU and if so, if there are multiple FPU-users per core.

In continous integration the switchtest FPU test never triggered, not in 64 nor in 32-bit mode.

That is probably because you have one of the two options known to cause Linux to use FPU in kernel-space (raid or a K6 processor), which prevents the switchtest test itself to use the FPU in Linux kernel-space and test that we can preempt it in the middle of such usage. If that is the case, your continuous integration tests kernel logs should contain:

Warning: Linux is compiled to use FPU in kernel-space. For this reason, switchtest can not test using FPU in Linux kernel-space.

The kernels for continuous integration should be compiled without raid or X86_USE_3DNOW support, so that switchtest can test preempting Linux in the middle of using FPU in kernel-space, and if the test work, it should normally be safe to enable RAID or X86_USE_3DNOW in the production kernel.

If the test do not pass, and you enable, say RAID, on your production kernel, and actually use RAID, you can expect data corruption.

So, all in all, having that thing broken is better handled with a #error than with silent data corruption.

There may be other ways around though, such as forcing Linux to use integer implementation of RAID rather than FPU based version.

Signature · 1 line
					    Gilles.
#4 lore raw
In reply to Henning Schild
Quoted 11 lines · Henning Schild

Hey Gilles,

i just checked out the new release, which came as a surprise. Thanks for publishing that!

Some of the patches prepare for kernel 4.0+ but one specifically makes sure the combination 4.0+ and 2.6.5 wont work.

Am Sat, 9 Jul 2016 15:29:49 +0200
schrieb Gilles Chanteperdrix <[email protected]>:

Quoted 8 lines

...

Quoted 1 line

hal/x86: forbid compilation with Linux 4.0+

...

Could you please provide details on how the FPU support is broken. I am successfully using xenomai 2.6 with 4.1.18 for some time now. I am not sure whether the applications on top use the FPU and if so, if there are multiple FPU-users per core.

The FPU support is broken in the way it detects that Linux was using FPU in kernel-space (for RAID, or memcpy on oldish AMD processors, geode, K6, etc...) when Linux gets preempted. We can no longer rely on checking the bit TS in CR0, and need instead to use an accessor that was added in the I-pipe patch to know that. For details, see the changes that were made to FPU support for x86 in Xenomai 3.x.

Signature · 1 line
					    Gilles.
#5 lore raw
Quoted 21 lines · Gilles Chanteperdrix
Quoted 11 lines · Henning Schild

Hey Gilles,

i just checked out the new release, which came as a surprise. Thanks for publishing that!

Some of the patches prepare for kernel 4.0+ but one specifically makes sure the combination 4.0+ and 2.6.5 wont work.

Am Sat, 9 Jul 2016 15:29:49 +0200
schrieb Gilles Chanteperdrix <[email protected]>:

Quoted 8 lines

...

Quoted 1 line

hal/x86: forbid compilation with Linux 4.0+

...

Could you please provide details on how the FPU support is broken. I am successfully using xenomai 2.6 with 4.1.18 for some time now. I am not sure whether the applications on top use the FPU and if so, if there are multiple FPU-users per core.

Quoted 7 lines

The FPU support is broken in the way it detects that Linux was using FPU in kernel-space (for RAID, or memcpy on oldish AMD processors, geode, K6, etc...) when Linux gets preempted. We can no longer rely on checking the bit TS in CR0, and need instead to use an accessor that was added in the I-pipe patch to know that. For details, see the changes that were made to FPU support for x86 in Xenomai 3.x.

Are we doing eager switching there already? Would allow to use things as-is (i.e. without having to trap FPU accesses) on CPUs that are recent enough to do this switching lazily in hardware.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
#6 lore raw
Quoted 30 lines · Jan Kiszka
Quoted 21 lines · Gilles Chanteperdrix
Quoted 11 lines · Henning Schild

Hey Gilles,

i just checked out the new release, which came as a surprise. Thanks for publishing that!

Some of the patches prepare for kernel 4.0+ but one specifically makes sure the combination 4.0+ and 2.6.5 wont work.

Am Sat, 9 Jul 2016 15:29:49 +0200
schrieb Gilles Chanteperdrix <[email protected]>:

Quoted 8 lines

...

Quoted 1 line

hal/x86: forbid compilation with Linux 4.0+

...

Could you please provide details on how the FPU support is broken. I am successfully using xenomai 2.6 with 4.1.18 for some time now. I am not sure whether the applications on top use the FPU and if so, if there are multiple FPU-users per core.

Quoted 7 lines

The FPU support is broken in the way it detects that Linux was using FPU in kernel-space (for RAID, or memcpy on oldish AMD processors, geode, K6, etc...) when Linux gets preempted. We can no longer rely on checking the bit TS in CR0, and need instead to use an accessor that was added in the I-pipe patch to know that. For details, see the changes that were made to FPU support for x86 in Xenomai 3.x.

Quoted 3 lines

Are we doing eager switching there already? Would allow to use things as-is (i.e. without having to trap FPU accesses) on CPUs that are recent enough to do this switching lazily in hardware.

The problem has nothing to do with trapping FPU accesses or eager switching. Xenomai has always done eager switching. Xenomai 3 traps fpu access in order to arm the XNFPU bit on first fpu use and then does eager switching as usual.

Signature · 1 line
					    Gilles.
#7 lore raw
Quoted 31 lines · Gilles Chanteperdrix
Quoted 30 lines · Jan Kiszka
Quoted 28 lines · Gilles Chanteperdrix
Quoted 11 lines · Henning Schild

Hey Gilles,

i just checked out the new release, which came as a surprise. Thanks for publishing that!

Some of the patches prepare for kernel 4.0+ but one specifically makes sure the combination 4.0+ and 2.6.5 wont work.

Am Sat, 9 Jul 2016 15:29:49 +0200
schrieb Gilles Chanteperdrix <[email protected]>:

Quoted 8 lines

...

Quoted 1 line

hal/x86: forbid compilation with Linux 4.0+

...

Could you please provide details on how the FPU support is broken. I am successfully using xenomai 2.6 with 4.1.18 for some time now. I am not sure whether the applications on top use the FPU and if so, if there are multiple FPU-users per core.

The FPU support is broken in the way it detects that Linux was using FPU in kernel-space (for RAID, or memcpy on oldish AMD processors, geode, K6, etc...) when Linux gets preempted. We can no longer rely on checking the bit TS in CR0, and need instead to use an accessor that was added in the I-pipe patch to know that. For details, see the changes that were made to FPU support for x86 in Xenomai 3.x.

Quoted 8 lines
Quoted 3 lines

Are we doing eager switching there already? Would allow to use things as-is (i.e. without having to trap FPU accesses) on CPUs that are recent enough to do this switching lazily in hardware.

The problem has nothing to do with trapping FPU accesses or eager switching. Xenomai has always done eager switching. Xenomai 3 traps fpu access in order to arm the XNFPU bit on first fpu use and then does eager switching as usual.

Eager means always switch on flipping the context, irrespective of the previous usage. There is no trapping of FPU usage anymore then. Hardware does this much faster today when using xsave. Therefore upstream moved away from the lazy pattern apparently also still used in Xenomai.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
#8 lore raw
Quoted 41 lines · Jan Kiszka
Quoted 31 lines · Gilles Chanteperdrix
Quoted 30 lines · Jan Kiszka
Quoted 28 lines · Gilles Chanteperdrix
Quoted 11 lines · Henning Schild

Hey Gilles,

i just checked out the new release, which came as a surprise. Thanks for publishing that!

Some of the patches prepare for kernel 4.0+ but one specifically makes sure the combination 4.0+ and 2.6.5 wont work.

Am Sat, 9 Jul 2016 15:29:49 +0200
schrieb Gilles Chanteperdrix <[email protected]>:

Quoted 8 lines

...

Quoted 1 line

hal/x86: forbid compilation with Linux 4.0+

...

Could you please provide details on how the FPU support is broken. I am successfully using xenomai 2.6 with 4.1.18 for some time now. I am not sure whether the applications on top use the FPU and if so, if there are multiple FPU-users per core.

The FPU support is broken in the way it detects that Linux was using FPU in kernel-space (for RAID, or memcpy on oldish AMD processors, geode, K6, etc...) when Linux gets preempted. We can no longer rely on checking the bit TS in CR0, and need instead to use an accessor that was added in the I-pipe patch to know that. For details, see the changes that were made to FPU support for x86 in Xenomai 3.x.

Quoted 8 lines
Quoted 3 lines

Are we doing eager switching there already? Would allow to use things as-is (i.e. without having to trap FPU accesses) on CPUs that are recent enough to do this switching lazily in hardware.

The problem has nothing to do with trapping FPU accesses or eager switching. Xenomai has always done eager switching. Xenomai 3 traps fpu access in order to arm the XNFPU bit on first fpu use and then does eager switching as usual.

Quoted 4 lines

Eager means always switch on flipping the context, irrespective of the previous usage. There is no trapping of FPU usage anymore then. Hardware does this much faster today when using xsave. Therefore upstream moved away from the lazy pattern apparently also still used in Xenomai.

I know what eager means and Xenomai has always switched eagerly. But the difference with Linux is that a Xenomai task has an XNFPU bit indicating whether it wants to use the FPU or not. And obviously we do not switch eagerly FPU for tasks which do not have the XNFPU bit.

Now, in Xenomai 2.x the XNFPU bit was systematically set for user-space tasks, so that Xenomai always switched eagerly FPU for user-space tasks. With Xenomai 3, the change I have made for x86 and ARM is that a user-space task starts without the XNFPU bit, and if it uses the FPU once, it gets the trap, the XNFPU is set, then it gets eager switches forever after. So, it only gets a trap once. Now, that means that you have to pay the price of a fault, once. So, to do even better, Philippe has proposed to add the XNFPU bit to pthread_set_mode_np/rt_task_set_mode so that a user-space task can forcibly set the XNFPU bit.

But clearly, Xenomai switches FPU eagerly, and always has.

I am surprised to have to explain all this to you, I thought this was common knowledge.

Signature · 1 line
					    Gilles.
#9 lore raw
Quoted 63 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 31 lines · Gilles Chanteperdrix
Quoted 30 lines · Jan Kiszka
Quoted 28 lines · Gilles Chanteperdrix
Quoted 11 lines · Henning Schild

Hey Gilles,

i just checked out the new release, which came as a surprise. Thanks for publishing that!

Some of the patches prepare for kernel 4.0+ but one specifically makes sure the combination 4.0+ and 2.6.5 wont work.

Am Sat, 9 Jul 2016 15:29:49 +0200
schrieb Gilles Chanteperdrix <[email protected]>:

Quoted 8 lines

...

Quoted 1 line

hal/x86: forbid compilation with Linux 4.0+

...

Could you please provide details on how the FPU support is broken. I am successfully using xenomai 2.6 with 4.1.18 for some time now. I am not sure whether the applications on top use the FPU and if so, if there are multiple FPU-users per core.

The FPU support is broken in the way it detects that Linux was using FPU in kernel-space (for RAID, or memcpy on oldish AMD processors, geode, K6, etc...) when Linux gets preempted. We can no longer rely on checking the bit TS in CR0, and need instead to use an accessor that was added in the I-pipe patch to know that. For details, see the changes that were made to FPU support for x86 in Xenomai 3.x.

Quoted 8 lines
Quoted 3 lines

Are we doing eager switching there already? Would allow to use things as-is (i.e. without having to trap FPU accesses) on CPUs that are recent enough to do this switching lazily in hardware.

The problem has nothing to do with trapping FPU accesses or eager switching. Xenomai has always done eager switching. Xenomai 3 traps fpu access in order to arm the XNFPU bit on first fpu use and then does eager switching as usual.

Quoted 4 lines

Eager means always switch on flipping the context, irrespective of the previous usage. There is no trapping of FPU usage anymore then. Hardware does this much faster today when using xsave. Therefore upstream moved away from the lazy pattern apparently also still used in Xenomai.

I know what eager means and Xenomai has always switched eagerly. But the difference with Linux is that a Xenomai task has an XNFPU bit indicating whether it wants to use the FPU or not. And obviously we do not switch eagerly FPU for tasks which do not have the XNFPU bit.

Now, in Xenomai 2.x the XNFPU bit was systematically set for user-space tasks, so that Xenomai always switched eagerly FPU for user-space tasks. With Xenomai 3, the change I have made for x86 and ARM is that a user-space task starts without the XNFPU bit, and if it uses the FPU once, it gets the trap, the XNFPU is set, then it gets eager switches forever after. So, it only gets a trap once. Now, that means that you have to pay the price of a fault, once. So, to do even better, Philippe has proposed to add the XNFPU bit to pthread_set_mode_np/rt_task_set_mode so that a user-space task can forcibly set the XNFPU bit.

Quoted 5 lines

But clearly, Xenomai switches FPU eagerly, and always has.

I am surprised to have to explain all this to you, I thought this was common knowledge.

Commit 304bceda6a upstream:

x86, fpu: use non-lazy fpu restore for processors supporting xsave

Fundamental model of the current Linux kernel is to lazily init and restore FPU instead of restoring the task state during context switch. This changes that fundamental lazy model to the non-lazy model for the processors supporting xsave feature.

Reasons driving this model change are:

i. Newer processors support optimized state save/restore using xsaveopt and xrstor by tracking the INIT state and MODIFIED state during context-switch. This is faster than modifying the cr0.TS bit which has serializing semantics. [...]

(so it's xsaveopt, not just xsave - weak memory...)

Eager switching in this context means *unconditionally* eager, just dependent on the availability of this hardware feature, which is present on all modern system, high-end or low-end (will check tomorrow if we even have it on the Quark which is seriously low-end). This makes the code much simpler than the semi-eager model of Xenomai, at least for modern x86.

So the question here is not about low- vs. high-end but rather modern vs. legacy. We can't remove the lazy model yet, but the eager makes sense as well. Yes, this is an optimization (so is lazy switching), but apparently even of the worst case (which is nothing lazy switching is about) because we save the costly fiddling with cr0, unconditionally.

Jan

#10 lore raw
Quoted 86 lines · Jan Kiszka
Quoted 63 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 31 lines · Gilles Chanteperdrix
Quoted 30 lines · Jan Kiszka
Quoted 28 lines · Gilles Chanteperdrix
Quoted 11 lines · Henning Schild

Hey Gilles,

i just checked out the new release, which came as a surprise. Thanks for publishing that!

Some of the patches prepare for kernel 4.0+ but one specifically makes sure the combination 4.0+ and 2.6.5 wont work.

Am Sat, 9 Jul 2016 15:29:49 +0200
schrieb Gilles Chanteperdrix <[email protected]>:

Quoted 8 lines

...

Quoted 1 line

hal/x86: forbid compilation with Linux 4.0+

...

Could you please provide details on how the FPU support is broken. I am successfully using xenomai 2.6 with 4.1.18 for some time now. I am not sure whether the applications on top use the FPU and if so, if there are multiple FPU-users per core.

The FPU support is broken in the way it detects that Linux was using FPU in kernel-space (for RAID, or memcpy on oldish AMD processors, geode, K6, etc...) when Linux gets preempted. We can no longer rely on checking the bit TS in CR0, and need instead to use an accessor that was added in the I-pipe patch to know that. For details, see the changes that were made to FPU support for x86 in Xenomai 3.x.

Quoted 8 lines
Quoted 3 lines

Are we doing eager switching there already? Would allow to use things as-is (i.e. without having to trap FPU accesses) on CPUs that are recent enough to do this switching lazily in hardware.

The problem has nothing to do with trapping FPU accesses or eager switching. Xenomai has always done eager switching. Xenomai 3 traps fpu access in order to arm the XNFPU bit on first fpu use and then does eager switching as usual.

Quoted 4 lines

Eager means always switch on flipping the context, irrespective of the previous usage. There is no trapping of FPU usage anymore then. Hardware does this much faster today when using xsave. Therefore upstream moved away from the lazy pattern apparently also still used in Xenomai.

I know what eager means and Xenomai has always switched eagerly. But the difference with Linux is that a Xenomai task has an XNFPU bit indicating whether it wants to use the FPU or not. And obviously we do not switch eagerly FPU for tasks which do not have the XNFPU bit.

Now, in Xenomai 2.x the XNFPU bit was systematically set for user-space tasks, so that Xenomai always switched eagerly FPU for user-space tasks. With Xenomai 3, the change I have made for x86 and ARM is that a user-space task starts without the XNFPU bit, and if it uses the FPU once, it gets the trap, the XNFPU is set, then it gets eager switches forever after. So, it only gets a trap once. Now, that means that you have to pay the price of a fault, once. So, to do even better, Philippe has proposed to add the XNFPU bit to pthread_set_mode_np/rt_task_set_mode so that a user-space task can forcibly set the XNFPU bit.

Quoted 5 lines

But clearly, Xenomai switches FPU eagerly, and always has.

I am surprised to have to explain all this to you, I thought this was common knowledge.

Commit 304bceda6a upstream:

x86, fpu: use non-lazy fpu restore for processors supporting xsave

Fundamental model of the current Linux kernel is to lazily init and restore FPU instead of restoring the task state during context switch. This changes that fundamental lazy model to the non-lazy model for the processors supporting xsave feature.

Reasons driving this model change are:

i. Newer processors support optimized state save/restore using xsaveopt and xrstor by tracking the INIT state and MODIFIED state during context-switch. This is faster than modifying the cr0.TS bit which has serializing semantics. [...]

Quoted 8 lines

(so it's xsaveopt, not just xsave - weak memory...)

Eager switching in this context means *unconditionally* eager, just dependent on the availability of this hardware feature, which is present on all modern system, high-end or low-end (will check tomorrow if we even have it on the Quark which is seriously low-end). This makes the code much simpler than the semi-eager model of Xenomai, at least for modern x86.

As usual, you are spreading nonsense. Xenomai has been eager all the time. The difference is:
- Linux kernel threads do not have an FPU context
- Xenomai threads without the XNFPU bit do not have an FPU context.

So Xenomai, like Linux, chooses who has an FPU context that needs to be switched. And it has always been done it like that. Linux, like Xenomai, is conditionally eager. Some Xenomai kernel threads do have an FPU context (still, even in Xenomai 3.x, even though I doubt anyone uses it, because compiling kernel modules to use the FPU is probably not an easy task). Historically, all user-space threads had an FPU context (and were switched eagerly, not semi-anything).

What has changed is that in Xenomai 3.x, I have decided to start user-space threads without an FPU context, because I thought not all of them use it. This may add some overhead on the first FPU use, but after that, we switch eagerly. And if need be, Philippe solution to force the bit can be implemented. Or the 2.x behaviour can be reverted. But please stop making it a big deal.

It is the third time I explain the same thing a different way. There will not be a fourth time. I will not answer your next mail.

Quoted 6 lines

So the question here is not about low- vs. high-end but rather modern vs. legacy. We can't remove the lazy model yet, but the eager makes sense as well. Yes, this is an optimization (so is lazy switching), but apparently even of the worst case (which is nothing lazy switching is about) because we save the costly fiddling with cr0, unconditionally.

I think Atom processors can be considered "modern", but I doubt all off them have the new instructions. Especially the low power ones. And the embedded processors have always been Xenomai dual kernel targets. Because, on high-end processor, the differences in performances between dual kernel and native preemption are so ridiculously low.

And I think, with the dovetail project, this point is moot, because we are going to stop duplicating the FPU support in Xenomai code, which has been a pain to maintain, really, and get the I-pipe patch to provide access to Linux FPU handling code to the head domain. So, we are going to use the new instructions, without having to reinvent the wheel once again.

Signature · 1 line
					    Gilles.
#11 lore raw
Quoted 116 lines · Gilles Chanteperdrix
Quoted 86 lines · Jan Kiszka
Quoted 63 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 31 lines · Gilles Chanteperdrix
Quoted 30 lines · Jan Kiszka
Quoted 28 lines · Gilles Chanteperdrix
Quoted 11 lines · Henning Schild

Hey Gilles,

i just checked out the new release, which came as a surprise. Thanks for publishing that!

Some of the patches prepare for kernel 4.0+ but one specifically makes sure the combination 4.0+ and 2.6.5 wont work.

Am Sat, 9 Jul 2016 15:29:49 +0200
schrieb Gilles Chanteperdrix <[email protected]>:

Quoted 8 lines

...

Quoted 1 line

hal/x86: forbid compilation with Linux 4.0+

...

Could you please provide details on how the FPU support is broken. I am successfully using xenomai 2.6 with 4.1.18 for some time now. I am not sure whether the applications on top use the FPU and if so, if there are multiple FPU-users per core.

The FPU support is broken in the way it detects that Linux was using FPU in kernel-space (for RAID, or memcpy on oldish AMD processors, geode, K6, etc...) when Linux gets preempted. We can no longer rely on checking the bit TS in CR0, and need instead to use an accessor that was added in the I-pipe patch to know that. For details, see the changes that were made to FPU support for x86 in Xenomai 3.x.

Quoted 8 lines
Quoted 3 lines

Are we doing eager switching there already? Would allow to use things as-is (i.e. without having to trap FPU accesses) on CPUs that are recent enough to do this switching lazily in hardware.

The problem has nothing to do with trapping FPU accesses or eager switching. Xenomai has always done eager switching. Xenomai 3 traps fpu access in order to arm the XNFPU bit on first fpu use and then does eager switching as usual.

Quoted 4 lines

Eager means always switch on flipping the context, irrespective of the previous usage. There is no trapping of FPU usage anymore then. Hardware does this much faster today when using xsave. Therefore upstream moved away from the lazy pattern apparently also still used in Xenomai.

I know what eager means and Xenomai has always switched eagerly. But the difference with Linux is that a Xenomai task has an XNFPU bit indicating whether it wants to use the FPU or not. And obviously we do not switch eagerly FPU for tasks which do not have the XNFPU bit.

Now, in Xenomai 2.x the XNFPU bit was systematically set for user-space tasks, so that Xenomai always switched eagerly FPU for user-space tasks. With Xenomai 3, the change I have made for x86 and ARM is that a user-space task starts without the XNFPU bit, and if it uses the FPU once, it gets the trap, the XNFPU is set, then it gets eager switches forever after. So, it only gets a trap once. Now, that means that you have to pay the price of a fault, once. So, to do even better, Philippe has proposed to add the XNFPU bit to pthread_set_mode_np/rt_task_set_mode so that a user-space task can forcibly set the XNFPU bit.

Quoted 5 lines

But clearly, Xenomai switches FPU eagerly, and always has.

I am surprised to have to explain all this to you, I thought this was common knowledge.

Commit 304bceda6a upstream:

x86, fpu: use non-lazy fpu restore for processors supporting xsave

Fundamental model of the current Linux kernel is to lazily init and restore FPU instead of restoring the task state during context switch. This changes that fundamental lazy model to the non-lazy model for the processors supporting xsave feature.

Reasons driving this model change are:

i. Newer processors support optimized state save/restore using xsaveopt and xrstor by tracking the INIT state and MODIFIED state during context-switch. This is faster than modifying the cr0.TS bit which has serializing semantics. [...]

Quoted 8 lines

(so it's xsaveopt, not just xsave - weak memory...)

Eager switching in this context means *unconditionally* eager, just dependent on the availability of this hardware feature, which is present on all modern system, high-end or low-end (will check tomorrow if we even have it on the Quark which is seriously low-end). This makes the code much simpler than the semi-eager model of Xenomai, at least for modern x86.

As usual, you are spreading nonsense. Xenomai has been eager all the time. The difference is:
- Linux kernel threads do not have an FPU context
- Xenomai threads without the XNFPU bit do not have an FPU context.

So Xenomai, like Linux, chooses who has an FPU context that needs to be switched. And it has always been done it like that. Linux, like Xenomai, is conditionally eager. Some Xenomai kernel threads do have an FPU context (still, even in Xenomai 3.x, even though I doubt anyone uses it, because compiling kernel modules to use the FPU is probably not an easy task). Historically, all user-space threads had an FPU context (and were switched eagerly, not semi-anything).

What has changed is that in Xenomai 3.x, I have decided to start user-space threads without an FPU context, because I thought not all of them use it. This may add some overhead on the first FPU use, but after that, we switch eagerly. And if need be, Philippe solution to force the bit can be implemented. Or the 2.x behaviour can be reverted. But please stop making it a big deal.

Quoted 2 lines

It is the third time I explain the same thing a different way. There will not be a fourth time. I will not answer your next mail.

Sorry if I wasn't clear enough. I can only recommend to re-read the Xenomai code, specifically xnarch_switch_to (hint: clts, stts...), and then compare to the upstream kernel again and the commit I cited. It's probably best you figure this out yourself.

Quoted 15 lines
Quoted 7 lines

So the question here is not about low- vs. high-end but rather modern vs. legacy. We can't remove the lazy model yet, but the eager makes sense as well. Yes, this is an optimization (so is lazy switching), but apparently even of the worst case (which is nothing lazy switching is about) because we save the costly fiddling with cr0, unconditionally.

I think Atom processors can be considered "modern", but I doubt all off them have the new instructions. Especially the low power ones. And the embedded processors have always been Xenomai dual kernel targets. Because, on high-end processor, the differences in performances between dual kernel and native preemption are so ridiculously low.

Quoted 7 lines

And I think, with the dovetail project, this point is moot, because we are going to stop duplicating the FPU support in Xenomai code, which has been a pain to maintain, really, and get the I-pipe patch to provide access to Linux FPU handling code to the head domain. So, we are going to use the new instructions, without having to reinvent the wheel once again.

That will indeed resolve this issue elegantly.

Jan

#12 lore raw
Quoted 13 lines · Jan Kiszka

Sorry if I wasn't clear enough. I can only recommend to re-read the Xenomai code, specifically xnarch_switch_to (hint: clts, stts...), and then compare to the upstream kernel again and the commit I cited. It's probably best you figure this out yourself.

Quoted 8 lines
Quoted 8 lines

Commit 304bceda6a upstream:

x86, fpu: use non-lazy fpu restore for processors supporting xsave

Fundamental model of the current Linux kernel is to lazily init and restore FPU instead of restoring the task state during context switch. This changes that fundamental lazy model to the non-lazy model for the processors supporting xsave feature.

I do not think that you are not clear. The commit message is clear enough and in line with how I have been seeing Linux switching FPU context on x86 for years: it was switching out FPU context during context switch to avoid SMP races, and switching in FPU context upon FPU faults (at the very beginning, with some refinements as time changed, with a counter that caused switching to eager after 5 context switches where the FPU had been used), hence "lazily restore FPU" in the commit message; this was lazy switching. Xenomai saves and restores unconditionally (if the XNFPU bit is set) the FPU context at every context switch.

Look at Xenomai 2.1 code:
https://git.xenomai.org/xenomai-2.0.git/tree/nucleus/pod.c#n2139

This is __xnpod_switch_fpu, the function which switches the FPU context.

And this function is called here:
https://git.xenomai.org/xenomai-2.0.git/tree/nucleus/pod.c#n2446

That is, in the middle of the context switch. No fault. Nothing lazy. Ergo eager.

The particular instructions used (clts, stts) has nothing to do with whether this is eager or not. Yes, clts and stts may be slow on new high end hardware, but as I said, we do not care about new high end hardware, because it has no valid reason whatsoever to be running a dual kernel.

Signature · 1 line
					    Gilles.
#13 lore raw
In reply to Jan Kiszka
Quoted 41 lines · Jan Kiszka
Quoted 31 lines · Gilles Chanteperdrix
Quoted 30 lines · Jan Kiszka
Quoted 28 lines · Gilles Chanteperdrix
Quoted 11 lines · Henning Schild

Hey Gilles,

i just checked out the new release, which came as a surprise. Thanks for publishing that!

Some of the patches prepare for kernel 4.0+ but one specifically makes sure the combination 4.0+ and 2.6.5 wont work.

Am Sat, 9 Jul 2016 15:29:49 +0200
schrieb Gilles Chanteperdrix <[email protected]>:

Quoted 8 lines

...

Quoted 1 line

hal/x86: forbid compilation with Linux 4.0+

...

Could you please provide details on how the FPU support is broken. I am successfully using xenomai 2.6 with 4.1.18 for some time now. I am not sure whether the applications on top use the FPU and if so, if there are multiple FPU-users per core.

The FPU support is broken in the way it detects that Linux was using FPU in kernel-space (for RAID, or memcpy on oldish AMD processors, geode, K6, etc...) when Linux gets preempted. We can no longer rely on checking the bit TS in CR0, and need instead to use an accessor that was added in the I-pipe patch to know that. For details, see the changes that were made to FPU support for x86 in Xenomai 3.x.

Quoted 8 lines
Quoted 3 lines

Are we doing eager switching there already? Would allow to use things as-is (i.e. without having to trap FPU accesses) on CPUs that are recent enough to do this switching lazily in hardware.

The problem has nothing to do with trapping FPU accesses or eager switching. Xenomai has always done eager switching. Xenomai 3 traps fpu access in order to arm the XNFPU bit on first fpu use and then does eager switching as usual.

Quoted 4 lines

Eager means always switch on flipping the context, irrespective of the previous usage. There is no trapping of FPU usage anymore then. Hardware does this much faster today when using xsave. Therefore upstream moved away from the lazy pattern apparently also still used in Xenomai.

besides, optimizing the case of high-end does not really make sense for Xenomai. We prefer to optimize the case of low-end, even if it has a small cost for high-end. We target good worst case, remember?

Signature · 1 line
					    Gilles.
#14 lore raw
In reply to Henning Schild
Quoted 5 lines · Henning Schild

Hey Gilles,

i just checked out the new release, which came as a surprise. Thanks for publishing that!

Quoted 8 lines

Some of the patches prepare for kernel 4.0+ but one specifically makes sure the combination 4.0+ and 2.6.5 wont work.

Am Sat, 9 Jul 2016 15:29:49 +0200
schrieb Gilles Chanteperdrix <[email protected]>:

...

Quoted 1 line

hal/x86: forbid compilation with Linux 4.0+

Actually, the commit message is prefixed with hal/x86, so it only makes sure that the combination 4.0+ and 2.6.5 does not work on x86. It does not make sure that the combination does not work for other architectures.

Signature · 1 line
					    Gilles.