static void *_watch_node(void *arg) { int type = PROFILE_NETWORK; #if HAVE_SYS_PRCTL_H if (prctl(PR_SET_NAME, "acctg_ib", NULL, NULL, NULL) < 0) { error("%s: cannot set my name to %s %m", __func__, "acctg_ib"); } #endif (void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); (void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); while (init_run && acct_gather_profile_test()) { /* Do this until shutdown is requested */ slurm_mutex_lock(&g_context_lock); (*(ops.node_update))(); slurm_mutex_unlock(&g_context_lock); slurm_mutex_lock(&acct_gather_profile_timer[type].notify_mutex); slurm_cond_wait( &acct_gather_profile_timer[type].notify, &acct_gather_profile_timer[type].notify_mutex); slurm_mutex_unlock(&acct_gather_profile_timer[type]. notify_mutex); } return NULL; }
static void *_watch_node(void *arg) { int i; #if HAVE_SYS_PRCTL_H if (prctl(PR_SET_NAME, "acctg_intrcnt", NULL, NULL, NULL) < 0) { error("%s: cannot set my name to %s %m", __func__, "acctg_ib"); } #endif while (init_run && acct_gather_profile_test()) { /* Do this until shutdown is requested */ slurm_mutex_lock(&g_context_lock); for (i = 0; i < g_context_num; i++) { if (!g_context[i]) continue; (*(ops[i].node_update))(); } slurm_mutex_unlock(&g_context_lock); slurm_mutex_lock(&profile_timer->notify_mutex); slurm_cond_wait(&profile_timer->notify, &profile_timer->notify_mutex); slurm_mutex_unlock(&profile_timer->notify_mutex); } return NULL; }
static void *_watch_tasks(void *arg) { int type = PROFILE_TASK; #if HAVE_SYS_PRCTL_H if (prctl(PR_SET_NAME, "acctg", NULL, NULL, NULL) < 0) { error("%s: cannot set my name to %s %m", __func__, "acctg"); } #endif (void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); (void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); /* Give chance for processes to spawn before starting * the polling. This should largely eliminate the * the chance of having /proc open when the tasks are * spawned, which would prevent a valid checkpoint/restart * with some systems */ _task_sleep(1); while (_init_run_test() && !_jobacct_shutdown_test() && acct_gather_profile_test()) { /* Do this until shutdown is requested */ slurm_mutex_lock(&acct_gather_profile_timer[type].notify_mutex); slurm_cond_wait( &acct_gather_profile_timer[type].notify, &acct_gather_profile_timer[type].notify_mutex); slurm_mutex_unlock(&acct_gather_profile_timer[type]. notify_mutex); slurm_mutex_lock(&g_context_lock); /* The initial poll is done after the last task is added */ _poll_data(1); slurm_mutex_unlock(&g_context_lock); } return NULL; }
static void *_timer_thread(void *args) { int i, now, diff; #if HAVE_SYS_PRCTL_H if (prctl(PR_SET_NAME, "acctg_prof", NULL, NULL, NULL) < 0) { error("%s: cannot set my name to %s %m", __func__, "acctg_prof"); } #endif (void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); (void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); DEF_TIMERS; while (init_run && acct_gather_profile_test()) { slurm_mutex_lock(&g_context_lock); START_TIMER; now = time(NULL); for (i=0; i<PROFILE_CNT; i++) { if (acct_gather_suspend_test()) { /* Handle suspended time as if it * didn't happen */ if (!acct_gather_profile_timer[i].freq) continue; if (acct_gather_profile_timer[i].last_notify) acct_gather_profile_timer[i]. last_notify += SLEEP_TIME; else acct_gather_profile_timer[i]. last_notify = now; continue; } diff = now - acct_gather_profile_timer[i].last_notify; /* info ("%d is %d and %d", i, */ /* acct_gather_profile_timer[i].freq, */ /* diff); */ if (!acct_gather_profile_timer[i].freq || (diff < acct_gather_profile_timer[i].freq)) continue; if (!acct_gather_profile_test()) break; /* Shutting down */ debug2("profile signaling type %s", acct_gather_profile_type_t_name(i)); /* signal poller to start */ slurm_mutex_lock(&acct_gather_profile_timer[i]. notify_mutex); slurm_cond_signal( &acct_gather_profile_timer[i].notify); slurm_mutex_unlock(&acct_gather_profile_timer[i]. notify_mutex); acct_gather_profile_timer[i].last_notify = now; } END_TIMER; slurm_mutex_unlock(&g_context_lock); usleep(USLEEP_TIME - DELTA_TIMER); } return NULL; }