public inbox for linux-kernel@vger.kernel.org
 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 v2 1/2] sched/rt: Check to push task away when its affinity is changed
Date: Tue, 5 May 2015 14:09:46 +0200	[thread overview]
Message-ID: <20150505120946.GL21418@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1430826968-10251-1-git-send-email-xlpang@126.com>

On Tue, May 05, 2015 at 07:56:07PM +0800, Xunlei Pang wrote:
> +++ b/kernel/sched/core.c
> @@ -4773,6 +4773,9 @@ void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask)
>  
>  	cpumask_copy(&p->cpus_allowed, new_mask);
>  	p->nr_cpus_allowed = cpumask_weight(new_mask);
> +
> +	if (p->sched_class->post_set_cpus_allowed)
> +		p->sched_class->post_set_cpus_allowed(p);
>  }
>  
>  /*
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 8885b65..4176f33 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -2280,6 +2280,20 @@ static void set_cpus_allowed_rt(struct task_struct *p,
>  	update_rt_migration(&rq->rt);
>  }
>  
> +static void post_set_cpus_allowed_rt(struct task_struct *p)
> +{
> +	struct rq *rq;
> +
> +	if (!task_on_rq_queued(p))
> +		return;
> +
> +	rq = task_rq(p);
> +	if (!task_running(rq, p) &&
> +	    p->nr_cpus_allowed > 1 &&
> +	    !test_tsk_need_resched(rq->curr))
> +		push_rt_tasks(rq);
> +}

Guys, this is disgusting. Please don't do these minimal effort hacks.

Either fix up all the classes with a trivial set_cpus_allowed() function
and make do_set_cpus_allowed() := p->sched_class->set_cpus_allowed().

Or just do the p->{nr_,}cpus_allowed assignments in
set_cpus_allowed_rt() and keep it all in the one callback.

  parent reply	other threads:[~2015-05-05 12:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-05 11:56 [PATCH v2 1/2] sched/rt: Check to push task away when its affinity is changed Xunlei Pang
2015-05-05 11:56 ` [PATCH v2 2/2] sched/rt: Remove redundant conditions from task_woken_rt() Xunlei Pang
2015-05-05 12:09 ` Peter Zijlstra [this message]
     [not found]   ` <OF0AFAEB82.B1AB4A37-ON48257E3C.0052FA35-48257E3C.00540890@zte.com.cn>
2015-05-08 17:28     ` [PATCH v2 1/2] sched/rt: Check to push task away when its affinity is changed 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=20150505120946.GL21418@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