Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755353AbbG0Csv (ORCPT ); Sun, 26 Jul 2015 22:48:51 -0400 Received: from mga02.intel.com ([134.134.136.20]:18568 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755058AbbG0Csu (ORCPT ); Sun, 26 Jul 2015 22:48:50 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,550,1432623600"; d="scan'208";a="770194951" Date: Mon, 27 Jul 2015 02:57:49 +0800 From: Yuyang Du To: Peter Zijlstra Cc: Rabin Vincent , Mike Galbraith , "mingo@redhat.com" , "linux-kernel@vger.kernel.org" , Paul Turner , Ben Segall , Morten Rasmussen Subject: Re: [PATCH?] Livelock in pick_next_task_fair() / idle_balance() Message-ID: <20150726185749.GC28512@intel.com> References: <20150630143057.GA31689@axis.com> <1435728995.9397.7.camel@gmail.com> <20150701145551.GA15690@axis.com> <20150701204404.GH25159@twins.programming.kicks-ass.net> <20150701232511.GA5197@intel.com> <20150703163928.GR3644@twins.programming.kicks-ass.net> <20150705221151.GF5197@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150705221151.GF5197@intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2323 Lines: 69 Hi Peter, What about this patch? Adding: Tested-by: Stefan Ekenberg Thanks, Yuyang On Mon, Jul 06, 2015 at 06:11:51AM +0800, Yuyang Du wrote: > On Fri, Jul 03, 2015 at 06:39:28PM +0200, Peter Zijlstra wrote: > > On Thu, Jul 02, 2015 at 07:25:11AM +0800, Yuyang Du wrote: > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > > index 40a7fcb..f7cc1ef 100644 > > > --- a/kernel/sched/fair.c > > > +++ b/kernel/sched/fair.c > > > @@ -5898,6 +5898,10 @@ static int detach_tasks(struct lb_env *env) > > > return 0; > > > > > > while (!list_empty(tasks)) { > > > + > > > + if (env->idle == CPU_NEWLY_IDLE && env->src_rq->nr_running <= 1) > > > > Should we make that ->idle != CPU_NOT_IDLE ? > > I think including CPU_IDLE is good. > > -- > Subject: [PATCH] sched: Avoid pulling all tasks in idle balancing > > In idle balancing where a CPU going idle pulls tasks from another CPU, > a livelock may happen if the CPU pulls all tasks from another, makes > it idle, and this iterates. So just avoid this. > > Reported-by: Rabin Vincent > Signed-off-by: Yuyang Du > --- > kernel/sched/fair.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 40a7fcb..769d591 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -5898,6 +5898,13 @@ static int detach_tasks(struct lb_env *env) > return 0; > > while (!list_empty(tasks)) { > + /* > + * We don't want to steal all, otherwise we may be treated likewise, > + * which could at worst lead to a livelock crash. > + */ > + if (env->idle != CPU_NOT_IDLE && env->src_rq->nr_running <= 1) > + break; > + > p = list_first_entry(tasks, struct task_struct, se.group_node); > > env->loop++; > -- > 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/ -- 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/