diff --git a/oprofile-0.9.1-xen.patch b/oprofile-0.9.1-xen.patch new file mode 100644 index 0000000..fc695f1 --- /dev/null +++ b/oprofile-0.9.1-xen.patch @@ -0,0 +1,491 @@ +diff -Naur oprofile-0.9.1/ChangeLog oprofile-0.9.1-xen/ChangeLog +--- oprofile-0.9.1/ChangeLog 2005-07-18 13:02:37.000000000 -0700 ++++ oprofile-0.9.1-xen/ChangeLog 2005-12-22 13:58:38.000000000 -0800 +@@ -1,3 +1,15 @@ ++2005-12-22 Jose Renato Santos ++ ++ * daemon/init.c: ++ * daemon/opd_interface.h: ++ * daemon/opd_kernel.h: ++ * daemon/opd_kernel.c: ++ * daemon/opd_trans.c: ++ * daemon/oprofiled.h: ++ * daemon/oprofiled.c: ++ * doc/opcontrol.1.in: ++ * utils/opcontrol: Added support for Xen ++ + 2005-07-18 John Levon + + * libutil++/tests/Makefile.am: canonicalize +diff -Naur oprofile-0.9.1/daemon/init.c oprofile-0.9.1-xen/daemon/init.c +--- oprofile-0.9.1/daemon/init.c 2005-05-02 08:06:57.000000000 -0700 ++++ oprofile-0.9.1-xen/daemon/init.c 2005-12-22 11:38:09.000000000 -0800 +@@ -7,6 +7,9 @@ + * + * @author John Levon + * @author Philippe Elie ++ * Modified by Aravind Menon for Xen ++ * These modifications are: ++ * Copyright (C) 2005 Hewlett-Packard Co. + */ + + #include "config.h" +@@ -222,6 +225,7 @@ + size_t opd_buf_size; + + opd_create_vmlinux(vmlinux, kernel_range); ++ opd_create_xen(xenimage, xen_range); + + opd_buf_size = opd_read_fs_int("/dev/oprofile/", "buffer_size", 1); + kernel_pointer_size = opd_read_fs_int("/dev/oprofile/", "pointer_size", 1); +diff -Naur oprofile-0.9.1/daemon/opd_interface.h oprofile-0.9.1-xen/daemon/opd_interface.h +--- oprofile-0.9.1/daemon/opd_interface.h 2005-04-13 19:14:17.000000000 -0700 ++++ oprofile-0.9.1-xen/daemon/opd_interface.h 2005-12-22 17:28:30.000000000 -0800 +@@ -8,6 +8,9 @@ + * + * @author John Levon + * @author Philippe Elie ++ * Modified by Aravind Menon for Xen ++ * These modifications are: ++ * Copyright (C) 2005 Hewlett-Packard Co. + */ + + #ifndef OPD_INTERFACE_H +@@ -17,10 +20,13 @@ + #define CPU_SWITCH_CODE 2 + #define COOKIE_SWITCH_CODE 3 + #define KERNEL_ENTER_SWITCH_CODE 4 +-#define KERNEL_EXIT_SWITCH_CODE 5 +-#define MODULE_LOADED_CODE 6 ++#define USER_ENTER_SWITCH_CODE 5 ++#define MODULE_LOADED_CODE 6 + #define CTX_TGID_CODE 7 + #define TRACE_BEGIN_CODE 8 +-#define LAST_CODE 9 ++/* Code 9 used to be TRACE_END_CODE which is not used anymore */ ++/* Code 9 is now considered an unknown escape code */ ++#define XEN_ENTER_SWITCH_CODE 10 ++#define LAST_CODE 11 + + #endif /* OPD_INTERFACE_H */ +diff -Naur oprofile-0.9.1/daemon/opd_kernel.c oprofile-0.9.1-xen/daemon/opd_kernel.c +--- oprofile-0.9.1/daemon/opd_kernel.c 2004-01-29 12:00:26.000000000 -0800 ++++ oprofile-0.9.1-xen/daemon/opd_kernel.c 2005-12-22 11:38:09.000000000 -0800 +@@ -7,6 +7,9 @@ + * + * @author John Levon + * @author Philippe Elie ++ * Modified by Aravind Menon for Xen ++ * These modifications are: ++ * Copyright (C) 2005 Hewlett-Packard Co. + */ + + #include "opd_kernel.h" +@@ -29,6 +32,8 @@ + + static struct kernel_image vmlinux_image; + ++static struct kernel_image xen_image; ++ + void opd_create_vmlinux(char const * name, char const * arg) + { + /* vmlinux is *not* on the list of modules */ +@@ -54,6 +59,31 @@ + } + } + ++void opd_create_xen(char const * name, char const * arg) ++{ ++ /* xen is *not* on the list of modules */ ++ list_init(&xen_image.list); ++ ++ /* for no xen */ ++ if (no_xen) { ++ xen_image.name = "no-xen"; ++ return; ++ } ++ ++ xen_image.name = xstrdup(name); ++ ++ sscanf(arg, "%llx,%llx", &xen_image.start, &xen_image.end); ++ ++ verbprintf(vmisc, "xen_start = %llx, xen_end = %llx\n", ++ xen_image.start, xen_image.end); ++ ++ if (!xen_image.start && !xen_image.end) { ++ fprintf(stderr, "error: mis-parsed xen range: %llx-%llx\n", ++ xen_image.start, xen_image.end); ++ exit(EXIT_FAILURE); ++ } ++} ++ + + /** + * Allocate and initialise a kernel image description +@@ -192,5 +222,8 @@ + return image; + } + ++ if (xen_image.start <= trans->pc && xen_image.end > trans->pc) ++ return &xen_image; ++ + return NULL; + } +diff -Naur oprofile-0.9.1/daemon/opd_kernel.h oprofile-0.9.1-xen/daemon/opd_kernel.h +--- oprofile-0.9.1/daemon/opd_kernel.h 2003-09-24 14:21:14.000000000 -0700 ++++ oprofile-0.9.1-xen/daemon/opd_kernel.h 2005-12-22 11:38:09.000000000 -0800 +@@ -7,6 +7,9 @@ + * + * @author John Levon + * @author Philippe Elie ++ * Modified by Aravind Menon for Xen ++ * These modifications are: ++ * Copyright (C) 2005 Hewlett-Packard Co. + */ + + #ifndef OPD_KERNEL_H +@@ -20,6 +23,8 @@ + /** create the kernel image */ + void opd_create_vmlinux(char const * name, char const * arg); + ++void opd_create_xen(char const * name, char const * arg); ++ + /** opd_reread_module_info - parse /proc/modules for kernel modules */ + void opd_reread_module_info(void); + +diff -Naur oprofile-0.9.1/daemon/opd_trans.c oprofile-0.9.1-xen/daemon/opd_trans.c +--- oprofile-0.9.1/daemon/opd_trans.c 2005-05-25 17:00:02.000000000 -0700 ++++ oprofile-0.9.1-xen/daemon/opd_trans.c 2005-12-22 14:48:41.000000000 -0800 +@@ -7,6 +7,9 @@ + * + * @author John Levon + * @author Philippe Elie ++ * Modified by Aravind Menon for Xen ++ * These modifications are: ++ * Copyright (C) 2005 Hewlett-Packard Co. + */ + + #include "opd_trans.h" +@@ -219,9 +222,9 @@ + } + + +-static void code_kernel_exit(struct transient * trans) ++static void code_user_enter(struct transient * trans) + { +- verbprintf(vmisc, "KERNEL_EXIT_SWITCH to user-space\n"); ++ verbprintf(vmisc, "USER_ENTER_SWITCH to user-space\n"); + trans->in_kernel = 0; + clear_trans_current(trans); + clear_trans_last(trans); +@@ -248,6 +251,19 @@ + trans->tracing = TRACING_START; + } + ++static void code_xen_enter(struct transient *trans) ++{ ++ verbprintf(vmisc, "XEN_ENTER_SWITCH to xen\n"); ++ trans->in_kernel = 1; ++ trans->current = NULL; ++ /* subtlety: we must keep trans->cookie cached, even though it's ++ * meaningless for Xen - we won't necessarily get a cookie switch ++ * on Xen exit. See comments in opd_sfile.c. It seems that we can ++ * get away with in_kernel = 1 as long as we supply the correct ++ * Xen image, and its address range in startup find_kernel_image ++ * is modified to look in the Xen image also ++ */ ++} + + typedef void (*handler_t)(struct transient *); + +@@ -257,11 +273,13 @@ + &code_cpu_switch, + &code_cookie_switch, + &code_kernel_enter, +- &code_kernel_exit, ++ &code_user_enter, + &code_module_loaded, + /* tgid handled differently */ + &code_unknown, + &code_trace_begin, ++ &code_unknown, ++ &code_xen_enter, + }; + + +diff -Naur oprofile-0.9.1/daemon/oprofiled.c oprofile-0.9.1-xen/daemon/oprofiled.c +--- oprofile-0.9.1/daemon/oprofiled.c 2005-03-29 09:10:51.000000000 -0800 ++++ oprofile-0.9.1-xen/daemon/oprofiled.c 2005-12-22 12:01:30.000000000 -0800 +@@ -7,6 +7,9 @@ + * + * @author John Levon + * @author Philippe Elie ++ * Modified by Aravind Menon for Xen ++ * These modifications are: ++ * Copyright (C) 2005 Hewlett-Packard Co. + */ + + #include "config.h" +@@ -60,6 +63,9 @@ + int no_vmlinux; + char * vmlinux; + char * kernel_range; ++int no_xen; ++char * xenimage; ++char * xen_range; + static char * verbose; + static char * binary_name_filter; + static char * events; +@@ -75,6 +81,8 @@ + { "kernel-range", 'r', POPT_ARG_STRING, &kernel_range, 0, "Kernel VMA range", "start-end", }, + { "vmlinux", 'k', POPT_ARG_STRING, &vmlinux, 0, "vmlinux kernel image", "file", }, + { "no-vmlinux", 0, POPT_ARG_NONE, &no_vmlinux, 0, "vmlinux kernel image file not available", NULL, }, ++ { "xen-range", 0, POPT_ARG_STRING, &xen_range, 0, "Xen VMA range", "start-end", }, ++ { "xen-image", 0, POPT_ARG_STRING, &xenimage, 0, "Xen image", "file", }, + { "image", 0, POPT_ARG_STRING, &binary_name_filter, 0, "image name filter", "profile these comma separated image" }, + { "separate-lib", 0, POPT_ARG_INT, &separate_lib, 0, "separate library samples for each distinct application", "[0|1]", }, + { "separate-kernel", 0, POPT_ARG_INT, &separate_kernel, 0, "separate kernel samples for each distinct application", "[0|1]", }, +@@ -407,7 +415,26 @@ + poptPrintHelp(optcon, stderr, 0); + exit(EXIT_FAILURE); + } +- ++ ++ if (!xenimage || !strcmp("", xenimage)) { ++ no_xen = 1; ++ } else { ++ no_xen = 0; ++ ++ /* canonicalise xen image filename. */ ++ tmp = xmalloc(PATH_MAX); ++ if (realpath(xenimage, tmp)) ++ xenimage = tmp; ++ else ++ free(tmp); ++ ++ if (!xen_range || !strcmp("", xen_range)) { ++ fprintf(stderr, "oprofiled: no Xen VMA range specified.\n"); ++ poptPrintHelp(optcon, stderr, 0); ++ exit(EXIT_FAILURE); ++ } ++ } ++ + opd_parse_events(events); + + opd_parse_image_filter(); +diff -Naur oprofile-0.9.1/daemon/oprofiled.h oprofile-0.9.1-xen/daemon/oprofiled.h +--- oprofile-0.9.1/daemon/oprofiled.h 2005-04-26 16:49:45.000000000 -0700 ++++ oprofile-0.9.1-xen/daemon/oprofiled.h 2005-12-22 11:38:09.000000000 -0800 +@@ -7,6 +7,9 @@ + * + * @author John Levon + * @author Philippe Elie ++ * Modified by Aravind Menon for Xen ++ * These modifications are: ++ * Copyright (C) 2005 Hewlett-Packard Co. + */ + + #ifndef OPROFILED_H +@@ -58,5 +61,8 @@ + extern int no_vmlinux; + extern char * vmlinux; + extern char * kernel_range; ++extern int no_xen; ++extern char * xenimage; ++extern char * xen_range; + + #endif /* OPROFILED_H */ +diff -Naur oprofile-0.9.1/doc/opcontrol.1.in oprofile-0.9.1-xen/doc/opcontrol.1.in +--- oprofile-0.9.1/doc/opcontrol.1.in 2005-04-28 14:09:21.000000000 -0700 ++++ oprofile-0.9.1-xen/doc/opcontrol.1.in 2005-12-22 11:38:09.000000000 -0800 +@@ -129,8 +129,23 @@ + .BI "--kernel-range="start,end + Set kernel range vma address in hexadecimal. + ++.SH OPTIONS (specific to Xen) ++.TP ++.BI "--xen="file ++Xen image ++.br ++.TP ++.BI "--active-domains=" ++List of domain ids participating in a multi-domain profiling session. If ++more than one domain is specified in they should be separated using ++commas. This option can only be used in domain 0 which is the only domain ++that can coordinate a multi-domain profiling session. Including domain 0 in ++the list of active domains is optional. (e.g. --active-domains=2,5,6 and ++--active-domains=0,2,5,6 are equivalent) ++.br ++ + .SH ENVIRONMENT +-No special environment variables are recognised by opreport. ++No special environment variables are recognised by opcontrol. + + .SH FILES + .TP +diff -Naur oprofile-0.9.1/utils/opcontrol oprofile-0.9.1-xen/utils/opcontrol +--- oprofile-0.9.1/utils/opcontrol 2005-06-16 12:12:07.000000000 -0700 ++++ oprofile-0.9.1-xen/utils/opcontrol 2005-12-22 12:30:56.000000000 -0800 +@@ -144,6 +144,10 @@ + --buffer-size=num kernel buffer size in sample units + --cpu-buffer-size=num per-cpu buffer size in units (2.6 only) + --note-table-size kernel notes buffer size in notes units (2.4 only) ++ ++ --xen Xen image (for Xen only) ++ --active-domains= List of domains in profiling session (for Xen only) ++ (list contains domain ids separated by commas) + " >&2 + } + +@@ -246,6 +250,7 @@ + CPU_BUF_SIZE=0 + NOTE_SIZE=0 + VMLINUX= ++ XENIMAGE="none" + VERBOSE="" + SEPARATE_LIB=0 + SEPARATE_KERNEL=0 +@@ -326,6 +331,7 @@ + echo "NOTE_SIZE=$NOTE_SIZE" >> $SETUP_FILE + fi + echo "CALLGRAPH=$CALLGRAPH" >> $SETUP_FILE ++ echo "XENIMAGE=$XENIMAGE" >> $SETUP_FILE + } + + +@@ -384,35 +390,61 @@ + + echo "The specified vmlinux file \"$VMLINUX\" doesn't exist." >&2 + exit 1 ++ ++# similar check for Xen image ++ if test -f "$XENIMAGE"; then ++ return ++ fi ++ ++ if test "$XENIMAGE" = "none"; then ++ return ++ fi ++ ++ echo "The specified XenImage file \"$XENIMAGE\" does not exist." >&2 ++ exit 1 + } + + +-# get start and end points of the kernel +-get_kernel_range() ++# get start and end points of a file image (linux kernel or xen) ++# get_image_range parameter: $1=type_of_image (linux or xen) ++get_image_range() + { +- if test ! -z "$KERNEL_RANGE"; then +- return; ++ if test "$1" = "xen"; then ++ if test ! -z "$XEN_RANGE"; then ++ return; ++ fi ++ FILE_IMAGE="$XENIMAGE" ++ else ++ if test ! -z "$KERNEL_RANGE"; then ++ return; ++ fi ++ FILE_IMAGE="$VMLINUX" + fi + +- if test "$VMLINUX" = "none"; then ++ if test "$FILE_IMAGE" = "none"; then + return; + fi + + # start at the start of .text and then continue to the end +- range_info=`objdump -h $VMLINUX 2>/dev/null | grep " .text "` ++ range_info=`objdump -h $FILE_IMAGE 2>/dev/null | grep " .text "` + tmp1=`echo $range_info | awk '{print $4}'` + tmp_length=`echo $range_info | awk '{print $3}'` +- tmp2=`objdump -h $VMLINUX --adjust-vma=0x$tmp_length 2>/dev/null | grep " .text " | awk '{print $4}'` ++ tmp2=`objdump -h $FILE_IMAGE --adjust-vma=0x$tmp_length 2>/dev/null | grep " .text " | awk '{print $4}'` + + if test -z "$tmp1" -o -z "$tmp2"; then +- echo "The specified file $VMLINUX does not seem to be valid" >&2 +- echo "Make sure you are using vmlinux not vmlinuz" >&2 ++ echo "The specified file $FILE_IMAGE does not seem to be valid" >&2 ++ echo "Make sure you are using the non-compressed image file (e.g. vmlinux not vmlinuz)" >&2 + vecho "found start as \"$tmp1\", end as \"$tmp2\"" >&2 + exit 1 + fi + +- KERNEL_RANGE="`echo $tmp1`,`echo $tmp2`" +- vecho "KERNEL_RANGE $KERNEL_RANGE" ++ if test "$1" = "xen"; then ++ XEN_RANGE="`echo $tmp1`,`echo $tmp2`" ++ vecho "XEN_RANGE $XEN_RANGE" ++ else ++ KERNEL_RANGE="`echo $tmp1`,`echo $tmp2`" ++ vecho "KERNEL_RANGE $KERNEL_RANGE" ++ fi + } + + +@@ -692,7 +724,7 @@ + VMLINUX=$val + DO_SETUP=yes + # check validity +- get_kernel_range ++ get_image_range "linux" + ;; + --no-vmlinux) + VMLINUX=none +@@ -703,6 +735,17 @@ + KERNEL_RANGE=$val + DO_SETUP=yes + ;; ++ --xen) ++ error_if_empty $arg $val ++ XENIMAGE=$val ++ DO_SETUP=yes ++ get_image_range "xen" ++ ;; ++ --active-domains) ++ error_if_empty $arg $val ++ ACTIVE_DOMAINS=$val ++ DO_SETUP=yes ++ ;; + --note-table-size) + error_if_empty $arg $val + if test $"KERNEL_SUPPORT" = "yes"; then +@@ -974,6 +1017,14 @@ + fi + fi + ++ if test -n "$ACTIVE_DOMAINS"; then ++ if test "$KERNEL_SUPPORT" = "yes"; then ++ echo $ACTIVE_DOMAINS >$MOUNT/active_domains ++ else ++ echo "active-domains not supported - ignored" >&2 ++ fi ++ fi ++ + if test $NOTE_SIZE != 0; then + set_param notesize $NOTE_SIZE + fi +@@ -1067,7 +1118,8 @@ + do_setup + do_load_setup + check_valid_args +- get_kernel_range ++ get_image_range "linux" ++ get_image_range "xen" + do_param_setup + + OPD_ARGS=" \ +@@ -1084,6 +1136,10 @@ + OPD_ARGS="$OPD_ARGS --vmlinux=$VMLINUX --kernel-range=$KERNEL_RANGE" + fi + ++ if ! test "$XENIMAGE" = "none"; then ++ OPD_ARGS="$OPD_ARGS --xen-image=$XENIMAGE --xen-range=$XEN_RANGE" ++ fi ++ + if ! test -z "$IMAGE_FILTER"; then + OPD_ARGS="$OPD_ARGS --image=$IMAGE_FILTER" + fi diff --git a/oprofile.spec b/oprofile.spec index ac6185d..d75c698 100644 --- a/oprofile.spec +++ b/oprofile.spec @@ -1,6 +1,6 @@ %define DATE 200511111 %define oprofile_version 0.9.1 -%define oprofile_release 8 +%define oprofile_release 9 Summary: System wide profiler Name: oprofile Version: 0.9.1 @@ -19,6 +19,7 @@ Patch63: oprofile-0.7-libs.patch #Patch80: oprofile-0.8.2-ppc64dot.patch Patch81: oprofile-0.9.1-anon.patch Patch82: oprofile_opcontrol.patch +Patch83: oprofile-0.9.1-xen.patch URL: http://oprofile.sf.net ExclusiveArch: %{ix86} ia64 x86_64 ppc ppc64 s390 s390x alpha alphaev6 sparc sparc64 @@ -58,6 +59,7 @@ Header files and libraries for developing apps which will use oprofile. #%patch80 -p1 -b .ppc64dot %patch81 -p1 -b .anon %patch82 -p1 -b .opcontrol +%patch83 -p1 -b .xen ./autogen.sh @@ -233,6 +235,9 @@ rm -rf ${RPM_BUILD_ROOT} %changelog +* Sat May 13 2006 Will Cohen - 0.9.1-8.1.1 +- Add xenoprof patch. + * Fri Feb 10 2006 Jesse Keating - 0.9.1-8.1.1 - bump again for double-long bug on ppc(64)