From: Pshyk, SerhiyX Date: Fri, 26 May 2017 14:51:54 +0000 (+0100) Subject: intel_pmu: address PR comments X-Git-Tag: collectd-5.8.0~114^2~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7853bfa986aee41b596174e7ecdc8fdeefc7d25a;p=collectd.git intel_pmu: address PR comments - cleanup of configure.ac - add config option EventList to avoid dependency on environment variables Change-Id: I987095b6e71bcf05103e773793c0a40c815f729b Signed-off-by: Serhiy Pshyk --- diff --git a/configure.ac b/configure.ac index af3bcfea..7b5045f7 100644 --- a/configure.ac +++ b/configure.ac @@ -4367,20 +4367,21 @@ fi # --with-libjevents {{{ with_libjevents_cppflags="" with_libjevents_ldflags="" -AC_ARG_WITH(libjevents, [AS_HELP_STRING([--with-libjevents@<:@=PREFIX@:>@], [Path to libjevents.])], -[ - if test "x$withval" != "xno" && test "x$withval" != "xyes" - then - with_libjevents_cppflags="-I$withval/include" - with_libjevents_ldflags="-L$withval/lib" - with_libjevents="yes" - else - with_libjevents="$withval" - fi -], -[ - with_libjevents="yes" -]) +AC_ARG_WITH([libjevents], + [AS_HELP_STRING([--with-libjevents@<:@=PREFIX@:>@], [Path to libjevents.])], + [ + if test "x$withval" != "xno" && test "x$withval" != "xyes" + then + with_libjevents_cppflags="-I$withval/include" + with_libjevents_ldflags="-L$withval/lib" + with_libjevents="yes" + else + with_libjevents="$withval" + fi + ], + [with_libjevents="yes"] +) + if test "x$with_libjevents" = "xyes" then SAVE_CPPFLAGS="$CPPFLAGS" @@ -4392,47 +4393,22 @@ then fi if test "x$with_libjevents" = "xyes" then - SAVE_CPPFLAGS="$CPPFLAGS" SAVE_LDFLAGS="$LDFLAGS" - CPPFLAGS="$CPPFLAGS $with_libjevents_cppflags" LDFLAGS="$LDFLAGS $with_libjevents_ldflags" AC_CHECK_LIB(jevents, json_events, [with_libjevents="yes"], [with_libjevents="no (Can't find libjevents)"]) - CPPFLAGS="$SAVE_CPPFLAGS" - LDFLAGS="$SAVE_LDFLAGS" -fi -if test "x$with_libjevents" = "xyes" -then - SAVE_CPPFLAGS="$CPPFLAGS" - SAVE_LDFLAGS="$LDFLAGS" - SAVE_LIBS="$LIBS" - CPPFLAGS="$CPPFLAGS -fPIC" - LDFLAGS="$LDFLAGS -shared" - LIBS="-ljevents" - AC_LINK_IFELSE([AC_LANG_SOURCE( - [[ - #include - #include "jevents.h" - void print_cpu(void){ - printf("%s", get_cpu_str()); - } - ]] - )], - [with_libjevents="yes"], [with_libjevents="no (could not link to libjevents. Check jevents is compiled with -fPIC.)"]) - CPPFLAGS="$SAVE_CPPFLAGS" LDFLAGS="$SAVE_LDFLAGS" - LIBS="$SAVE_LIBS" fi if test "x$with_libjevents" = "xyes" then BUILD_WITH_LIBJEVENTS_CPPFLAGS="$with_libjevents_cppflags" BUILD_WITH_LIBJEVENTS_LDFLAGS="$with_libjevents_ldflags" BUILD_WITH_LIBJEVENTS_LIBS="-ljevents" - AC_SUBST(BUILD_WITH_LIBJEVENTS_CPPFLAGS) - AC_SUBST(BUILD_WITH_LIBJEVENTS_LDFLAGS) - AC_SUBST(BUILD_WITH_LIBJEVENTS_LIBS) fi +AC_SUBST(BUILD_WITH_LIBJEVENTS_CPPFLAGS) +AC_SUBST(BUILD_WITH_LIBJEVENTS_LDFLAGS) +AC_SUBST(BUILD_WITH_LIBJEVENTS_LIBS) # }}} # --with-libprotobuf {{{ diff --git a/contrib/systemd.collectd.service b/contrib/systemd.collectd.service index efd922a6..5f3e907f 100644 --- a/contrib/systemd.collectd.service +++ b/contrib/systemd.collectd.service @@ -11,20 +11,6 @@ EnvironmentFile=-/etc/default/collectd ProtectSystem=full ProtectHome=true -# Some plugins require access to data located in a specified folder, to access -# this data you'll have to specify the path by using the Environment directive -# below. -# -# Here's a (incomplete) list of the plugins known environment requirements: -# intel_pmu XDG_CACHE_HOME -# -# Example, if you use the intel_pmu plugin and cache is located in the /opt -# directory: -# Environment=XDG_CACHE_HOME=/opt -# -# By default, the HOME directory is chosen: -Environment= - # A few plugins won't work without some privileges, which you'll have to # specify using the CapabilityBoundingSet directive below. # diff --git a/src/collectd.conf.in b/src/collectd.conf.in index 1a2823b7..1b40bf40 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -651,6 +651,7 @@ # ReportHardwareCacheEvents true # ReportKernelPMUEvents true # ReportSoftwareEvents true +# EventList "/var/cache/pmu/GenuineIntel-6-2D-core.json" # HardwareEvents "L2_RQSTS.CODE_RD_HIT,L2_RQSTS.CODE_RD_MISS" "L2_RQSTS.ALL_CODE_RD" # diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 36053cd0..30544d09 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -3093,6 +3093,7 @@ B ReportHardwareCacheEvents true ReportKernelPMUEvents true ReportSoftwareEvents true + EventList "/var/cache/pmu/GenuineIntel-6-2D-core.json" HardwareEvents "L2_RQSTS.CODE_RD_HIT,L2_RQSTS.CODE_RD_MISS" "L2_RQSTS.ALL_CODE_RD" @@ -3154,11 +3155,16 @@ Enable or disable measuring of software events provided by kernel: - alignment-faults - emulation-faults +=item B I + +JSON performance counter event list file name. To be able to monitor all Intel +CPU specific events JSON event list file should be downloaded. Use the pmu-tools +event_download.py script to download event list for current CPU. + =item B I This field is a list of event names or groups of comma separated event names. -To be able to monitor all Intel CPU specific events JSON event list file should -be downloaded. Use the pmu-tools event_download.py script for this. +This option requires B option to be configured. =back diff --git a/src/intel_pmu.c b/src/intel_pmu.c index e332c37b..87a713be 100644 --- a/src/intel_pmu.c +++ b/src/intel_pmu.c @@ -67,6 +67,7 @@ struct intel_pmu_ctx_s { _Bool hw_cache_events; _Bool kernel_pmu_events; _Bool sw_events; + char event_list_fn[PATH_MAX]; char **hw_events; size_t hw_events_count; struct eventlist *event_list; @@ -243,6 +244,9 @@ static int pmu_config(oconfig_item_t *ci) { ret = cf_util_get_boolean(child, &g_ctx.hw_cache_events); } else if (strcasecmp("ReportKernelPMUEvents", child->key) == 0) { ret = cf_util_get_boolean(child, &g_ctx.kernel_pmu_events); + } else if (strcasecmp("EventList", child->key) == 0) { + ret = cf_util_get_string_buffer(child, g_ctx.event_list_fn, + sizeof(g_ctx.event_list_fn)); } else if (strcasecmp("HardwareEvents", child->key) == 0) { ret = pmu_config_hw_events(child); } else if (strcasecmp("ReportSoftwareEvents", child->key) == 0) { @@ -493,6 +497,14 @@ static int pmu_init(void) { /* parse events names if config option is present and is not empty */ if (g_ctx.hw_events_count) { + + ret = read_events(g_ctx.event_list_fn); + if (ret != 0) { + ERROR(PMU_PLUGIN ": Failed to read event list file '%s'.", + g_ctx.event_list_fn); + return ret; + } + ret = pmu_add_hw_events(g_ctx.event_list, g_ctx.hw_events, g_ctx.hw_events_count); if (ret != 0) {