Re: RFC: patch to trigger thread stats output from cyclictest with SIGHUP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 11 Mar 2013 17:54:05 +0100
David Sommerseth <davids@xxxxxxxxxx> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 11/03/13 17:25, Paul Gortmaker wrote:
> > On Mon, Mar 11, 2013 at 12:16 PM, Clark Williams 
> > <williams@xxxxxxxxxx> wrote:
> >> John,
> >> 
> >> Steven suggested a feature for cyclictest that I'd actually been
> >>  whining about (internally anyway). During long rteval runs 
> >> there's really no feedback available if you want to know how the 
> >> run is progressing. Steven suggested sending SIGHUP and dumping 
> >> the current state. Below is a patch that seems to work for 
> >> cyclictest; just wanted to get some feedback on whether this 
> >> would be acceptable behaviour.
> > 
> > Is USR1 already in use for something?  That would be consistent 
> > with how things like dd use USR1 signal - to report interim stats.
> > 
> > P.
> 
> +1 ... I was just about to say exactly the same.
> 
> 

Good points. As I recall SIGHUP is usually used to force a re-read of
configs (which doesn't really apply here).

Here's a revised version using SIGUSR1:

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 0a15dcb..be4046f 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -199,6 +199,11 @@ static char **traceptr;
 static int traceopt_count;
 static int traceopt_size;
 
+static struct thread_param **parameters;
+static struct thread_stat **statistics;
+
+static void print_stat(struct thread_param *par, int index, int verbose);
+
 static int latency_target_fd = -1;
 static int32_t latency_target_value = 0;
 
@@ -1368,6 +1373,19 @@ static int check_timer(void)
 
 static void sighand(int sig)
 {
+	if (sig == SIGUSR1) {
+		int i;
+		int oldquiet = quiet;
+
+		quiet = 0;
+		printf("#---------------------------\n");
+		printf("# cyclictest current status:\n");
+		for (i = 0; i < num_threads; i++)
+			print_stat(parameters[i], i, 0);
+		printf("#---------------------------\n");
+		quiet = oldquiet;
+		return;
+	}
 	shutdown = 1;
 	if (refresh_on_max)
 		pthread_cond_signal(&refresh_on_max_cond);
@@ -1503,8 +1521,6 @@ int main(int argc, char **argv)
 	sigset_t sigset;
 	int signum = SIGALRM;
 	int mode;
-	struct thread_param **parameters;
-	struct thread_stat **statistics;
 	int max_cpus = sysconf(_SC_NPROCESSORS_CONF);
 	int i, ret = -1;
 	int status;
@@ -1642,6 +1658,7 @@ int main(int argc, char **argv)
 
 	signal(SIGINT, sighand);
 	signal(SIGTERM, sighand);
+	signal(SIGUSR1, sighand);
 
 	parameters = calloc(num_threads, sizeof(struct thread_param *));
 	if (!parameters)

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux