gpu_subarray_free(mem);
mem = smalloc(config.samples * sizeof(void *));
for (i = 0; i < config.samples; i++) {
+ // (s)calloc used so pointers in structs are initialized to
+ // NULLs for Sysman metric state/property Get calls
mem[i] = scalloc(count, size);
}
return mem;
char buf[32];
*pci_bdf = *pci_dev = NULL;
- zes_pci_properties_t pci;
+ zes_pci_properties_t pci = {.pNext = NULL};
ze_result_t ret = zesDevicePciGetProperties(dev, &pci);
if (ret == ZE_RESULT_SUCCESS) {
const zes_pci_address_t *addr = &pci.address;
}
INFO("HW state:");
- zes_device_state_t state;
+ zes_device_state_t state = {.pNext = NULL};
/* Note: there's also zesDevicePciGetState() for PCI link status */
if (ret = zesDeviceGetState(dev, &state), ret == ZE_RESULT_SUCCESS) {
INFO("- repaired: %s",
}
INFO("HW identification:");
- zes_device_properties_t props;
+ zes_device_properties_t props = {.pNext = NULL};
if (ret = zesDeviceGetProperties(dev, &props), ret == ZE_RESULT_SUCCESS) {
const ze_device_properties_t *core = &props.core;
snprintf(buf, sizeof(buf), "0x%x", core->deviceId);
WARNING(PLUGIN_NAME ": failed to get memory properties count => 0x%x", ret);
return true;
}
- ze_device_memory_properties_t *mems;
- mems = scalloc(mem_count, sizeof(*mems));
+ ze_device_memory_properties_t *mems = scalloc(mem_count, sizeof(*mems));
if (ret = zeDeviceGetMemoryProperties(mdev, &mem_count, mems),
ret != ZE_RESULT_SUCCESS) {
WARNING(PLUGIN_NAME ": failed to get %d memory properties => 0x%x",
}
/* Get all GPU devices for the driver */
for (uint32_t dev_idx = 0; dev_idx < dev_count; dev_idx++) {
- ze_device_properties_t props;
+ ze_device_properties_t props = {.pNext = NULL};
if (ret = zeDeviceGetProperties(devs[dev_idx], &props),
ret != ZE_RESULT_SUCCESS) {
ERROR(PLUGIN_NAME
bool ok = false;
for (i = 0; i < ras_count; i++) {
- zes_ras_properties_t props;
+ zes_ras_properties_t props = {.pNext = NULL};
if (ret = zesRasGetProperties(ras[i], &props), ret != ZE_RESULT_SUCCESS) {
ERROR(PLUGIN_NAME ": failed to get RAS set %d properties => 0x%x", i,
ret);
snprintf(buf, sizeof(buf), "%d", props.subdeviceId);
subdev = buf;
}
- zes_ras_state_t values;
const bool clear = false;
+ zes_ras_state_t values = {.pNext = NULL};
if (ret = zesRasGetState(ras[i], clear, &values),
ret != ZE_RESULT_SUCCESS) {
ERROR(PLUGIN_NAME ": failed to get RAS set %d (%s) state => 0x%x", i,
* for success
*/
static ze_result_t set_mem_labels(zes_mem_handle_t mem, metric_t *metric) {
- zes_mem_properties_t props;
+ zes_mem_properties_t props = {.pNext = NULL};
ze_result_t ret = zesMemoryGetProperties(mem, &props);
if (ret != ZE_RESULT_SUCCESS) {
return ret;
*/
static ze_result_t set_freq_labels(zes_freq_handle_t freq, metric_t *metric,
double *maxfreq) {
- zes_freq_properties_t props;
+ zes_freq_properties_t props = {.pNext = NULL};
ze_result_t ret = zesFrequencyGetProperties(freq, &props);
if (ret != ZE_RESULT_SUCCESS) {
return ret;
bool reported_ratio = false, ok = false;
for (i = 0; i < temp_count; i++) {
- zes_temp_properties_t props;
+ zes_temp_properties_t props = {.pNext = NULL};
if (ret = zesTemperatureGetProperties(temps[i], &props),
ret != ZE_RESULT_SUCCESS) {
ERROR(PLUGIN_NAME
bool ok = false;
for (i = 0; i < power_count; i++) {
- zes_power_properties_t props;
+ zes_power_properties_t props = {.pNext = NULL};
if (ret = zesPowerGetProperties(powers[i], &props),
ret != ZE_RESULT_SUCCESS) {
ERROR(PLUGIN_NAME ": failed to get power domain %d properties => 0x%x", i,
int type_idx[16] = {0};
bool reported_ratio = false, reported_counter = false, ok = false;
for (i = 0; i < engine_count; i++) {
- zes_engine_properties_t props;
+ zes_engine_properties_t props = {.pNext = NULL};
if (ret = zesEngineGetProperties(engines[i], &props),
ret != ZE_RESULT_SUCCESS) {
ERROR(PLUGIN_NAME ": failed to get engine group %d properties => 0x%x", i,
* - All registered config variables work and invalid config values are rejected
* - All mocked up Sysman functions get called when no errors are returned and
* count of Sysman calls is always same for plugin init() and read() callbacks
+ * - .pNext pointers in structs given to (most) Get functions are initialized
* - Plugin dispatch API receives correct values for all metrics, both in
* single-sampling, and in multi-sampling configurations
* - Every Sysman call failure during init or metrics queries is logged, and
ze_device_properties_t *props) {
ze_result_t ret = dev_args_check(3, "zeDeviceGetProperties", dev, props);
if (ret == ZE_RESULT_SUCCESS) {
+ assert(!props->pNext);
memset(props, 0, sizeof(*props));
props->type = ZE_DEVICE_TYPE_GPU;
}
*count = 1;
if (!props)
return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
+ assert(!props->pNext);
memset(props, 0, sizeof(*props));
return ZE_RESULT_SUCCESS;
}
#define DEV_GET_ZEROED_STRUCT(callbit, getname, structtype) \
ze_result_t getname(zes_device_handle_t dev, structtype *to_zero) { \
ze_result_t ret = dev_args_check(callbit, #getname, dev, to_zero); \
- if (ret == ZE_RESULT_SUCCESS) \
+ if (ret == ZE_RESULT_SUCCESS) { \
+ assert(!to_zero->pNext); \
memset(to_zero, 0, sizeof(*to_zero)); \
+ } \
return ret; \
}
ze_result_t propname(handletype handle, proptype *prop) { \
ze_result_t ret = metric_args_check(callbit + 1, #propname, handle, prop); \
if (ret == ZE_RESULT_SUCCESS) { \
+ assert(!prop->pNext); \
*prop = propvar; \
prop->onSubdevice = true; \
} \
if (clear) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
+ assert(!state->pNext);
static uint64_t count = RAS_INIT;
memset(state, 0, sizeof(zes_ras_state_t));
/* props default to zeroes i.e. correctable error type,