Skip to content

Commit

Permalink
Collect the statistics of LDMSD's worker threads
Browse files Browse the repository at this point in the history
  • Loading branch information
nichamon committed Dec 20, 2023
1 parent a681f5a commit 259cde0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
40 changes: 40 additions & 0 deletions ldms/src/ldmsd/ldmsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,46 @@ pthread_t get_thread(int idx)
return ev_thread[idx];
}

void ldmsd_worker_thrstat_free(struct ldmsd_worker_thrstat_result *res)
{
if (!res)
return;

int i;
for (i = 0; i < res->count; i++) {
ovis_scheduler_thrstat_free(res->entries[i]);
}
free(res);
}

struct ldmsd_worker_thrstat_result *ldmsd_worker_thrstat_get()
{
int i;
struct ldmsd_worker_thrstat_result *res;
struct timespec now;

clock_gettime(CLOCK_REALTIME, &now);
res = malloc(sizeof(*res) +
(ev_thread_count * sizeof(struct ovis_scheduler_thrstat *)));
if (!res) {
ovis_log(NULL, OVIS_LCRIT, "Memory allocation failure.\n");
return NULL;
}
res->count = 0;
for (i = 0; i < ev_thread_count; i++) {
res->entries[i] = ovis_scheduler_thrstat_get(ovis_scheduler[i], &now);
if (!res->entries[i]) {
ovis_log(NULL, OVIS_LCRIT, "Memory allocation failure.\n");
goto err;
}
res->count++;
}
return res;
err:
ldmsd_worker_thrstat_free(res);
return NULL;
}

void kpublish(int map_fd, int set_no, int set_size, char *set_name)
{
ldms_set_t map_set;
Expand Down
5 changes: 5 additions & 0 deletions ldms/src/ldmsd/ldmsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,11 @@ typedef struct ldmsd_row_list_s *ldmsd_row_list_t;

typedef struct ldmsd_req_ctxt *ldmsd_req_ctxt_t;

struct ldmsd_worker_thrstat_result {
int count; /* Number of worker threads */
struct ovis_scheduler_thrstat *entries[0];
};

/**
* A utility to convert \c row to JSON array.
*
Expand Down

0 comments on commit 259cde0

Please sign in to comment.