static cputime64_t get_iowait_time(int cpu) { u64 iowait_time = get_cpu_iowait_time_us(cpu, NULL); cputime64_t iowait; if (iowait_time == -1ULL) /* !NO_HZ so we can rely on cpustat.iowait */ iowait = kstat_cpu(cpu).cpustat.iowait; else iowait = nsecs_to_jiffies64(1000 * iowait_time); return iowait; }
static cputime64_t get_idle_time(int cpu) { u64 idle_time = get_cpu_idle_time_us(cpu, NULL); cputime64_t idle; if (idle_time == -1ULL) { /* !NO_HZ so we can rely on cpustat.idle */ idle = kstat_cpu(cpu).cpustat.idle; idle = cputime64_add(idle, arch_idle_time(cpu)); } else idle = nsecs_to_jiffies64(1000 * idle_time); return idle; }
/* * wait synchronously for a call to complete */ static long afs_wait_for_call_to_complete(struct afs_call *call, struct afs_addr_cursor *ac) { signed long rtt2, timeout; long ret; u64 rtt; u32 life, last_life; DECLARE_WAITQUEUE(myself, current); _enter(""); rtt = rxrpc_kernel_get_rtt(call->net->socket, call->rxcall); rtt2 = nsecs_to_jiffies64(rtt) * 2; if (rtt2 < 2) rtt2 = 2; timeout = rtt2; last_life = rxrpc_kernel_check_life(call->net->socket, call->rxcall); add_wait_queue(&call->waitq, &myself); for (;;) { set_current_state(TASK_UNINTERRUPTIBLE); /* deliver any messages that are in the queue */ if (!afs_check_call_state(call, AFS_CALL_COMPLETE) && call->need_attention) { call->need_attention = false; __set_current_state(TASK_RUNNING); afs_deliver_to_call(call); continue; } if (afs_check_call_state(call, AFS_CALL_COMPLETE)) break; life = rxrpc_kernel_check_life(call->net->socket, call->rxcall); if (timeout == 0 && life == last_life && signal_pending(current)) break; if (life != last_life) { timeout = rtt2; last_life = life; } timeout = schedule_timeout(timeout); } remove_wait_queue(&call->waitq, &myself); __set_current_state(TASK_RUNNING); /* Kill off the call if it's still live. */ if (!afs_check_call_state(call, AFS_CALL_COMPLETE)) { _debug("call interrupted"); if (rxrpc_kernel_abort_call(call->net->socket, call->rxcall, RX_USER_ABORT, -EINTR, "KWI")) afs_set_call_complete(call, -EINTR, 0); } spin_lock_bh(&call->state_lock); ac->abort_code = call->abort_code; ac->error = call->error; spin_unlock_bh(&call->state_lock); ret = ac->error; switch (ret) { case 0: if (call->ret_reply0) { ret = (long)call->reply[0]; call->reply[0] = NULL; } /* Fall through */ case -ECONNABORTED: ac->responded = true; break; } _debug("call complete"); afs_put_call(call); _leave(" = %p", (void *)ret); return ret; }