mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Xunlei Pang <xlpang@126.com>
Cc: linux-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Juri Lelli <juri.lelli@gmail.com>, Ingo Molnar <mingo@redhat.com>,
	Xunlei Pang <pang.xunlei@linaro.org>
Subject: Re: [PATCH v3 1/4] sched/rt: Check to push the task away after its affinity was changed
Date: Fri, 29 May 2015 15:16:26 +0200	[thread overview]
Message-ID: <20150529131626.GK19282@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1431442004-18716-1-git-send-email-xlpang@126.com>

On Tue, May 12, 2015 at 10:46:41PM +0800, Xunlei Pang wrote:
> @@ -2278,6 +2279,20 @@ static void set_cpus_allowed_rt(struct task_struct *p,
>  	}
>  
>  	update_rt_migration(&rq->rt);
> +
> +check_push:
> +	if (weight > 1 &&
> +	    !task_running(rq, p) &&
> +	    !test_tsk_need_resched(rq->curr) &&
> +	    !cpumask_subset(new_mask, &p->cpus_allowed)) {
> +		/* Update new affinity and try to push. */
> +		cpumask_copy(&p->cpus_allowed, new_mask);
> +		p->nr_cpus_allowed = weight;
> +		push_rt_tasks(rq);
> +		return true;
> +	}
> +
> +	return false;
>  }

I think this is broken; push_rt_tasks() will do double_rq_lock() which
will drop rq->lock.

This means load-balancing can come in and move our task p; in fact,
push_rt_task() can do exactly that -- after all that was the point of
this patch.

_However_ this means that after calling ->set_cpus_allowed() we must not
assume @p is on @rt, yet we do. Look at __set_cpus_allowed_ptr(), we'll
call move_queued_task() if (!running || waking) && on_rq, and
move_queued_task() happily calls dequeue_task(rq, p), which will go
*boom*.

I currently do not have a better idea than to repurpose the PUSH_IPI
stuff, that is, send a self IPI to go do the push or somesuch. Lemme
stare at this a little more.

  parent reply	other threads:[~2015-05-29 13:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12 14:46 Xunlei Pang
2015-05-12 14:46 ` [PATCH v3 2/4] sched/deadline: " Xunlei Pang
2015-05-12 14:46 ` [PATCH v3 3/4] sched/rt: Remove redundant conditions from task_woken_rt() Xunlei Pang
2015-05-12 14:46 ` [PATCH v3 4/4] sched/deadline: Remove redundant conditions from task_woken_dl() Xunlei Pang
2015-05-29 13:16 ` Peter Zijlstra [this message]
     [not found]   ` <OF8BB81194.1A32A464-ON48257E54.004C068A-48257E54.004D51E2@zte.com.cn>
2015-05-30  8:20     ` [PATCH v3 1/4] sched/rt: Check to push the task away after its affinity was changed Peter Zijlstra
2015-05-30 10:54       ` Peter Zijlstra
2015-05-30 16:30         ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150529131626.GK19282@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=juri.lelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pang.xunlei@linaro.org \
    --cc=rostedt@goodmis.org \
    --cc=xlpang@126.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome