Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754190AbbKCNbb (ORCPT ); Tue, 3 Nov 2015 08:31:31 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:40316 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753549AbbKCNba (ORCPT ); Tue, 3 Nov 2015 08:31:30 -0500 Date: Tue, 3 Nov 2015 14:31:20 +0100 From: Peter Zijlstra To: Jacob Pan Cc: Thomas Gleixner , LKML , Arjan van de Ven , Paul Turner , Len Brown , Srinivas Pandruvada , Tim Chen , Andi Kleen , Rafael Wysocki Subject: Re: [RFC PATCH 3/3] sched: introduce synchronized idle injection Message-ID: <20151103133120.GD17308@twins.programming.kicks-ass.net> References: <1446509428-5616-1-git-send-email-jacob.jun.pan@linux.intel.com> <1446509428-5616-4-git-send-email-jacob.jun.pan@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1446509428-5616-4-git-send-email-jacob.jun.pan@linux.intel.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 Content-Length: 1383 Lines: 39 > @@ -5136,6 +5148,16 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev) > struct task_struct *p; > int new_tasks; > > +#ifdef CONFIG_CFS_IDLE_INJECT > + if (cfs_rq->force_throttled && > + !idle_cpu(cpu_of(rq)) && > + !unlikely(local_softirq_pending())) { > + /* forced idle, pick no task */ > + trace_sched_cfs_idle_inject(cpu_of(rq), 1); > + update_curr(cfs_rq); > + return NULL; > + } > +#endif > again: > #ifdef CONFIG_FAIR_GROUP_SCHED > if (!cfs_rq->nr_running) So this is horrible... This is a fast path, and you just put at least one cachemiss in it, a branch (without hint) and some goofy code (wth are we checking softirqs?). How about you frob things such that cfs_rq->nr_running == 0 and we'll hit the idle: path, at that point you can test if we're forced idle and skip the load-balancing attempt. There's probably a fair number of icky cases to deal with if you frob cfs_rq->nr_running, like the enqueue path which will add to it. We'll have to come up with something to not slow that down either. The thing is, both schedule and enqueue are very hot and this is code that will 'never' run. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/