Skip to contentSkip to conversation

Minor page faults from pthread_create()

DISCUSSION Adrian Knoth 4 participants 4 messages Jan 6, 2012 – Jan 9, 2012

lore
Share & tools
lore
#0 lore raw

Hi!

While playing with

https://rt.wiki.kernel.org/articles/t/h/r/Threaded_RT-application_with_memory_locking_and_stack_handling_example_f48b.html

I was wondering why pthread_create() should cause minor page faults when there is a pre-allocated pre-faulted 100MB memory pool.

Simply running the example causes roughly 30 minor page faults. When I manually allocate stack memory for the stack (after mlockall() and mallopt have been called) and use pthread_attr_setstack() before calling pthread_create(), minor page faults drop to 2.

Does anybody happen to know what is causing these remaining two page faults? My only guess so far is kernel memory to hold some organizational data for the new thread after clone() has been invoked, but this could also be completely wrong.

Note that I don't need to get page faults down to 0, I'm only looking for an explanation to understand the issue at hand to confirm that pthread_create() must not be used from an RT context.

TIA

#1 lore raw

Hi,

2012/1/6 Adrian Knoth <[email protected]>:

Quoted 2 lines

I was wondering why pthread_create() should cause minor page faults when there is a pre-allocated pre-faulted 100MB memory pool.

That pre-allocated block of memory is used by Glibc for its malloc routines. While doing a pthread_create() you go to the kernel. Inside the kernel many functions allocate memory as well. This is outside the control of the C-library.
Probably some function inside the kernel allocates this memory and uses it, resulting in these page-faults.
One example is allocating memory for the stack.

Kind regards,

Remy

#2 lore raw

Re: Minor page faults from pthread_create() aka still problems with 3.0.12-rt30

In reply to Adrian Knoth

Hi

Quoted 5 lines

Simply running the example causes roughly 30 minor page faults. When I manually allocate stack memory for the stack (after mlockall() and mallopt have been called) and use pthread_attr_setstack() before calling pthread_create(), minor page faults drop to 2.

Quoted 8 lines

Does anybody happen to know what is causing these remaining two page faults? My only guess so far is kernel memory to hold some organizational data for the new thread after clone() has been invoked, but this could also be completely wrong.

Note that I don't need to get page faults down to 0, I'm only looking for an explanation to understand the issue at hand to confirm that pthread_create() must not be used from an RT context.

While unfortunatly i can't help i've got the impression that something is still strange with 3.0.12pmx-rt30. (This is on a arm i.mx35 with some platform adaptations and a cyclic clock interrupt.). I haven't build a newer version of 3.0-rt yet.

See my mail where i describe this problem here.
https://lkml.org/lkml/2011/12/7/657

I am ocasionally also seeing a ksoftirqd/0 running on as much cpu as it gets. This is always when i see the message: sched: RT throttling activated

Not the best start into the new year :-(.

Best regards
Tim

Please ignore:

Hottinger Baldwin Messtechnik GmbH, Im Tiefen See 45, 64293 Darmstadt, Germany | www.hbm.com

Registered as GmbH (German limited liability corporation) in the commercial register at the local court of Darmstadt, HRB 1147 Company domiciled in Darmstadt | CEO: Andreas Huellhorst | Chairman of the board: James Charles Webster

Als Gesellschaft mit beschraenkter Haftung eingetragen im Handelsregister des Amtsgerichts Darmstadt unter HRB 1147 Sitz der Gesellschaft: Darmstadt | Geschaeftsfuehrung: Andreas Huellhorst | Aufsichtsratsvorsitzender: James Charles Webster

The information in this email is confidential. It is intended solely for the addressee. If you are not the intended recipient, please let me know and delete this email.

Die in dieser E-Mail enthaltene Information ist vertraulich und lediglich für den Empfaenger bestimmt. Sollten Sie nicht der eigentliche Empfaenger sein, informieren Sie mich bitte kurz und loeschen diese E-Mail. --
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Adrian Knoth

Em Fri, Jan 06, 2012 at 09:46:29PM +0100, Adrian Knoth escreveu:

Quoted 12 lines

While playing with

https://rt.wiki.kernel.org/articles/t/h/r/Threaded_RT-application_with_memory_locking_and_stack_handling_example_f48b.html

I was wondering why pthread_create() should cause minor page faults when there is a pre-allocated pre-faulted 100MB memory pool.

Simply running the example causes roughly 30 minor page faults. When I manually allocate stack memory for the stack (after mlockall() and mallopt have been called) and use pthread_attr_setstack() before calling pthread_create(), minor page faults drop to 2.

Quoted 8 lines

Does anybody happen to know what is causing these remaining two page faults? My only guess so far is kernel memory to hold some organizational data for the new thread after clone() has been invoked, but this could also be completely wrong.

Note that I don't need to get page faults down to 0, I'm only looking for an explanation to understand the issue at hand to confirm that pthread_create() must not be used from an RT context.

Try:

$ perf record --event minor-faults --call-graph your-program
$ perf report

Should answer that question if running on a -fno-omit-frame-pointer binary world. Or at least provide the callchains for the kernel part of the call chains.

32-bit distros should be OK in that respect.

- Arnaldo