From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752789AbdATQPJ (ORCPT ); Fri, 20 Jan 2017 11:15:09 -0500 Received: from smtprelay0235.hostedemail.com ([216.40.44.235]:46677 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752373AbdATQPG (ORCPT ); Fri, 20 Jan 2017 11:15:06 -0500 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::,RULES_HIT:41:355:379:541:599:800:960:968:973:981:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4362:5007:6119:6261:7875:7903:7974:8660:10004:10400:10562:10848:10967:11026:11232:11658:11914:12043:12295:12296:12555:12740:12760:12895:13148:13221:13229:13230:13439:14096:14097:14181:14659:14721:21080:21325:21451:30012:30054:30070:30090:30091,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:0:0,LFtime:5,LUA_SUMMARY:none X-HE-Tag: vase80_7e394340ac53f X-Filterd-Recvd-Size: 3207 Date: Fri, 20 Jan 2017 11:14:25 -0500 From: Steven Rostedt To: Peter Zijlstra Cc: LKML , Ingo Molnar , Andrew Morton Subject: Re: [PATCH] sched: Optimize pick_next_task for idle_sched_class too Message-ID: <20170120111425.5afaad5c@gandalf.local.home> In-Reply-To: <20170119174408.GN6485@twins.programming.kicks-ass.net> References: <20170119101703.2abeaeb6@gandalf.local.home> <20170119174408.GN6485@twins.programming.kicks-ass.net> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; 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, 19 Jan 2017 18:44:08 +0100 Peter Zijlstra wrote: - if (likely(prev->sched_class == class && > > + if (likely((prev->sched_class == class || > > + prev->sched_class == idle_class) && > > rq->nr_running == rq->cfs.h_nr_running)) { > > OK, so I hate this patch because it makes the condition more complex, > and while staring at what it does for code generation I couldn't for the > life of me figure out why we care about prev->sched_class to begin with. I was thinking it would save on checking the rq at all, but rq is used by pick_next_task_*() anyway, so I doubt it's much savings. > > (we used to, but the current code not so much) > > So I simply removed that entire clause, like below, and lo and behold, > the system booted... I thought about doing this too, but decided against it because I was thinking that since class (and now idle_class) are constants, it would help the non cfs case. Checking prev->sched_class against a constant I thought would be quick. But yeah, I doubt it matters much in the grand scale of things. > > Could you give it a spin to see if anything comes apart? Yeah this works. You can add: Reported-by: Steven Rostedt (VMware) Tested-by: Steven Rostedt (VMware) Thanks, -- Steve > > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 49ce1cb..51ca21e 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -3321,15 +3321,14 @@ static inline void schedule_debug(struct task_struct *prev) > static inline struct task_struct * > pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) > { > - const struct sched_class *class = &fair_sched_class; > + const struct sched_class *class; > struct task_struct *p; > > /* > * Optimization: we know that if all tasks are in > * the fair class we can call that function directly: > */ > - if (likely(prev->sched_class == class && > - rq->nr_running == rq->cfs.h_nr_running)) { > + if (likely(rq->nr_running == rq->cfs.h_nr_running)) { > p = fair_sched_class.pick_next_task(rq, prev, rf); > if (unlikely(p == RETRY_TASK)) > goto again;