[prev in list] [next in list] [prev in thread] [next in thread] 

List:       oprofile-commits
Subject:    [oprof-cvs] CVS: oprofile/daemon opd_pipe.h, 1.1, 1.2 opd_pipe.c,
From:       hanseld <hanseld () users ! sourceforge ! net>
Date:       2008-04-28 21:23:56
Message-ID: E1JqapI-0004Ob-Rb () sc8-pr-cvs3 ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/oprofile/oprofile/daemon
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15532/daemon

Modified Files:
	oprofiled.h oprofiled.c init.c opd_anon.c Makefile.am 
Added Files:
	opd_pipe.h opd_pipe.c 
Log Message:
JIT support (for profiling Java applications) added



Index: oprofiled.h
===================================================================
RCS file: /cvsroot/oprofile/oprofile/daemon/oprofiled.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -p -d -r1.7 -r1.8
--- oprofiled.h	16 Jan 2006 13:21:09 -0000	1.7
+++ oprofiled.h	28 Apr 2008 21:23:23 -0000	1.8
@@ -50,6 +50,7 @@ int opd_read_fs_int(char const * path, c
 extern sig_atomic_t signal_alarm;
 extern sig_atomic_t signal_hup;
 extern sig_atomic_t signal_term;
+extern sig_atomic_t signal_child;
 extern sig_atomic_t signal_usr1;
 extern sig_atomic_t signal_usr2;
 

Index: oprofiled.c
===================================================================
RCS file: /cvsroot/oprofile/oprofile/daemon/oprofiled.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -p -d -r1.85 -r1.86
--- oprofiled.c	3 Mar 2008 14:37:32 -0000	1.85
+++ oprofiled.c	28 Apr 2008 21:23:23 -0000	1.86
@@ -46,6 +46,7 @@
 sig_atomic_t signal_alarm;
 sig_atomic_t signal_hup;
 sig_atomic_t signal_term;
+sig_atomic_t signal_child;
 sig_atomic_t signal_usr1;
 sig_atomic_t signal_usr2;
 
@@ -186,6 +187,11 @@ static void opd_sigterm(int val __attrib
 {
 	signal_term = 1;
 }
+
+static void opd_sigchild(int val __attribute__((unused)))
+{
+	signal_child = 1;
+}
  
 
 static void opd_sigusr1(int val __attribute__((unused)))
@@ -233,6 +239,16 @@ static void opd_setup_signals(void)
 		exit(EXIT_FAILURE);
 	}
 
+	act.sa_handler = opd_sigchild;
+	act.sa_flags = 0;
+	sigemptyset(&act.sa_mask);
+	sigaddset(&act.sa_mask, SIGCHLD);
+
+	if (sigaction(SIGCHLD, &act, NULL)) {
+		perror("oprofiled: install of SIGCHLD handler failed: ");
+		exit(EXIT_FAILURE);
+	}
+
 	act.sa_handler = opd_sigusr1;
 	act.sa_flags = 0;
 	sigemptyset(&act.sa_mask);

Index: init.c
===================================================================
RCS file: /cvsroot/oprofile/oprofile/daemon/init.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -p -d -r1.12 -r1.13
--- init.c	14 Dec 2006 14:36:25 -0000	1.12
+++ init.c	28 Apr 2008 21:23:24 -0000	1.13
@@ -7,6 +7,7 @@
  *
  * @author John Levon
  * @author Philippe Elie
+ * @Modifications Daniel Hansel
  * Modified by Aravind Menon for Xen
  * These modifications are:
  * Copyright (C) 2005 Hewlett-Packard Co.
@@ -17,6 +18,7 @@
 #include "oprofiled.h"
 #include "opd_stats.h"
 #include "opd_sfile.h"
+#include "opd_pipe.h"
 #include "opd_kernel.h"
 #include "opd_trans.h"
 #include "opd_anon.h"
@@ -33,17 +35,26 @@
 #include <fcntl.h>
 #include <stdio.h>
 #include <errno.h>
+#include <limits.h>
 #include <stdlib.h>
+#include <sys/time.h>
+#include <wait.h>
+#include <string.h>
 
 size_t kernel_pointer_size;
 
 static fd_t devfd;
 static char * sbuf;
 static size_t s_buf_bytesize;
+extern char * session_dir;
+static char start_time_str[32];
+static int jit_conversion_running;
 
 static void opd_sighup(void);
 static void opd_alarm(void);
 static void opd_sigterm(void);
+static void opd_sigchild(void);
+static void opd_do_jitdumps(void);
 
 /**
  * opd_open_files - open necessary files
@@ -76,6 +87,7 @@ static void opd_open_files(void)
 	}
 
 	opd_open_logfile();
+	opd_create_pipe();
 
 	printf("oprofiled started %s", op_get_time());
 	printf("kernel pointer size: %lu\n",
@@ -133,6 +145,48 @@ static void opd_do_samples(char const * 
 	complete_dump();
 }
  
+static void opd_do_jitdumps(void)
+{ 
+	pid_t childpid;
+	int arg_num;
+	unsigned long long end_time = 0ULL;
+	struct timeval tv;
+	char end_time_str[32];
+	char opjitconv_path[PATH_MAX + 1];
+	char * exec_args[6];
+
+	if (jit_conversion_running)
+		return;
+	jit_conversion_running = 1;
+
+	childpid = fork();
+	switch (childpid) {
+		case -1:
+			perror("Error forking JIT dump process!");
+			break;
+		case 0:
+			gettimeofday(&tv, NULL);
+			end_time = tv.tv_sec;
+			sprintf(end_time_str, "%llu", end_time);
+			sprintf(opjitconv_path, "%s/%s", OP_BINDIR, "opjitconv");
+			arg_num = 0;
+			exec_args[arg_num++] = opjitconv_path;
+			if (vmisc)
+				exec_args[arg_num++] = "-d";
+			exec_args[arg_num++] = session_dir;
+			exec_args[arg_num++] = start_time_str;
+			exec_args[arg_num++] = end_time_str;
+			exec_args[arg_num] = (char *) NULL;
+			execvp("opjitconv", exec_args);
+			fprintf(stderr, "Failed to exec %s: %s\n",
+			        exec_args[0], strerror(errno));
+			/* We don't want any cleanup in the child */
+			_exit(EXIT_FAILURE);
+		default:
+			break;
+	} 
+
+} 
 
 /**
  * opd_do_read - enter processing loop
@@ -144,6 +198,8 @@ static void opd_do_samples(char const * 
  */
 static void opd_do_read(char * buf, size_t size)
 {
+	opd_open_pipe();
+
 	while (1) {
 		ssize_t count = -1;
 
@@ -167,6 +223,9 @@ static void opd_do_read(char * buf, size
 			if (signal_term)
 				opd_sigterm();
 
+			if (signal_child)
+				opd_sigchild();
+
 			if (signal_usr1) {
 				signal_usr1 = 0;
 				perfmon_start();
@@ -176,10 +235,17 @@ static void opd_do_read(char * buf, size
 				signal_usr2 = 0;
 				perfmon_stop();
 			}
+
+			if (is_jitconv_requested()) {
+				verbprintf(vmisc, "Start opjitconv was triggered\n");
+				opd_do_jitdumps();
+			}
 		}
 
 		opd_do_samples(buf, count);
 	}
+	
+	opd_close_pipe();
 }
 
 
@@ -213,16 +279,33 @@ static void clean_exit(void)
 
 static void opd_sigterm(void)
 {
+	opd_do_jitdumps();
 	opd_print_stats();
 	printf("oprofiled stopped %s", op_get_time());
 	exit(EXIT_FAILURE);
 }
- 
 
+/* SIGCHLD received from JIT dump child process. */
+static void opd_sigchild(void)
+{
+	int child_status;
+	wait(&child_status);
+	jit_conversion_running = 0;
+	if (WIFEXITED(child_status) && (!WEXITSTATUS(child_status))) {
+		verbprintf(vmisc, "JIT dump processing complete.\n");
+	} else {
+		printf("JIT dump processing exited abnormally: %d\n",
+		       WEXITSTATUS(child_status));
+	}
+
+}
+ 
 static void opd_26_init(void)
 {
 	size_t i;
 	size_t opd_buf_size;
+	unsigned long long start_time = 0ULL;
+	struct timeval tv;
 
 	opd_create_vmlinux(vmlinux, kernel_range);
 	opd_create_xen(xenimage, xen_range);
@@ -254,6 +337,11 @@ static void opd_26_init(void)
 
 	/* trigger kernel module setup before returning control to opcontrol */
 	opd_open_files();
+	gettimeofday(&tv, NULL);
+	start_time = 0ULL;
+	start_time = tv.tv_sec;
+	sprintf(start_time_str, "%llu", start_time);
+		  
 }
 
 

Index: opd_anon.c
===================================================================
RCS file: /cvsroot/oprofile/oprofile/daemon/opd_anon.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -p -d -r1.9 -r1.10
--- opd_anon.c	23 Aug 2007 14:12:38 -0000	1.9
+++ opd_anon.c	28 Apr 2008 21:23:24 -0000	1.10
@@ -14,6 +14,7 @@
  * @remark Read the file COPYING
  *
  * @author John Levon
+ * @Modifications Gisle Dankel
  */
 
 #include "opd_anon.h"
@@ -142,13 +143,15 @@ static void get_anon_maps(struct transie
 	while (fgets(buf, PATH_MAX, fp) != NULL) {
 		char tmp[MAX_IMAGE_NAME_SIZE + 1];
 		char name[MAX_IMAGE_NAME_SIZE + 1];
-		/* Note that this actually includes all mappings,
-		 * since we want stuff like [heap]
+		/* Some anon maps have labels like
+		 * [heap], [stack], [vdso], [vsyscall] ...
+		 * Keep track of these labels. If a map has no name, call it "anon".
+		 * Ignore all mappings starting with "/" (file or shared memory object)
 		 */
 		strcpy(name, "anon");
 		ret = sscanf(buf, "%llx-%llx %20s %20s %20s %20s %20s",
 		             &start, &end, tmp, tmp, tmp, tmp, name);
-		if (ret < 6)
+		if (ret < 6 || name[0] == '/')
 			continue;
 
 		add_anon_mapping(trans, start, end, name);

Index: Makefile.am
===================================================================
RCS file: /cvsroot/oprofile/oprofile/daemon/Makefile.am,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -p -d -r1.31 -r1.32
--- Makefile.am	10 May 2007 23:42:32 -0000	1.31
+++ Makefile.am	28 Apr 2008 21:23:24 -0000	1.32
@@ -5,6 +5,8 @@ oprofiled_SOURCES = \
 	oprofiled.c \
 	oprofiled.h \
 	opd_stats.c \
+	opd_pipe.c \
+	opd_pipe.h \
 	opd_sfile.c \
 	opd_sfile.h \
 	opd_kernel.c \


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Oprofile-commits mailing list
Oprofile-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oprofile-commits
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic