Minor page faults from memory compaction causing in-band transitions
Subsystems (2)
Hi Xenomai team,
I'm working on a real-time control application using Xenomai and we've been experiencing unexpected in-band transitions caused by minor page faults during kernel memory compaction. Even though our RT threads use mlockall(MCL_CURRENT | MCL_FUTURE) and we've pre-faulted memory, the kernel's compaction process seems to temporarily invalidate PTEs on our locked pages, causing faults when the RT thread accesses them.
Has this issue come up before? I'm wondering if there's a mechanism to reserve a section of RAM that's excluded from compaction/migration entirely, or if there are kernel/Xenomai configurations we should be using to prevent this.
Any guidance would be appreciated!
Thanks,
Brandon
Quoted 9 lines · Brandon Ho
Hi Xenomai team,
I'm working on a real-time control application using Xenomai and we've been experiencing unexpected in-band transitions caused by minor page faults during kernel memory compaction. Even though our RT threads use
mlockall(MCL_CURRENT | MCL_FUTURE)and we've pre-faulted memory, the kernel's compaction process seems to temporarily invalidate PTEs on our locked pages, causing faults when the RT thread accesses them.
Quoted 5 lines
Has this issue come up before? I'm wondering if there's a mechanism to reserve a section of RAM that's excluded from compaction/migration entirely, or if there are kernel/Xenomai configurations we should be using to prevent this.
Any guidance would be appreciated!
Memory migration as well as compaction are not compatible with deterministic system behavior. Both Xenomai 3 and 4 should warn about them, and you should disabling these features in your kernel. Unfortunately, current kernels do not allow a more fine-grained control.
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Quoted 10 lines · Brandon Ho
Hi Xenomai team,
I'm working on a real-time control application using Xenomai and we've been experiencing unexpected in-band transitions caused by minor page faults during kernel memory compaction. Even though our RT threads use
mlockall(MCL_CURRENT | MCL_FUTURE)and we've pre-faulted memory, the kernel's compaction process seems to temporarily invalidate PTEs on our locked pages, causing faults when the RT thread accesses them.Has this issue come up before?
Yes, this is a known issue.
Quoted 3 lines
I'm wondering if there's a mechanism to reserve
a section of RAM that's excluded from compaction/migration entirely, or if
Not to my knowledge.
Quoted 4 lines
there are kernel/Xenomai configurations we should be using to prevent this.
Any guidance would be appreciated!
As Jan mentioned, the only way is to disable all options which select CONFIG_COMPACTION ATM.
Signature · 1 line
Philippe.
Thank you for the responses! I recently came across the compact_unevictable_allowed sysctl option and it seems like it could be a good fit for our use case. Setting it to 0 would prevent the kernel from compacting/migrating locked pages, which should eliminate the minor faults we're seeing during compaction.
Could we possibly set compact_unevictable_allowed=0 by default when CONFIG_EVL is enabled?
Quoted 8 lines · Brandon Ho
Thank you for the responses! I recently came across the
compact_unevictable_allowedsysctl option and it seems like it could be a good fit for our use case. Setting it to 0 would prevent the kernel from compacting/migrating locked pages, which should eliminate the minor faults we're seeing during compaction.Could we possibly set
compact_unevictable_allowed=0by default whenCONFIG_EVLis enabled?
Definitely, yes. Thanks for chasing this issue down. This patch is going to be merged upstream asap, you may want to apply it for a preview.
mm/Kconfig +1 -1
@@ -648,7 +648,7 @@ config COMPACTION config COMPACT_UNEVICTABLE_DEFAULT int depends on COMPACTION - default 0 if PREEMPT_RT + default 0 if PREEMPT_RT || DOVETAIL default 1 #
Quoted 2 lines
Signature · 1 line
Philippe.
A message that is not in the archive (sent off-list or not yet received): CY1P110MB0760484C0708C37BA89D5A02D624A@CY1P110MB0760.NAMP110.PROD.OUTLOOK.COM
Quoted 2 lines · Jay Sridharan
I think it would also be very useful to add these considerations to the "Caveat" page in the EVL documentation.
Agreed.
Quoted 7 lines
Perhaps some discussion on the impacts of
CONFIG_COMPACTION,CONFIG_MIGRATIONandCONFIG_TRANSPARENT_HUGEPAGE, as well as the impact ofCOMPACT_UNEVICTABLE_DEFAULT.I know the Caveat page already has an in-depth discussion of CPU isolation and SMIs, so it feels like a good place to mention it.
Is there a place where we can submit a patch to the docs?
Yes, please send a patch to this list, the markdown files for the website can be cloned from [1].
[1] https://gitlab.com/Xenomai/xenomai4/website
Signature · 1 line
Philippe.
Quoted 8 lines · Philippe Gerum
Quoted 6 lines · Brandon Ho
Thank you for the responses! I recently came across the
compact_unevictable_allowedsysctl option and it seems like it could be a good fit for our use case. Setting it to 0 would prevent the kernel from compacting/migrating locked pages, which should eliminate the minor faults we're seeing during compaction.
Quoted 5 lines
Quoted 2 lines
Could we possibly set
compact_unevictable_allowed=0by default whenCONFIG_EVLis enabled?Definitely, yes. Thanks for chasing this issue down. This patch is going to be merged upstream asap, you may want to apply it for a preview.
Targeting linux-evl or linux-dovetail?
This is of interest for Xenomai 3 as well, so merging on Dovetail-level would be nice.
The same applies for the documentation update. Once we have it for x4 we should consider that for x4 as well.
Quoted 20 lines
mm/Kconfig +0
-0@@ -648,7 +648,7 @@ config COMPACTIONconfig
COMPACT_UNEVICTABLE_DEFAULT
int
depends on COMPACTIONmm/Kconfig +1
-1- default 0 if PREEMPT_RT + default 0 if PREEMPT_RT || DOVETAILdefault 1
#Quoted 2 lines
--
Philippe.
Quoted 9 lines · Florian Bezdeka
Quoted 8 lines · Philippe Gerum
Quoted 6 lines · Brandon Ho
Thank you for the responses! I recently came across the
compact_unevictable_allowedsysctl option and it seems like it could be a good fit for our use case. Setting it to 0 would prevent the kernel from compacting/migrating locked pages, which should eliminate the minor faults we're seeing during compaction.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Could we possibly set
compact_unevictable_allowed=0by default whenCONFIG_EVLis enabled?Definitely, yes. Thanks for chasing this issue down. This patch is going to be merged upstream asap, you may want to apply it for a preview.
Targeting linux-evl or linux-dovetail?
linux-dovetail, this is a general issue for any latency-sensitive code.
Signature · 1 line
Philippe.
Quoted 14 lines · Philippe Gerum
Quoted 12 lines · Florian Bezdeka
Quoted 11 lines · Philippe Gerum
Quoted 8 lines · Brandon Ho
Thank you for the responses! I recently came across the
compact_unevictable_allowedsysctl option and it seems like it could be a good fit for our use case. Setting it to 0 would prevent the kernel from compacting/migrating locked pages, which should eliminate the minor faults we're seeing during compaction.Could we possibly set
compact_unevictable_allowed=0by default whenCONFIG_EVLis enabled?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Definitely, yes. Thanks for chasing this issue down. This patch is going to be merged upstream asap, you may want to apply it for a preview.
Targeting linux-evl or linux-dovetail?
linux-dovetail, this is a general issue for any latency-sensitive code.
While reviewing all PREEMPT_RT exclusion cases in Kconfigs, some of which Dovetail may want to share, I found this potential one:
init/Kconfig +1 -1
@@ -947,7 +947,7 @@ config NUMA_BALANCING bool "Memory placement aware NUMA scheduler" depends on ARCH_SUPPORTS_NUMA_BALANCING depends on !ARCH_WANT_NUMA_VARIABLE_LOCALITY - depends on SMP && NUMA && MIGRATION && !PREEMPT_RT + depends on SMP && NUMA && MIGRATION && !PREEMPT_RT && !DOVETAIL
Any objection to disabling NUMA_BALANCING when operating in dual kernel mode? (CONFIG_DOVETAIL=y).
Signature · 1 line
Philippe.