/* * sched_core_update_cookie - replace the cookie on a task * @p: the task to update * @cookie: the new cookie * * Effectively exchange the task cookie; caller is responsible for lifetimes on * both ends. * * Returns: the old cookie
*/ staticunsignedlong sched_core_update_cookie(struct task_struct *p, unsignedlong cookie)
{ unsignedlong old_cookie; struct rq_flags rf; struct rq *rq;
rq = task_rq_lock(p, &rf);
/* * Since creating a cookie implies sched_core_get(), and we cannot set * a cookie until after we've created it, similarly, we cannot destroy * a cookie until after we've removed it, we must have core scheduling * enabled here.
*/
WARN_ON_ONCE((p->core_cookie || cookie) && !sched_core_enabled(rq));
if (sched_core_enqueued(p))
sched_core_dequeue(rq, p, DEQUEUE_SAVE);
/* * Consider the cases: !prev_cookie and !cookie.
*/ if (cookie && task_on_rq_queued(p))
sched_core_enqueue(rq, p);
/* * If task is currently running, it may not be compatible anymore after * the cookie change, so enter the scheduler on its CPU to schedule it * away. * * Note that it is possible that as a result of this cookie change, the * core has now entered/left forced idle state. Defer accounting to the * next scheduling edge, rather than always forcing a reschedule here.
*/ if (task_on_cpu(rq, p))
resched_curr(rq);
/* * Check if this process has the right to modify the specified * process. Use the regular "ptrace_may_access()" checks.
*/ if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) {
err = -EPERM; goto out;
}
delta = now - rq->core->core_forceidle_start; if (unlikely((s64)delta <= 0)) return;
rq->core->core_forceidle_start = now;
if (WARN_ON_ONCE(!rq->core->core_forceidle_occupation)) { /* can't be forced idle without a running task */
} elseif (rq->core->core_forceidle_count > 1 ||
rq->core->core_forceidle_occupation > 1) { /* * For larger SMT configurations, we need to scale the charged * forced idle amount since there can be more than one forced * idle sibling and more than one running cookied task.
*/
delta *= rq->core->core_forceidle_count;
delta = div_u64(delta, rq->core->core_forceidle_occupation);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.