WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xenpm: add timeout option to 'xenpm start

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xenpm: add timeout option to 'xenpm start' command.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 19 Mar 2009 10:10:15 -0700
Delivery-date: Thu, 19 Mar 2009 10:11:35 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1237457399 0
# Node ID cbdc022b003561ba2ed5838aa47a81120f283adf
# Parent  fe949f9129b00484b0d1a22a5440db0592f9da92
xenpm: add timeout option to 'xenpm start' command.

Thus we can sample a fixed time of period without manual interruption.

Signed-off-by: Guanqun Lu <guanqun.lu@xxxxxxxxx>
---
 tools/misc/xenpm.c |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)

diff -r fe949f9129b0 -r cbdc022b0035 tools/misc/xenpm.c
--- a/tools/misc/xenpm.c        Thu Mar 19 10:09:24 2009 +0000
+++ b/tools/misc/xenpm.c        Thu Mar 19 10:09:59 2009 +0000
@@ -59,8 +59,8 @@ void show_help(void)
             " set-up-threshold      [cpuid] <num> set up threshold on CPU 
<cpuid> or all\n"
             "                                     it is used in ondemand 
governor.\n"
             " get-cpu-topology                    get thread/core/socket 
topology info\n"
-            " start                               start collect Cx/Px 
statistics,\n"
-            "                                     output after CTRL-C or 
SIGINT.\n"
+            " start [seconds]                     start collect Cx/Px 
statistics,\n"
+            "                                     output after CTRL-C or 
SIGINT or several seconds.\n"
             );
 }
 /* wrapper function */
@@ -353,6 +353,16 @@ void start_gather_func(int argc, char *a
 {
     int i;
     struct timeval tv;
+    int timeout = 0;
+
+    if ( argc == 1 )
+    {
+        sscanf(argv[0], "%d", &timeout);
+        if ( timeout <= 0 )
+            fprintf(stderr, "failed to set timeout seconds, falling 
back...\n");
+        else
+            printf("Timeout set to %d seconds\n", timeout);
+    }
 
     if ( gettimeofday(&tv, NULL) == -1 )
     {
@@ -408,7 +418,21 @@ void start_gather_func(int argc, char *a
         free(cxstat);
         return ;
     }
-    printf("Start sampling, waiting for CTRL-C or SIGINT signal ...\n");
+
+    if ( timeout > 0 )
+    {
+        if ( signal(SIGALRM, signal_int_handler) == SIG_ERR )
+        {
+            fprintf(stderr, "failed to set signal alarm handler\n");
+            free(sum);
+            free(pxstat);
+            free(cxstat);
+            return ;
+        }
+        alarm(timeout);
+    }
+
+    printf("Start sampling, waiting for CTRL-C or SIGINT or SIGALARM signal 
...\n");
 
     pause();
 }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xenpm: add timeout option to 'xenpm start' command., Xen patchbot-unstable <=