Re: [PATCH] Fix configure script to error out when no perf_events support is found
Maynard Johnson <[email protected]>
| Newsgroups | gmane.linux.oprofile |
|---|---|
| Message-ID | <[email protected]> |
On 10/09/2014 01:43 PM, Carl Love wrote: > Maynard: > > I tested on a Power7 with Red Hat Enterprise Linux Server release 6.5 > (Santiago). I tried installing the patch on a fresh git pull. The > patch applied cleanly. > > I ran autogen.sh and configure to install locally in my directory. That > all worked as expected. I did a test run of operf and ocount to make > sure they built correctly. > > I then tweeked the minimum version number, variables/directory location > names. in the script. I tried to make it "appear" as if the needed > version and the expected files were not there to get the script to fail. > It seemed to fail as expected for each case I was testing. The > resultant error message was consistent with the expected failure. > > I didn't find any formatting issues. > > As far as I can tell, it looks good. Thanks for the review and extra testing effort, Carl! Patch applied. -Maynard > > Carl Love > > On Mon, 2014-10-06 at 16:47 -0500, Maynard Johnson wrote: >> Fix configure script to error out when no perf_events support is found >> >> Prior to release 1.0.0, if the configure script found that the kernel >> version was not new enough to have perf_events support or if the perf_event.h >> header file could not be found, we would just fall back to building only >> the legacy opcontrol-based profiler and would skip building operf and ocount. >> But as of release 1.0.0, the opcontrol-based profiler is no longer included, >> so if operf and ocount cannot be built, we should error out of the configure >> execution, which is what this patch does. >> >> Signed-off-by: Maynard Johnson <[email protected]> >> --- >> configure.ac | 149 +++++++++++++++++++++++++++++----------------------------- >> 1 files changed, 74 insertions(+), 75 deletions(-) >> >> Index: op-master/configure.ac >> =================================================================== >> --- op-master.orig/configure.ac >> +++ op-master/configure.ac >> @@ -57,7 +57,7 @@ AC_PROG_CC >> AC_PROG_CPP >> AC_PROG_CXX >> AC_CHECK_PROG(LD,ld,ld,) >> -test "$LD" || AC_ERROR(ld not found) >> +test "$LD" || AC_MSG_ERROR(ld not found) >> >> # --with-kernel for cross compilation >> AC_ARG_WITH(kernel, >> @@ -80,8 +80,6 @@ if test "$KERNELDIR" != ""; then >> PERF_EVENT_FLAGS=" -I$KERNELDIR/include" >> AC_SUBST(PERF_EVENT_FLAGS) >> PERF_EVENT_H="$KERNELDIR/include/linux/perf_event.h" >> - else >> - echo "$KERNELDIR does not exist." >> fi >> else >> PERF_EVENT_H="/usr/include/linux/perf_event.h" >> @@ -92,6 +90,10 @@ kernel_may_have_perf_events_support="no" >> AX_KERNEL_VERSION(2, 6, 31, <=, kernel_may_have_perf_events_support="yes", >> kernel_has_perf_events_support="no") >> >> +if test "$kernel_has_perf_events_support" = "no"; then >> + AC_MSG_ERROR(Your kernel version is older than the required level (2.6.31) to build oprofile.) >> +fi >> + >> dnl The AX_KERNEL_VERSION macro may return kernel_may_have_perf_events_support="yes", >> dnl indicating a partial answer. Some architectures do not implement the Performance >> dnl Events Kernel Subsystem even with kernel versions > 2.6.31 -- i.e., not even >> @@ -135,66 +137,84 @@ else >> kernel_has_perf_events_support="no" >> fi >> >> -AM_CONDITIONAL(BUILD_FOR_PERF_EVENT, test "$kernel_has_perf_events_support" = "yes") >> - >> -if test "$kernel_has_perf_events_support" = "yes"; then >> - HAVE_PERF_EVENTS='1' >> - AC_MSG_CHECKING([whether PERF_RECORD_MISC_GUEST_KERNEL is defined in perf_event.h]) >> - rm -f test-for-PERF_GUEST >> - AC_LANG_CONFTEST( >> - [AC_LANG_PROGRAM([[#include <linux/perf_event.h>]], >> - [[unsigned int pr_guest_kern = PERF_RECORD_MISC_GUEST_KERNEL; >> - unsigned int pr_guest_user = PERF_RECORD_MISC_GUEST_USER;]]) >> - ]) >> - $CC conftest.$ac_ext $CFLAGS $LDFLAGS $LIBS $PERF_EVENT_FLAGS -o test-for-PERF_GUEST > /dev/null 2>&1 >> - if test -f test-for-PERF_GUEST; then >> - echo "yes" >> - HAVE_PERF_GUEST_MACROS='1' >> +if test "$kernel_has_perf_events_support" != "yes"; then >> + if test "$KERNELDIR" != ""; then >> + echo "ERROR: You requested to build oprofile with '--with-kernel=$KERNELDIR'," >> + if ! test -d $KERNELDIR; then >> + echo "but that directory does not exist." >> + elif test "$PERF_EVENT_H_EXISTS" != "yes"; then >> + echo "but headers were not accessible at the given location." >> + echo "Be sure you have run the following command from within your kernel source tree:" >> + echo " make headers_install INSTALL_HDR_PATH=<kernel-hdrs-install-dir>" >> + echo "Then pass <kernel-hdrs-install-dir> to oprofile's '--with-kernel' configure option." >> + else >> + echo "but your kernel does not appear to have the necessary support to run oprofile." >> + fi >> else >> - echo "no" >> - HAVE_PERF_GUEST_MACROS='0' >> + if test "$PERF_EVENT_H_EXISTS" != "yes"; then >> + echo "Error: perf_event.h not found. Either install the kernel headers package or" >> + echo "use the --with-kernel option." >> + else >> + echo "Error: Your kernel does not appear to have the necessary support to run oprofile." >> + fi >> fi >> - AC_DEFINE_UNQUOTED(HAVE_PERF_GUEST_MACROS, $HAVE_PERF_GUEST_MACROS, [PERF_RECORD_MISC_GUEST_KERNEL is defined in perf_event.h]) >> - rm -f test-for-PERF_GUEST* >> + AC_MSG_ERROR(Unable to build oprofile. Exiting.) >> +fi >> >> - AC_MSG_CHECKING([whether precise_ip is defined in perf_event.h]) >> - rm -f test-for-precise-ip >> - AC_LANG_CONFTEST( >> - [AC_LANG_PROGRAM([[#include <linux/perf_event.h>]], >> - [[struct perf_event_attr attr; >> - attr.precise_ip = 2;]]) >> - ]) >> - $CC conftest.$ac_ext $CFLAGS $LDFLAGS $LIBS $PERF_EVENT_FLAGS -o test-for-precise-ip > /dev/null 2>&1 >> - if test -f test-for-precise-ip; then >> - echo "yes" >> - HAVE_PERF_PRECISE_IP='1' >> - else >> - echo "no" >> - HAVE_PERF_PRECISE_IP='0' >> - fi >> - AC_DEFINE_UNQUOTED(HAVE_PERF_PRECISE_IP, $HAVE_PERF_PRECISE_IP, [precise_ip is defined in perf_event.h]) >> - rm -f test-for-precise-ip* >> +AM_CONDITIONAL(BUILD_FOR_PERF_EVENT, test "$kernel_has_perf_events_support" = "yes") >> >> + >> +HAVE_PERF_EVENTS='1' >> +AC_MSG_CHECKING([whether PERF_RECORD_MISC_GUEST_KERNEL is defined in perf_event.h]) >> +rm -f test-for-PERF_GUEST >> +AC_LANG_CONFTEST( >> + [AC_LANG_PROGRAM([[#include <linux/perf_event.h>]], >> + [[unsigned int pr_guest_kern = PERF_RECORD_MISC_GUEST_KERNEL; >> + unsigned int pr_guest_user = PERF_RECORD_MISC_GUEST_USER;]]) >> + ]) >> +$CC conftest.$ac_ext $CFLAGS $LDFLAGS $LIBS $PERF_EVENT_FLAGS -o test-for-PERF_GUEST > /dev/null 2>&1 >> +if test -f test-for-PERF_GUEST; then >> + echo "yes" >> + HAVE_PERF_GUEST_MACROS='1' >> else >> - HAVE_PERF_EVENTS='0' >> - AC_MSG_RESULT([No perf_events support available; falling back to legacy oprofile]) >> + echo "no" >> + HAVE_PERF_GUEST_MACROS='0' >> fi >> +AC_DEFINE_UNQUOTED(HAVE_PERF_GUEST_MACROS, $HAVE_PERF_GUEST_MACROS, [PERF_RECORD_MISC_GUEST_KERNEL is defined in perf_event.h]) >> +rm -f test-for-PERF_GUEST* >> + >> +AC_MSG_CHECKING([whether precise_ip is defined in perf_event.h]) >> +rm -f test-for-precise-ip >> +AC_LANG_CONFTEST( >> + [AC_LANG_PROGRAM([[#include <linux/perf_event.h>]], >> + [[struct perf_event_attr attr; >> + attr.precise_ip = 2;]]) >> + ]) >> +$CC conftest.$ac_ext $CFLAGS $LDFLAGS $LIBS $PERF_EVENT_FLAGS -o test-for-precise-ip > /dev/null 2>&1 >> +if test -f test-for-precise-ip; then >> + echo "yes" >> + HAVE_PERF_PRECISE_IP='1' >> +else >> + echo "no" >> + HAVE_PERF_PRECISE_IP='0' >> +fi >> +AC_DEFINE_UNQUOTED(HAVE_PERF_PRECISE_IP, $HAVE_PERF_PRECISE_IP, [precise_ip is defined in perf_event.h]) >> +rm -f test-for-precise-ip* >> + >> >> AC_DEFINE_UNQUOTED(HAVE_PERF_EVENTS, $HAVE_PERF_EVENTS, [Kernel support for perf_events exists]) >> AC_CANONICAL_HOST >> -if test "$HAVE_PERF_EVENTS" = "1"; then >> - PFM_LIB= >> - if test "$host_cpu" = "powerpc64le" -o "$host_cpu" = "powerpc64"; then >> - AC_CHECK_HEADER(perfmon/pfmlib.h,,[AC_MSG_ERROR([pfmlib.h not found; may be provided by libpfm devel or papi devel package])]) >> - AC_CHECK_LIB(pfm,pfm_get_os_event_encoding, HAVE_LIBPFM3='0'; HAVE_LIBPFM='1', [ >> - AC_CHECK_LIB(pfm, pfm_get_event_name, HAVE_LIBPFM3='1'; HAVE_LIBPFM='1', >> - [AC_MSG_ERROR([libpfm not found; may be provided by libpfm devel or papi devel package])])]) >> - PFM_LIB="-lpfm" >> - AC_DEFINE_UNQUOTED(HAVE_LIBPFM3, $HAVE_LIBPFM3, [Define to 1 if using libpfm3; 0 if using newer libpfm]) >> - AC_DEFINE_UNQUOTED(HAVE_LIBPFM, $HAVE_LIBPFM, [Define to 1 if libpfm is available]) >> - fi >> - AC_SUBST(PFM_LIB) >> +PFM_LIB= >> +if test "$host_cpu" = "powerpc64le" -o "$host_cpu" = "powerpc64"; then >> + AC_CHECK_HEADER(perfmon/pfmlib.h,,[AC_MSG_ERROR([pfmlib.h not found; may be provided by libpfm devel or papi devel package])]) >> + AC_CHECK_LIB(pfm,pfm_get_os_event_encoding, HAVE_LIBPFM3='0'; HAVE_LIBPFM='1', [ >> + AC_CHECK_LIB(pfm, pfm_get_event_name, HAVE_LIBPFM3='1'; HAVE_LIBPFM='1', >> + [AC_MSG_ERROR([libpfm not found; may be provided by libpfm devel or papi devel package])])]) >> + PFM_LIB="-lpfm" >> + AC_DEFINE_UNQUOTED(HAVE_LIBPFM3, $HAVE_LIBPFM3, [Define to 1 if using libpfm3; 0 if using newer libpfm]) >> + AC_DEFINE_UNQUOTED(HAVE_LIBPFM, $HAVE_LIBPFM, [Define to 1 if libpfm is available]) >> fi >> +AC_SUBST(PFM_LIB) >> >> AC_ARG_WITH(java, >> [ --with-java=java-home Path to Java home directory (default is "no"; "yes" will use /usr as Java home)], >> @@ -425,25 +445,3 @@ elif test "`getent passwd oprofile 2>/de >> echo " The 'oprofile' group must be the default group for the 'oprofile' user." >> fi >> fi >> - >> -if test "$PERF_EVENT_H_EXISTS" != "yes" && test "$kernel_may_have_perf_events_support" = "yes"; then >> - echo "Warning: perf_event.h not found. Either install the kernel headers package or" >> - echo "use the --with-kernel option if you want the non-root, single application" >> - echo "profiling support provided by operf." >> - echo "" >> - echo "If you run 'make' now, only the legacy ocontrol-based profiler will be built." >> -fi >> - >> -if test "$KERNELDIR" != "" && test "$kernel_has_perf_events_support" != "yes"; then >> - if ! test -d $KERNELDIR; then >> - echo "WARNING: You passed '--with-kernel=$KERNELDIR', but $KERNELDIR" >> - echo "does not exist." >> - else >> - echo "Warning: You requested to build with the '--with-kernel' option, but your kernel" >> - echo "headers were not accessible at the given location. Be sure you have run the following" >> - echo "command from within your kernel source tree:" >> - echo " make headers_install INSTALL_HDR_PATH=<kernel-hdrs-install-dir>" >> - echo "Then pass <kernel-hdrs-install-dir> to oprofile's '--with-kernel' configure option." >> - fi >> - echo "" >> -fi >> >> >> ------------------------------------------------------------------------------ >> Slashdot TV. Videos for Nerds. Stuff that Matters. >> http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk >> _______________________________________________ >> oprofile-list mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/oprofile-list >> > > ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk