Skip to contentSkip to conversation

User space stack pre-faulting

Xenomai-core Jan Kiszka 2 participants 5 messages Jun 22, 2011

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

Hi Gilles,

do you remember reasons for only pre-faulting the main thread's stack? The desire to avoid wasting resources by forcing all stacks into memory?

I've the requirement on my table to provide a generic solution of all shadow threads. I think this should be possible using pthread_getattr_np and walking the stack page-wise, but I may miss some pitfall.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#1 lore raw
Quoted 8 lines · Jan Kiszka

Hi Gilles,

do you remember reasons for only pre-faulting the main thread's stack? The desire to avoid wasting resources by forcing all stacks into memory?

I've the requirement on my table to provide a generic solution of all shadow threads. I think this should be possible using pthread_getattr_np and walking the stack page-wise, but I may miss some pitfall.

Last time I checked, only the main thread stack was mapped on demand. Other threads have mmaped stacks, which are made present by mlockall, so, do not need faulting.

Signature · 1 line
                                                                Gilles.
author
#2 lore raw
Quoted 6 lines · Gilles Chanteperdrix
Quoted 5 lines · Jan Kiszka

Hi Gilles,

do you remember reasons for only pre-faulting the main thread's stack? The desire to avoid wasting resources by forcing all stacks into memory?

Quoted 7 lines
Quoted 3 lines

I've the requirement on my table to provide a generic solution of all shadow threads. I think this should be possible using pthread_getattr_np and walking the stack page-wise, but I may miss some pitfall.

Last time I checked, only the main thread stack was mapped on demand. Other threads have mmaped stacks, which are made present by mlockall, so, do not need faulting.

That's definitely not the case in general. Customer has just confirmed that pre-faulting thread stacks avoids first-access domain switches.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#3 lore raw
Quoted 11 lines · Jan Kiszka
Quoted 10 lines · Gilles Chanteperdrix
Quoted 8 lines · Jan Kiszka

Hi Gilles,

do you remember reasons for only pre-faulting the main thread's stack? The desire to avoid wasting resources by forcing all stacks into memory?

I've the requirement on my table to provide a generic solution of all shadow threads. I think this should be possible using pthread_getattr_np and walking the stack page-wise, but I may miss some pitfall.

Quoted 6 lines
Quoted 3 lines

Last time I checked, only the main thread stack was mapped on demand. Other threads have mmaped stacks, which are made present by mlockall, so, do not need faulting.

That's definitely not the case in general. Customer has just confirmed that pre-faulting thread stacks avoids first-access domain switches.

self-contained test case please.

Quoted 3 lines

Jan

Signature · 1 line
                                                                Gilles.
author
#4 lore raw
Quoted 12 lines · Gilles Chanteperdrix
Quoted 11 lines · Jan Kiszka
Quoted 10 lines · Gilles Chanteperdrix
Quoted 8 lines · Jan Kiszka

Hi Gilles,

do you remember reasons for only pre-faulting the main thread's stack? The desire to avoid wasting resources by forcing all stacks into memory?

I've the requirement on my table to provide a generic solution of all shadow threads. I think this should be possible using pthread_getattr_np and walking the stack page-wise, but I may miss some pitfall.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Last time I checked, only the main thread stack was mapped on demand. Other threads have mmaped stacks, which are made present by mlockall, so, do not need faulting.

That's definitely not the case in general. Customer has just confirmed that pre-faulting thread stacks avoids first-access domain switches.

self-contained test case please.

Yes, will check this. Currently distracted again by a higher prio oops :-/.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux