add mlockall option to cyclictest, et al
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Thomas,
Got a couple of requests for mlockall() in cyclictest, so I added an --mlockall option to cyclictest, signaltest and pi_stress.
Patches attached.
Clark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iEYEARECAAYFAkgknisACgkQqA4JVb61b9e+5wCgkfnFdvymSXLsxQ9AwhVU9te+ J9YAniZv12Xj1r6epjft/L/CLv3P1Yl4
=ismw
-----END PGP SIGNATURE-----
From c4a44c163df791ec3f42075e587685fa7e5b031d Mon Sep 17 00:00:00 2001
From: Clark Williams <[email protected]>
Date: Fri, 9 May 2008 13:28:50 -0500
Subject: [PATCH] added mlockall option
--- .gitignore | 4 ++++ src/cyclictest/cyclictest.c | 18 +++++++++++++++++- src/pi_tests/pi_stress.c | 18 ++++++++++++++++++ src/signaltest/signaltest.c | 16 +++++++++++++++- 4 files changed, 54 insertions(+), 2 deletions(-)
.gitignore +4 -0
@@ -8,3 +8,7 @@ releases BUILD RPMS SRPMS +classic_pi +pi_stress +cyclictest +signaltest
src/cyclictest/cyclictest.c +17 -1
@@ -30,6 +30,7 @@#include <sys/types.h> #include <sys/time.h> #include <sys/utsname.h> +#include <sys/mman.h> #define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0]))
@@ -119,6 +120,7 @@ static int ftrace = 0;static int kernelversion;static int verbose =0 ;static int oscope_reduction =1 ; +static int lockall =0 ;/* Backup of kernel variables that we modify */ static struct kvars {
@@ -478,6 +480,7 @@ static void display_help(void)"-s --system use sys_nanosleep and sys_setitimer\n" "-t --threads one thread per available processor\n" "-t NUM --threads=NUM number of threads: without -t default=1\n" +"-m --mlockall lock current and future memory allocations\n" "-v --verbose output values on stdout for statistics\n" " format: n:c:v n=tasknum c=count v=value in us\n");exit (0 );
@@ -531,11 +534,12 @@ static void process_options (int argc, char *argv[]) {"relative", no_argument, NULL, 'r'}, {"system", no_argument, NULL, 's'}, {"threads", optional_argument, NULL, 't'}, + {"mlockall", no_argument, NULL, 'm' }, {"verbose", no_argument, NULL, 'v'}, {"help", no_argument, NULL, '?'}, {NULL, 0, NULL, 0} }; -int c =getopt_long (argc, argv,"a::b:c:d:fi:l:no:p:qrst::v" , +int c =getopt_long (argc, argv,"a::b:c:d:fi:l:no:p:qrsmt::v" , long_options, &option_index);if (c ==-1 )break ;
@@ -566,6 +570,7 @@ static void process_options (int argc, char *argv[]) num_threads = max_cpus;break ;case 'v' : verbose =1 ;break ; +case 'm' : lockall =1 ;break ;case '?' : error =1 ;break ; } }
@@ -696,6 +701,13 @@ int main(int argc, char **argv)process_options (argc, argv); +/* lock all memory (prevent paging) */ +if (lockall) +if (mlockall (MCL_CURRENT |MCL_FUTURE ) ==-1 ) { +perror ("mlockall" ); + goto out; + } + kernelversion =check_kernel ();if (kernelversion ==KV_NOT_26 )
@@ -809,6 +821,10 @@ int main(int argc, char **argv)free (par); out: +/* unlock everything */ +if (lockall) +munlockall (); +/* Be a nice program, cleanup */ if (kernelversion !=KV_26_CURR )restorekernvars ();
src/pi_tests/pi_stress.c +18 -0
@@ -51,6 +51,7 @@#include <signal.h> #include <getopt.h> #include <sys/types.h> +#include <sys/mman.h> #include <sys/wait.h> #include <termios.h>
@@ -128,6 +129,9 @@ int have_errors = 0;// force running on one cpu int uniprocessor =0 ; +// lock all memory +int lockall =0 ; +// command line options struct option options [] = { {"duration" , required_argument,NULL ,'t' },
@@ -141,6 +145,7 @@ struct option options [] = { { "prompt", no_argument, NULL, 'p'}, { "debug", no_argument, NULL, 'd'}, { "version", no_argument, NULL, 'V'}, + { "mlockall", no_argument, NULL, 'm'}, { "help", no_argument, NULL, 'h'}, { NULL, 0, NULL, 0}, };
@@ -234,6 +239,13 @@ main (int argc, char **argv)/* process command line arguments */ process_command_line (argc, argv); +/* lock memory */ +if (lockall) +if (mlockall (MCL_CURRENT |MCL_FUTURE ) ==-1 ) { +error ("mlockall failed\n" ); +return FAILURE ; + } +// boost main's priority (so we keep running) :) prio_min =sched_get_priority_min (policy); thread_param.sched_priority =MAIN_PRIO ();
@@ -328,6 +340,8 @@ main (int argc, char **argv) } finish =time (NULL );summary (); +if (lockall) +munlockall ();exit (retval); }
@@ -852,6 +866,7 @@ usage(void)printf ("\t--rr\t\t- use SCHED_RR for test threads [SCHED_FIFO]\n" );printf ("\t--prompt\t- prompt before starting the test\n" );printf ("\t--uniprocessor\t- force all threads to run on one processor\n" ); +printf ("\t--mlockall\t- lock current and future memory\n" );printf ("\t--debug\t\t- turn on debug prints\n" );printf ("\t--version\t- print version number on output\n" );printf ("\t--help\t\t- print this message\n" );
@@ -1083,6 +1098,9 @@ process_command_line(int argc, char **argv)case 'u' : uniprocessor =1 ;break ; +case 'm' : + lockall =1 ; +break ; } } }
src/signaltest/signaltest.c +15 -1
@@ -25,6 +25,7 @@#include <sys/stat.h> #include <sys/types.h> #include <sys/time.h> +#include <sys/mman.h> #define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0]))
@@ -207,6 +208,7 @@ static void display_help(void)"-p PRIO --prio=PRIO priority of highest prio thread\n" "-q --quiet print only a summary on exit\n" "-t NUM --threads=NUM number of threads: default=2\n" +"-m --mlockall lock current and future memory allocations\n" "-v --verbose output values on stdout for statistics\n" " format: n:c:v n=tasknum c=count v=value in us\n");exit (0 );
@@ -217,6 +219,7 @@ static int num_threads = 2;static int max_cycles;static int verbose;static int quiet; +static int lockall =0 ;/* Process commandline options */ static void process_options (int argc,char *argv[])
@@ -235,7 +238,7 @@ static void process_options (int argc, char *argv[]) {"help", no_argument, NULL, '?'}, {NULL, 0, NULL, 0} }; -int c =getopt_long (argc, argv,"b:c:d:i:l:np:qrst:v" , +int c =getopt_long (argc, argv,"b:c:d:i:l:np:qrsmt:v" , long_options, &option_index);if (c ==-1 )break ;
@@ -245,6 +248,7 @@ static void process_options (int argc, char *argv[])case 'p' : priority =atoi (optarg);break ;case 'q' : quiet =1 ;break ;case 't' : num_threads =atoi (optarg);break ; +case 'm' : lockall =1 ;break ;case 'v' : verbose =1 ;break ;case '?' : error =1 ;break ; }
@@ -317,6 +321,13 @@ int main(int argc, char **argv)process_options (argc, argv); +/* lock all memory (prevent paging) */ +if (lockall) +if (mlockall (MCL_CURRENT |MCL_FUTURE ) ==-1 ) { +perror ("mlockall" ); + goto out; + } +check_kernel ();sigemptyset (&sigset);
@@ -417,5 +428,8 @@ int main(int argc, char **argv) outpar:free (par); out: +if (lockall) +munlockall (); +exit (ret); }
Signature · 1 line
1.5.4.5
From f6db792ba42908b78f31d3a16cf5c170c29085b7 Mon Sep 17 00:00:00 2001
From: Clark Williams <[email protected]>
Date: Fri, 9 May 2008 13:40:08 -0500
Subject: [PATCH] updated man pages for --mlockall option
--- src/cyclictest/cyclictest.8 | 3 +++ src/pi_tests/pi_stress.8 | 6 +++++- 2 files changed, 8 insertions(+), 1 deletions(-)
src/cyclictest/cyclictest.8 +3 -0
@@ -86,6 +86,9 @@ Use sys_nanosleep and sys_setitimer instead of posix timers. Note, that -s can o Set the number of test threads (default is 1). Create NUM test threads. If NUM is not specifed, NUM is set to the number of available CPUs. See -d, -i and -p for further information. .TP +.B \-m, \-\-mlockall +Lock current an future memory allocations to prevent being paged out +.TP .B \-v, \-\-verbose Output values on stdout for statistics. This option is used to gather statistical information about the latency distribution. The output is sent to stdout. The output format is:
src/pi_tests/pi_stress.8 +5 -1
@@ -10,7 +10,7 @@ pi_stress \- a stress test for POSIX Priority Inheritance mutexes .\"}}} .\"{{{ Synopsis -.\" Usage: pi_stress [-i n ] [-g n] [-v] [-d] [-s] [-r] [-p] [-u] +.\" Usage: pi_stress [-i n ] [-g n] [-v] [-d] [-s] [-r] [-p] [-u] [-m] .SH SYNOPSIS .B pi_stress .RB [ \-i|--inversions
@@ -24,6 +24,7 @@ pi_stress \- a stress test for POSIX Priority Inheritance mutexes .RB [ \-s|--signal ] .RB [ \-r|--rr ] .RB [ \-p|--prompt ] +.RB [ \-m|--mlockall ] .RB [ \-u|--uniprocessor ] .br .\" help
@@ -70,6 +71,9 @@ Prompt before actually starting the stress test Run all threads on one processor. The default is to run all inversion group threads on one processor and the admin threads (reporting thread, keyboard reader, etc.) on a different processor. +.IP \m|--mlockall +Call mlockall to lock currnet and future memory allocations and +prevent being paged out .IP -h|--help Display a short help message and options. .SH CAVEATS
Signature · 1 line
1.5.4.5
From 5587d442ee5eba79325e842f5ecc70ce6fe74817 Mon Sep 17 00:00:00 2001
From: Clark Williams <[email protected]>
Date: Fri, 9 May 2008 13:43:55 -0500
Subject: [PATCH] fixed formating damage
--- src/cyclictest/cyclictest.8 | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
src/cyclictest/cyclictest.8 +1 -1
@@ -16,7 +16,7 @@ cyclictest \- High resolution test program .SH SYNOPSIS .B cyclictest -.RI "[ -hnqrsv ] [\-a " proc " ] [\-b " usec " ] [\-c " clock " ] [\-d " dist " ] [\-i " intv " ] [\-l " loop " ] [\-o " red " ] [\-p " prio " ] [\-t " num " ] " +.RI "[ -hnqrsv ] [\-a " proc " ] [\-b " usec " ] [\-c " clock " ] [\-d " dist " ] [\-i " intv " ] [\-l " loop " ] [\-o " red " ] [\-p " prio " ] [\-t " num " ] [\-m]" .\" .SH DESCRIPTION .\" This manual page documents briefly the .\" .B cyclictest commands.
Signature · 1 line
1.5.4.5
Ack.
I was just telling jcm yesterday (at the SF RT summit), that this needed to be done.
We have definite evidence of major page faults on cyclictest, and consequent spikes.
(its opaque for far, why a small, and high prio process should become swap fodder to begin with)
Sven
Sent via BlackBerry by AT&T
-----Original Message-----
From: Clark Williams <[email protected]>
Date: Fri, 09 May 2008 13:55:40
To:Thomas Gleixner <[email protected]>
Cc:Arnaldo Carvalho de Melo <[email protected]>,Luis Claudio Goncalves <[email protected]>,RT <[email protected]>
Subject: add mlockall option to cyclictest, et al
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Thomas,
Got a couple of requests for mlockall() in cyclictest, so I added an --mlockall option to cyclictest, signaltest and pi_stress.
Patches attached.
Clark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iEYEARECAAYFAkgknisACgkQqA4JVb61b9e+5wCgkfnFdvymSXLsxQ9AwhVU9te+ J9YAniZv12Xj1r6epjft/L/CLv3P1Yl4
=ismw
-----END PGP SIGNATURE-----
Quoted 8 lines · Clark Williams
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Thomas,
Got a couple of requests for
mlockall()in cyclictest, so I added an --mlockall option to cyclictest, signaltest andpi_stress.
One small remark: it would be better to do the mlockall() by default. As far as I know this should be done always for real-time applications. I am actually surprised that it is not done already. It is also mentioned in the Howto build an RT-application on the RT linux wiki.
Robert
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 10 lines · Robert de Vries
Quoted 9 lines · Clark Williams
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Thomas,
Got a couple of requests for
mlockall()in cyclictest, so I added an --mlockall
option to cyclictest, signaltest andpi_stress.
Quoted 8 lines
One small remark: it would be better to do the
mlockall()by default. As far as I know this should be done always for real-time applications. I am actually surprised that it is not done already. It is also mentioned in the Howto build an RT-application on the RT linux wiki.Robert
I thought about that, but figured it would be better just to have the option rather than change long-standing behavior.
It's Thomas's call though :)
Clark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iEYEARECAAYFAkgl99sACgkQqA4JVb61b9eV4gCgiIs5QHocKBRHyOsGlMw+F5BA PuUAnRo5+9oeO5oMFjq55JUxaR7dBI2b
=pefi
-----END PGP SIGNATURE-----
Quoted 19 lines · Clark Williams
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 15 lines · Robert de Vries
Quoted 9 lines · Clark Williams
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Thomas,
Got a couple of requests for
mlockall()in cyclictest, so I added an --mlockall
option to cyclictest, signaltest andpi_stress.One small remark: it would be better to do the
mlockall()by default. As far as I know this should be done always for real-time applications. I am actually surprised that it is not done already. It is also mentioned in the Howto build an RT-application on the RT linux wiki.
Quoted 8 lines
Quoted 3 lines
Robert
I thought about that, but figured it would be better just to have the option rather than change long-standing behavior.
It's Thomas's call though :)
I prefer an option. That gives the mm folks less of an excuse why they swap out hot memory :)
Thanks,
tglx
Quoted 22 lines · On Sunday 25 May 2008 23:22:22 Thomas Gleixner wrote:
Quoted 21 lines · Clark Williams
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 16 lines · Robert de Vries
Quoted 8 lines · Clark Williams
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Thomas,
Got a couple of requests for
mlockall()in cyclictest, so I added an --mlockall
option to cyclictest, signaltest andpi_stress.One small remark: it would be better to do the
mlockall()by default. As far as I know this should be done always for real-time applications. I am actually surprised that it is not done already. It is also mentioned in the Howto build an RT-application on the RT linux wiki.Robert
Quoted 7 lines
Quoted 4 lines
I thought about that, but figured it would be better just to have the option rather than change long-standing behavior.
It's Thomas's call though :)
I prefer an option. That gives the mm folks less of an excuse why they swap out hot memory :)
Hi Thomas,
unfortunately this nice feature didn't made it into rt-tests 0.23 release. Is there any plan to include this for upcoming rt-tests releases?
best regards,
Daniel
Quoted 9 lines · Daniel Gollub
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Got a couple of requests for
mlockall()in cyclictest, so I added an --mlockall
option to cyclictest, signaltest andpi_stress.One small remark: it would be better to do the
mlockall()by default. As far as I know this should be done always for real-time applications. I am actually surprised that it is not done already. It is also mentioned in the Howto build an RT-application on the RT linux wiki.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Robert
I thought about that, but figured it would be better just to have the option rather than change long-standing behavior.
Right.
Nope. We dont want to change the applications default behaviour.
Also mlockall is only relevant if your system supports swap.
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
It's Thomas's call though :)
I prefer an option. That gives the mm folks less of an excuse why they swap out hot memory :)
Hehe
Quoted 4 lines
Hi Thomas,
unfortunately this nice feature didn't made it into rt-tests 0.23 release. Is there any plan to include this for upcoming rt-tests releases?
Yup. Thanks for the reminder. It just got lost in my ever growing inbox :(
Thanks,
tglx