This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
RE: Tune reader_thread poll timeout value
Hi,
Here is proposal for this tunable. I tested on OMAP with value X=50ms, 200ms, 345ms, 1s, 5s, 10s:
- for low throughput trace, stapio wakes up precisely every X ms (scheduler switch probe + awk post-processing). Wakes-up every 200ms if option is not used
- with high value such as 5 seconds, low throughput trace is dumped only every 5s. So of course, do not use probe timer.s(1) to get trace dumped every s on command line, you will have 5 correct infos in 1 shot every 5s.
- no impact in performance, when trace throughput is high, ppoll() returns before timeout expires. For example, an Android video playback fills a buffer in 2 or 3s (scheduler contextswitch + irqs + workqueue monitoring) so 5s timeout expiration is not occuring.
From f70a4385fd709af0079b293f27617e0c2968ae03 Mon Sep 17 00:00:00 2001
From: Frederic Turgis <f-turgis@ti.com>
Date: Tue, 15 May 2012 04:56:14 +0200
Subject: [PATCH] Allow tuning of reader thread ppoll timeout value
Default value of 200ms causes too many wake-ups for embedded platforms
low power use-cases. Timeout of several seconds is expected on these.
New option is -T x where x is timeout in ms.
---
runtime/staprun/common.c | 18 ++++++++++++++++--
runtime/staprun/relay.c | 5 +++++
runtime/staprun/staprun.8 | 8 ++++++++
runtime/staprun/staprun.h | 1 +
4 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/runtime/staprun/common.c b/runtime/staprun/common.c
index eeb22d5..470f1f9 100644
--- a/runtime/staprun/common.c
+++ b/runtime/staprun/common.c
@@ -23,6 +23,7 @@ int verbose;
int suppress_warnings;
int target_pid;
unsigned int buffer_size;
+unsigned int reader_timeout_ms;
char *target_cmd;
char *outfile_name;
int rename_mod;
@@ -117,6 +118,7 @@ void parse_args(int argc, char **argv)
suppress_warnings = 0;
target_pid = 0;
buffer_size = 0;
+ reader_timeout_ms = 0;
target_cmd = NULL;
outfile_name = NULL;
rename_mod = 0;
@@ -130,7 +132,7 @@ void parse_args(int argc, char **argv)
remote_id = -1;
remote_uri = NULL;
- while ((c = getopt(argc, argv, "ALu::vb:t:dc:o:x:S:DwRr:V")) != EOF) {
+ while ((c = getopt(argc, argv, "ALu::vb:t:dc:o:x:S:DwRr:VT:")) != EOF) {
switch (c) {
case 'u':
need_uprobes = 1;
@@ -204,6 +206,14 @@ void parse_args(int argc, char **argv)
VERSION, GIT_MESSAGE);
_exit(1);
break;
+ case 'T':
+ reader_timeout_ms = (unsigned)atoi(optarg);
+ if (reader_timeout_ms < 1) {
+ err(_("Invalid reader timeout value '%d' (should be >= 1).\n"), reader_timeout_ms);
+ usage(argv[0]);
+ }
+
+ break;
default:
usage(argv[0]);
}
@@ -313,7 +323,11 @@ void usage(char *prog)
" assumed to be the maximum file size in MB.\n"
" When the number of output files reaches N, it\n"
" switches to the first output file. You can omit\n"
- " the second argument.\n\n"
+ " the second argument.\n"
+ "-T timeout Specifies upper limit on amount of time reader thread\n"
+ " will wait for new trace buffer. Value should be an\n"
+ " integer >= 1, which is timeout value in ms. Default value is 200ms.\n"
+ " Purpose is to reduce stapio wake-ups for embedded platforms low-power use cases\n\n"
"MODULE can be either a module name or a module path. If a\n"
"module name is used, it is searched in the following directory:\n"));
{
diff --git a/runtime/staprun/relay.c b/runtime/staprun/relay.c
index e08ff60..d8ca71b 100644
--- a/runtime/staprun/relay.c
+++ b/runtime/staprun/relay.c
@@ -152,6 +152,11 @@ static void *reader_thread(void *data)
timeout = NULL;
#endif
}
+
+ if (reader_timeout_ms) {
+ timeout->tv_sec = reader_timeout_ms / 1000;
+ timeout->tv_nsec = (reader_timeout_ms - timeout->tv_sec * 1000) * 1000000;
+ }
pollfd.fd = relay_fd[cpu];
pollfd.events = POLLIN;
diff --git a/runtime/staprun/staprun.8 b/runtime/staprun/staprun.8
index d87a2e8..bcca07d 100644
--- a/runtime/staprun/staprun.8
+++ b/runtime/staprun/staprun.8
@@ -106,6 +106,14 @@ output files exceed
.B N
, systemtap removes the oldest output file. You can omit the second argument.
.TP
+.B \-T
+Sets maximum time reader thread will wait before dumping trace buffer. Value is
+in ms, default is 200ms. Setting this to a high value decreases number of stapio
+wake-ups, allowing deeper sleep for embedded platforms. But it impacts interactivity
+on terminal as traces are dumped less often in case of low throughput.
+There is no interactivity or performance impact for high throughput as trace is
+dumped when buffer is full, before this timeout expires.
+.TP
.B var1=val
Sets the value of global variable var1 to val. Global variables contained
within a module are treated as module options and can be set from the
diff --git a/runtime/staprun/staprun.h b/runtime/staprun/staprun.h
index 3664889..d01a291 100644
--- a/runtime/staprun/staprun.h
+++ b/runtime/staprun/staprun.h
@@ -208,6 +208,7 @@ extern int kernel_ptr_size;
extern int verbose;
extern int suppress_warnings;
extern unsigned int buffer_size;
+extern unsigned int reader_timeout_ms;
extern char *modname;
extern char *modpath;
#define MAXMODOPTIONS 64
--
1.7.1
Regards
Fred
OMAP Platform Business Unit - System Platform Engineering - Platform & Product Entitlement
Texas Instruments France SA, 821 Avenue Jack Kilby, 06270 Villeneuve Loubet. 036 420 040 R.C.S Antibes. Capital de EUR 753.920
-----Original Message-----
From: Turgis, Frederic
Sent: Monday, May 07, 2012 6:09 PM
To: 'Frank Ch. Eigler'
Cc: Josh Stone; Mark Wielaard; systemtap@sourceware.org
Subject: RE: Tune reader_thread poll timeout value
>I think it'd be OK to do it as a staprun-only option. Over time I'd
>like to automate the selection of this value rather than expose it
>more broadly.
Agreed. I test and update the doc then submit the patch to mailing list.
Regards
Fred