From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755164AbbDIN4p (ORCPT ); Thu, 9 Apr 2015 09:56:45 -0400 Received: from smtprelay0229.hostedemail.com ([216.40.44.229]:37247 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753305AbbDIN4m (ORCPT ); Thu, 9 Apr 2015 09:56:42 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 10,1,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1543:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2895:3138:3139:3140:3141:3142:3151:3355:3622:3865:3866:3867:3868:3870:3871:3872:3873:5007:6120:6261:7875:7901:7903:7974:10007:10400:10848:10967:11026:11232:11658:11914:12043:12291:12296:12438:12517:12519:12555:12663:12740:13161:13229:13255:14096:14097:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:1:0 X-HE-Tag: leg77_7460719fd7e0b X-Filterd-Recvd-Size: 4542 Date: Thu, 9 Apr 2015 09:56:38 -0400 From: Steven Rostedt To: Xunlei Pang Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Juri Lelli , Dan Streetman , Xunlei Pang Subject: Re: [PATCH v5 2/3] sched/rt: Fix wrong SMP scheduler behavior for equal prio cases Message-ID: <20150409095638.4fe20620@gandalf.local.home> In-Reply-To: <1428550038-13619-2-git-send-email-xlpang@126.com> References: <1428550038-13619-1-git-send-email-xlpang@126.com> <1428550038-13619-2-git-send-email-xlpang@126.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 9 Apr 2015 11:27:17 +0800 Xunlei Pang wrote: > Suggested-by: Steven Rostedt > Signed-off-by: Xunlei Pang > --- > kernel/sched/rt.c | 26 ++++++++++++++++++++------ > 1 file changed, 20 insertions(+), 6 deletions(-) > > diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c > index 575da76..402162a 100644 > --- a/kernel/sched/rt.c > +++ b/kernel/sched/rt.c > @@ -359,11 +359,15 @@ static inline void set_post_schedule(struct rq *rq) > rq->post_schedule = has_pushable_tasks(rq); > } > > -static void enqueue_pushable_task(struct rq *rq, struct task_struct *p) > +static void > +enqueue_pushable_task(struct rq *rq, struct task_struct *p, bool head) > { > plist_del(&p->pushable_tasks, &rq->rt.pushable_tasks); > plist_node_init(&p->pushable_tasks, p->prio); > - plist_add(&p->pushable_tasks, &rq->rt.pushable_tasks); > + if (head) > + plist_add_head(&p->pushable_tasks, &rq->rt.pushable_tasks); > + else > + plist_add_tail(&p->pushable_tasks, &rq->rt.pushable_tasks); > > /* Update the highest prio pushable task */ > if (p->prio < rq->rt.highest_prio.next) > @@ -385,7 +389,8 @@ static void dequeue_pushable_task(struct rq *rq, struct task_struct *p) > > #else > > -static inline void enqueue_pushable_task(struct rq *rq, struct task_struct *p) > +static inline > +void enqueue_pushable_task(struct rq *rq, struct task_struct *p, bool head) > { > } > > @@ -1260,7 +1265,7 @@ enqueue_task_rt(struct rq *rq, struct task_struct *p, int flags) > enqueue_rt_entity(rt_se, flags & ENQUEUE_HEAD); > > if (!task_current(rq, p) && p->nr_cpus_allowed > 1) > - enqueue_pushable_task(rq, p); > + enqueue_pushable_task(rq, p, false); Hmm, I really don't like the "false" parameter all over the place, since it's only needed in one place. Thinking about this more, what about keeping enqueue_pushable_task() as is, and adding an enqueue_pushable_task_preempted(). Having something like this: static inline void enqueue_pushable_task(struct rq *rq, struct task_struct *p) { enqueue_pushable_task_preempted(rq, p, false); } > } > > static void dequeue_task_rt(struct rq *rq, struct task_struct *p, int flags) > @@ -1507,7 +1512,16 @@ static void put_prev_task_rt(struct rq *rq, struct task_struct *p) > * if it is still active > */ > if (on_rt_rq(&p->rt) && p->nr_cpus_allowed > 1) > - enqueue_pushable_task(rq, p); > + /* > + * put_prev_task_rt() is called by many functions, > + * pick_next_task_rt() is the only one may have > + * PREEMPT_ACTIVE set. So if detecting p(current > + * task) is preempted in such case, we should > + * enqueue it to the front of the pushable plist, > + * as there may be multiple tasks with the same > + * priority as p. > + */ > + enqueue_pushable_task(rq, p, !!(preempt_count() & PREEMPT_ACTIVE)); Then we don't need to touch any of the code but this place, and this would be: enqueue_pushable_task_preempted(rq, p, !!(preempt_count() & PREEMPT_ACTIVE)); I'm thinking this would be much more descriptive. What do you think? -- Steve > } > > #ifdef CONFIG_SMP > @@ -2091,7 +2105,7 @@ static void set_cpus_allowed_rt(struct task_struct *p, > rq->rt.rt_nr_migratory--; > } else { > if (!task_current(rq, p)) > - enqueue_pushable_task(rq, p); > + enqueue_pushable_task(rq, p, false); > rq->rt.rt_nr_migratory++; > } >