Skip to content

Commit

Permalink
slingshot_info: support ESM link speed internally
Browse files Browse the repository at this point in the history
  • Loading branch information
morrone authored and tom95858 committed Apr 3, 2024
1 parent 67cf679 commit 4506815
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions ldms/src/sampler/slingshot_info/slingshot_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,42 @@ static void set_pcie_speed(ldms_mval_t record_instance, int index, const char *d
char *speed = buf1;
char *width = buf2;
FILE *fp;
char *rc;
char *rc = NULL;

snprintf(path, PATH_MAX, "/sys/class/cxi/%s/device/current_link_speed",
/* First try current_esm_link_speed */
snprintf(path, PATH_MAX,
"/sys/class/cxi/%s/device/properties/current_esm_link_speed",
device_name);
fp = fopen(path, "r");
if (fp == NULL) {
log_fn(LDMSD_LWARNING, SAMP" unable to open \"%s\"\n", path);
return;
if (fp != NULL) {
rc = fgets(speed, PATH_MAX, fp);
fclose(fp);
if (rc != NULL) {
strip_whitespace(&speed);
}
}
rc = fgets(speed, PATH_MAX, fp);
fclose(fp);
if (rc == NULL) {
return;

/* Fall back to current_link_speed if needed */
if (rc == NULL
|| strcmp(speed, "Absent") == 0
|| strcmp(speed, "Disabled") == 0) {
snprintf(path, PATH_MAX,
"/sys/class/cxi/%s/device/current_link_speed",
device_name);
fp = fopen(path, "r");
if (fp == NULL) {
log_fn(LDMSD_LWARNING, SAMP" unable to open \"%s\"\n", path);
return;
}
rc = fgets(speed, PATH_MAX, fp);
fclose(fp);
if (rc == NULL) {
return;
}
strip_whitespace(&speed);
}
strip_whitespace(&speed);

/* Next look up pcie width */
snprintf(path, PATH_MAX, "/sys/class/cxi/%s/device/current_link_width",
device_name);
fp = fopen(path, "r");
Expand Down

0 comments on commit 4506815

Please sign in to comment.