inline nanos_event_key_t InstrumentationDictionary::getEventKey ( const std::string &key ) { return getEventKey( key.c_str() ); }
#include <errno.h> #include <fcntl.h> #include <limits.h> #include <string.h> #include <sys/ioctl.h> #include <sys/syscall.h> #include <unistd.h> #include "Buffer.h" #include "DynBuf.h" #include "Logging.h" #include "Monitor.h" #include "PerfBuffer.h" #include "SessionData.h" static const int schedSwitchKey = getEventKey(); #define DEFAULT_PEA_ARGS(pea, additionalSampleType) \ pea.size = sizeof(pea); \ /* Emit time, read_format below, group leader id, and raw tracepoint info */ \ pea.sample_type = (gSessionData.mPerf.getLegacySupport() \ ? PERF_SAMPLE_TID | PERF_SAMPLE_IP | PERF_SAMPLE_ID \ : PERF_SAMPLE_IDENTIFIER ) | PERF_SAMPLE_TIME | additionalSampleType; \ /* Emit emit value in group format */ \ pea.read_format = PERF_FORMAT_ID | PERF_FORMAT_GROUP; \ /* start out disabled */ \ pea.disabled = 1; \ /* have a sampling interrupt happen when we cross the wakeup_watermark boundary */ \ pea.watermark = 1; \ /* Be conservative in flush size as only one buffer set is monitored */ \ pea.wakeup_watermark = BUF_SIZE / 2; \
HwmonCounter::HwmonCounter(HwmonCounter *next, const sensors_chip_name *chip, const sensors_feature *feature) : next(next), key(getEventKey()), polled(false), readable(false), enabled(false), duplicate(false), chip(chip), feature(feature) { int len = sensors_snprintf_chip_name(NULL, 0, chip) + 1; char *chip_name = new char[len]; sensors_snprintf_chip_name(chip_name, len, chip); len = snprintf(NULL, 0, "hwmon_%s_%d", chip_name, feature->number) + 1; name = new char[len]; snprintf(name, len, "hwmon_%s_%d", chip_name, feature->number); delete [] chip_name; label = sensors_get_label(chip, feature); switch (feature->type) { case SENSORS_FEATURE_IN: title = "Voltage"; input = SENSORS_SUBFEATURE_IN_INPUT; display = "maximum"; counter_class = "absolute"; unit = "V"; modifier = 1000; monotonic = false; break; case SENSORS_FEATURE_FAN: title = "Fan"; input = SENSORS_SUBFEATURE_FAN_INPUT; display = "average"; counter_class = "absolute"; unit = "RPM"; modifier = 1; monotonic = false; break; case SENSORS_FEATURE_TEMP: title = "Temperature"; input = SENSORS_SUBFEATURE_TEMP_INPUT; display = "maximum"; counter_class = "absolute"; unit = "°C"; modifier = 1000; monotonic = false; break; case SENSORS_FEATURE_POWER: title = "Power"; input = SENSORS_SUBFEATURE_POWER_INPUT; display = "maximum"; counter_class = "absolute"; unit = "W"; modifier = 1000000; monotonic = false; break; case SENSORS_FEATURE_ENERGY: title = "Energy"; input = SENSORS_SUBFEATURE_ENERGY_INPUT; display = "accumulate"; counter_class = "delta"; unit = "J"; modifier = 1000000; monotonic = true; break; case SENSORS_FEATURE_CURR: title = "Current"; input = SENSORS_SUBFEATURE_CURR_INPUT; display = "maximum"; counter_class = "absolute"; unit = "A"; modifier = 1000; monotonic = false; break; case SENSORS_FEATURE_HUMIDITY: title = "Humidity"; input = SENSORS_SUBFEATURE_HUMIDITY_INPUT; display = "average"; counter_class = "absolute"; unit = "%"; modifier = 1000; monotonic = false; break; default: logg->logError(__FILE__, __LINE__, "Unsupported hwmon feature %i", feature->type); handleException(); } for (HwmonCounter * counter = next; counter != NULL; counter = counter->getNext()) { if (strcmp(label, counter->getLabel()) == 0 && strcmp(title, counter->getTitle()) == 0) { duplicate = true; counter->duplicate = true; break; } } }
PerfCounter(PerfCounter *next, const char *name, uint32_t type, uint64_t config, bool perCpu) : mNext(next), mName(name), mType(type), mCount(0), mKey(getEventKey()), mConfig(config), mEnabled(false), mPerCpu(perCpu) {}