Skip to content

Commit

Permalink
mxqd_control: Track database values for global running slots and jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
mariux committed Nov 4, 2015
1 parent 79db558 commit bdb8114
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1336,13 +1336,16 @@ void server_dump(struct mxq_server *server)
continue;
}
group = &ulist->groups[0].group;
mx_log_info(" user=%s(%d) slots_running=%lu",
mx_log_info(" user=%s(%d) slots_running=%lu global_slots_running=%lu global_threads_running=%lu",
group->user_name,
group->user_uid,
ulist->slots_running);
ulist->slots_running,
ulist->global_slots_running,
ulist->global_threads_running);

for (glist = ulist->groups; glist; glist = glist->next) {
group = &glist->group;

mx_log_info(" group=%s(%d):%lu %s jobs_in_q=%lu",
group->user_name,
group->user_uid,
Expand All @@ -1369,6 +1372,9 @@ void server_dump(struct mxq_server *server)
server->slots,
server->threads_running,
server->jobs_running);
mx_log_info("global_slots_running=%lu global_threads_running=%lu",
server->global_slots_running,
server->global_threads_running);
cpuset_log("cpu set running",
&server->cpu_set_running);
mx_log_info("====================== SERVER DUMP END ======================");
Expand Down
9 changes: 9 additions & 0 deletions mxqd.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ struct mxq_group_list {
unsigned long slots_running;
unsigned long memory_used;

unsigned long global_threads_running;
unsigned long global_slots_running;

short orphaned;
};

Expand All @@ -54,6 +57,9 @@ struct mxq_user_list {
unsigned long threads_running;
unsigned long slots_running;
unsigned long memory_used;

unsigned long global_threads_running;
unsigned long global_slots_running;
};

struct mxq_server {
Expand All @@ -69,6 +75,9 @@ struct mxq_server {
unsigned long memory_used;
cpu_set_t cpu_set_running;

unsigned long global_threads_running;
unsigned long global_slots_running;

unsigned long slots;
unsigned long memory_total;
long double memory_avg_per_slot;
Expand Down
28 changes: 28 additions & 0 deletions mxqd_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,15 @@ struct mxq_group_list *_user_list_add_group(struct mxq_user_list *ulist, struct
ulist->group_cnt++;
server->group_cnt++;

glist->global_slots_running = group->group_slots_running;
glist->global_threads_running = group->group_jobs_running * group->job_threads;

ulist->global_slots_running += glist->global_slots_running;
ulist->global_threads_running += glist->global_threads_running;

server->global_slots_running += glist->global_slots_running;
server->global_threads_running += glist->global_threads_running;

_group_list_init(glist);

return glist;
Expand Down Expand Up @@ -354,15 +363,34 @@ struct mxq_group_list *_server_add_group(struct mxq_server *server, struct mxq_g
static struct mxq_group_list *_user_list_update_group(struct mxq_user_list *ulist, struct mxq_group *group)
{
struct mxq_group_list *glist;
struct mxq_server *server;

assert(ulist);
assert(group);
assert(ulist->server);

server = ulist->server;

glist = _group_list_find_by_group(ulist->groups, group);
if (!glist) {
return _user_list_add_group(ulist, group);
}

server->global_slots_running -= glist->global_slots_running;
server->global_threads_running -= glist->global_threads_running;

ulist->global_slots_running -= glist->global_slots_running;
ulist->global_threads_running -= glist->global_threads_running;

glist->global_slots_running = group->group_slots_running;
glist->global_threads_running = group->group_jobs_running * group->job_threads;

ulist->global_slots_running += glist->global_slots_running;
ulist->global_threads_running += glist->global_threads_running;

server->global_slots_running += glist->global_slots_running;
server->global_threads_running += glist->global_threads_running;

mxq_group_free_content(&glist->group);

memcpy(&glist->group, group, sizeof(*group));
Expand Down

0 comments on commit bdb8114

Please sign in to comment.