Re: [PATCH v3 1/2] sched/rt: Check to push the task when changing its affinity
From: Steven Rostedt
Date: Thu Feb 12 2015 - 18:31:43 EST
On Sun, 8 Feb 2015 23:51:25 +0800
Xunlei Pang <pang.xunlei@xxxxxxxxxx> wrote:
> + if (new_weight > 1 &&
> + rt_task(rq->curr) &&
> + !test_tsk_need_resched(rq->curr)) {
> + /*
> + * We own p->pi_lock and rq->lock. rq->lock might
> + * get released when doing direct pushing, however
> + * p->pi_lock is always held, so it's safe to assign
> + * the new_mask and new_weight to p below.
> + */
> + if (!task_running(rq, p)) {
> + cpumask_copy(&p->cpus_allowed, new_mask);
> + p->nr_cpus_allowed = new_weight;
> + direct_push = 1;
> + } else if (cpumask_test_cpu(task_cpu(p), new_mask)) {
> + cpumask_copy(&p->cpus_allowed, new_mask);
> + p->nr_cpus_allowed = new_weight;
> + if (!cpupri_find(&rq->rd->cpupri, p, NULL))
> + goto update;
> +
> + /*
> + * At this point, current task gets migratable most
> + * likely due to the change of its affinity, let's
> + * figure out if we can migrate it.
> + *
> + * Is there any task with the same priority as that
> + * of current task? If found one, we should resched.
> + * NOTE: The target may be unpushable.
> + */
> + if (p->prio == rq->rt.highest_prio.next) {
> + /* One target just in pushable_tasks list. */
> + requeue_task_rt(rq, p, 0);
What's the purpose of the requeue_task_rt() here?
> + preempt_push = 1;
> + } else if (rq->rt.rt_nr_total > 1) {
> + struct task_struct *next;
> +
> + requeue_task_rt(rq, p, 0);
And here? It may just be late and I'm tired, but it's not obvious to me.
Thanks,
-- Steve
> + next = peek_next_task_rt(rq);
> + if (next != p && next->prio == p->prio)
> + preempt_push = 1;
> + }
> + }
> + }
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/