Skip to content

Commit

Permalink
Merge "resctrl: allow monitoring stop for non-existent pids."
Browse files Browse the repository at this point in the history
  • Loading branch information
mstarzyx authored and Gerrit Code Review committed Jun 6, 2018
2 parents ddfb57d + 0dd2167 commit 2f06404
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/resctrl_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,10 +756,8 @@ resctrl_alloc_task_validate(const pid_t task)

memset(buf, 0, sizeof(buf));
snprintf(buf, sizeof(buf)-1, "/proc/%d", (int)task);
if (access(buf, F_OK) != 0) {
LOG_ERROR("Task %d does not exist!\n", (int)task);
if (access(buf, F_OK) != 0)
return PQOS_RETVAL_ERROR;
}

return PQOS_RETVAL_OK;
}
Expand All @@ -772,8 +770,10 @@ resctrl_alloc_task_write(const unsigned class_id, const pid_t task)

/* Check if task exists */
ret = resctrl_alloc_task_validate(task);
if (ret != PQOS_RETVAL_OK)
if (ret != PQOS_RETVAL_OK) {
LOG_ERROR("Task %d does not exist!\n", (int)task);
return PQOS_RETVAL_PARAM;
}

/* Open resctrl tasks file */
fd = resctrl_alloc_fopen(class_id, rctl_tasks, "w");
Expand Down Expand Up @@ -867,8 +867,10 @@ resctrl_alloc_task_search(unsigned *class_id,

/* Check if task exists */
ret = resctrl_alloc_task_validate(task);
if (ret != PQOS_RETVAL_OK)
if (ret != PQOS_RETVAL_OK) {
LOG_ERROR("Task %d does not exist!\n", (int)task);
return PQOS_RETVAL_PARAM;
}

/* Get number of COS */
ret = resctrl_alloc_get_grps_num(cap, &max_cos);
Expand Down
6 changes: 6 additions & 0 deletions lib/resctrl_monitoring.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,12 @@ resctrl_mon_stop(struct pqos_mon_data *group)
for (i = 0; i < group->tid_nr; i++) {
const pid_t tid = group->tid_map[i];

if (resctrl_alloc_task_validate(tid) !=
PQOS_RETVAL_OK) {
LOG_DEBUG("resctrl_mon_stop: Skipping "
"non-existant PID: %d\n", tid);
continue;
}
ret = resctrl_mon_assoc_set_pid(tid, NULL);
if (ret != PQOS_RETVAL_OK)
goto resctrl_mon_stop_exit;
Expand Down

0 comments on commit 2f06404

Please sign in to comment.