From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422758AbbEEMKQ (ORCPT ); Tue, 5 May 2015 08:10:16 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:55296 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422679AbbEEMKJ (ORCPT ); Tue, 5 May 2015 08:10:09 -0400 Date: Tue, 5 May 2015 14:09:46 +0200 From: Peter Zijlstra To: Xunlei Pang Cc: linux-kernel@vger.kernel.org, Steven Rostedt , Juri Lelli , Ingo Molnar , Xunlei Pang Subject: Re: [PATCH v2 1/2] sched/rt: Check to push task away when its affinity is changed Message-ID: <20150505120946.GL21418@twins.programming.kicks-ass.net> References: <1430826968-10251-1-git-send-email-xlpang@126.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1430826968-10251-1-git-send-email-xlpang@126.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.