(rt_)printf and virtual memory
Hi all,
consider the simple code attached.
I'm using Xenomai 3.1 on a x86_64 CPU, 2GB RAM.
I compile and link the code using "xeno-config --skin=alchemy --cflags" and "xeno-config --skin=alchemy --ldflags"
* Scenario 1)
#define printf rt_printf commented out (use printf for prints)
Changing the NUM_TASKS value, in top command I see these results:
- NUM_TASKS 2
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
496 480 root S 80068 4% 0% ./test
- NUM_TASKS 4
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
496 480 root S 80204 4% 0% ./test
- NUM_TASKS 5
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
496 480 root S 80272 4% 0% ./test
- NUM_TASKS 6
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
496 480 root S 80340 4% 0% ./test
Virtual memory size increases in a linear way.
* Scenario 2)
#define printf rt_printf not commented (use rt_printf for prints)
Changing the NUM_TASKS value, in top command I see these results:
- NUM_TASKS 2
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
496 480 root S 80068 4% 0% ./test
- NUM_TASKS 4
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
496 480 root S 80204 4% 0% ./test
- NUM_TASKS 5
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
496 480 root S 142M 4% 0% ./test
- NUM_TASKS 6
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
496 480 root S 206M 4% 0% ./test
Starting from a number of tasks > 4, the VMEM got a jump and then increases very rapidly.
Is it normal? Or I'm misusing the rt_printf?
Thanks in advance, regards
---
Mauro S.
Il 07/09/21 11:21, Mauro S. via Xenomai ha scritto:
Quoted 62 lines
Hi all,
consider the simple code attached.
I'm using Xenomai 3.1 on a
x86_64CPU, 2GB RAM.I compile and link the code using "xeno-config --skin=alchemy --cflags" and "xeno-config --skin=alchemy --ldflags"
* Scenario 1)
#define printfrt_printfcommented out (use printf for prints)Changing the
NUM_TASKSvalue, in top command I see these results:-
NUM_TASKS2PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 80068 4% 0% ./test
-
NUM_TASKS4PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 80204 4% 0% ./test
-
NUM_TASKS5PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 80272 4% 0% ./test
-
NUM_TASKS6PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 80340 4% 0% ./test
Virtual memory size increases in a linear way.
* Scenario 2)
#define printfrt_printfnot commented (usert_printffor prints)Changing the
NUM_TASKSvalue, in top command I see these results:-
NUM_TASKS2PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 80068 4% 0% ./test
-
NUM_TASKS4PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 80204 4% 0% ./test
-
NUM_TASKS5PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 142M 4% 0% ./test
-
NUM_TASKS6PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 206M 4% 0% ./test
Quoted 5 lines
Starting from a number of tasks > 4, the VMEM got a jump and then increases very rapidly.
Is it normal? Or I'm misusing the
rt_printf?Thanks in advance, regards
Damn, I forgot the attachment, sorry.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.c
Type: text/x-csrc
Size: 1229 bytes
Desc: not available
URL: <http://xenomai.org/pipermail/xenomai/attachments/20210907/0e3c2f5b/attachment.c>
Quoted 59 lines · Mauro S. via Xenomai
Hi all,
consider the simple code attached.
I'm using Xenomai 3.1 on a
x86_64CPU, 2GB RAM.I compile and link the code using "xeno-config --skin=alchemy --cflags" and "xeno-config --skin=alchemy --ldflags"
* Scenario 1)
#define printfrt_printfcommented out (use printf for prints)Changing the
NUM_TASKSvalue, in top command I see these results:-
NUM_TASKS2PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 80068 4% 0% ./test
-
NUM_TASKS4PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 80204 4% 0% ./test
-
NUM_TASKS5PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 80272 4% 0% ./test
-
NUM_TASKS6PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 80340 4% 0% ./test
Virtual memory size increases in a linear way.
* Scenario 2)
#define printfrt_printfnot commented (usert_printffor prints)Changing the
NUM_TASKSvalue, in top command I see these results:-
NUM_TASKS2PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 80068 4% 0% ./test
-
NUM_TASKS4PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 80204 4% 0% ./test
-
NUM_TASKS5PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 142M 4% 0% ./test
-
NUM_TASKS6
Quoted 8 lines
PID PPID USER STAT VSZ %VSZ %CPU COMMAND 496 480 root S 206M 4% 0% ./test
Starting from a number of tasks > 4, the VMEM got a jump and then increases very rapidly.
Is it normal? Or I'm misusing the
rt_printf?
No, that's related to glibc's internal memory allocation strategy. I didn't dig into details, but you can easily trigger enormous virtual memory reservations (which are not real memory, as we know) by adding a pre-thread malloc(1) to your program - without using rt_printf.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Il 09/09/21 20:44, Jan Kiszka ha scritto:
Quoted 1 line · Mauro S. via Xenomai
..snip..
Quoted 4 lines
Quoted 4 lines
Starting from a number of tasks > 4, the VMEM got a jump and then increases very rapidly.
Quoted 9 lines
Quoted 1 line
Is it normal? Or I'm misusing the
rt_printf?No, that's related to glibc's internal memory allocation strategy. I didn't dig into details, but you can easily trigger enormous virtual memory reservations (which are not real memory, as we know) by adding a pre-thread malloc(1) to your program - without using
rt_printf.Jan
Hi Jan,
ok thank you.
Regards
Signature · 1 line
Mauro