From patchwork Thu Dec 20 07:55:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 154322 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5858555ljp; Wed, 19 Dec 2018 23:56:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/XTQWTr/rbiOdEptb+1OY8uwByCtP5EJ+ZnvoNB5ub+bs38IT67VnJ4KthbII5oyP0j/OCf X-Received: by 2002:a63:ed42:: with SMTP id m2mr22232305pgk.147.1545292569106; Wed, 19 Dec 2018 23:56:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545292569; cv=none; d=google.com; s=arc-20160816; b=SUWPqqDpeoQ762OgFgC2uq0dRzKeBNqbcFVbXDshl72o2J9FQjhhL1d5fI0x9BaVKD xfCji/b6CExsL7FW4x4y5VemQsNpMseiFG21HNcQPVBDmyc1xI0j/Q/6IUxi0SDfh7zr q1q0g90PsCr9rySrpTHbXvaageCcn2JUgUZ1UIKxkXYxD4WKsn+igBzeCNr+TaK8Swz/ ZkHAic7v57zvNRlen23GBOn5jXt7+/AJUSWdgcg05hXobar6cYzwkRMFzOWdvGsP7OAc 3vb391YQ7lHh3vacmE9BaLs/PA9+/1rEmVZTZINWkLIXGWkpB8EN5Nka6NRH8MQ6Yq8L +ZYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=JMZgSdyWPqBACBBm3S9C2jr7vI8zerSZBF4GiDfVwEY=; b=0E3KpR2N1fsD6mAo4cyk6Sv6UreMlyWqjnEXwmqEO1DSqNqOLEqfz0D7r6hjybF8aE dhw5RwGcRJbg6dw1FzwRRj3gLmkvxCVzcXCSxzITTmLuPPa9Qtb//fKMtmNIOeaRAFRx FAGAEr+8IOf84XLR4G7Teah61YTEqkqIhsl405D97ovCfyD8A3NwmK/hhar8IIOlOOaL d6IwbvyWv+ga6urfDQQ7gxFXAHVzGDNoq8bkwmELmVU5x98jKjphQExiq/o8T3SPbv7e MRl+fqPaGacCPaJkLq+cJTojttqN9L4w/3s+Qs6o+tM56t1kBvFvaDyeAkfdmlE6yP27 +qQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="TPDyeJl/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si18721254pgb.105.2018.12.19.23.56.08; Wed, 19 Dec 2018 23:56:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="TPDyeJl/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730697AbeLTH4A (ORCPT + 31 others); Thu, 20 Dec 2018 02:56:00 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46724 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730721AbeLTHz4 (ORCPT ); Thu, 20 Dec 2018 02:55:56 -0500 Received: by mail-wr1-f68.google.com with SMTP id l9so653866wrt.13 for ; Wed, 19 Dec 2018 23:55:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JMZgSdyWPqBACBBm3S9C2jr7vI8zerSZBF4GiDfVwEY=; b=TPDyeJl/2A1jvjLcQhEpVHU3bbt+NlZzVlI97aWnTm3th0ZYuK3XvPG8R6MtIvT9na rcw87YXsh5yPmS8w6jeETWZjg+rUswDz3NDPWXlRWbHyfsN+pyqQXoyc6JQnxfYOTwq/ hVUwpmDBvmmlL5ITM3h6LAdViB+9TogDXFmlE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JMZgSdyWPqBACBBm3S9C2jr7vI8zerSZBF4GiDfVwEY=; b=XkAeAwgZzRIaBxN/UV1bCIMEwU/MLIIXFXg+2g3aqEVS6HrXNkhu9AjnfInz+4Ajav M68z4kQ6DDed1Wg4dHodwDaJAC/rgfYBccZMvkoXoQI7WTwn87eYpsMmF0rmPZV3S4M1 QwXS9P0EcsSwfriRcoBa4PcvBSuSZKlgDKEzu5PaKEzPE2VtVcl4hqh+AKLpslMCUGHC dbWc93qgDLhYLJk6neskPQVpR8i+FAksJTbOKrsYt6nOi4zLhVV8NaPJq6Q2IqyD57a9 AAo+6eAYw4Et54yiaEYajyb8pwfSvhSdP01UtUumGy/DcW9GouuKe05gXNMZi7FTHdR1 t/AA== X-Gm-Message-State: AA+aEWYHGww8QaNP0L0f/epPG39W4tjJsCdpisQbUr7e6UdVr61v6UPz xgUI+Co7ZdhFXDB1XsyNgtREGw== X-Received: by 2002:a05:6000:10d1:: with SMTP id b17mr21392340wrx.306.1545292554356; Wed, 19 Dec 2018 23:55:54 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:f9b3:37c1:b11a:64ce]) by smtp.gmail.com with ESMTPSA id c10sm8773299wrw.49.2018.12.19.23.55.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Dec 2018 23:55:53 -0800 (PST) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org Cc: valentin.schneider@arm.com, Morten.Rasmussen@arm.com, Vincent Guittot Subject: [PATCH 3/3] sched/fair: fix unnecessary increase of balance interval Date: Thu, 20 Dec 2018 08:55:47 +0100 Message-Id: <1545292547-18770-4-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545292547-18770-1-git-send-email-vincent.guittot@linaro.org> References: <1545292547-18770-1-git-send-email-vincent.guittot@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case of active balance, we increase the balance interval to cover pinned tasks cases not covered by all_pinned logic. Neverthless, the active migration triggered by asym packing should be treated as the normal unbalanced case and reset the interval to default value otherwise active migration for asym_packing can be easily delayed for hundreds of ms because of this pinned task detection mecanism. The same happen to other conditions tested in need_active_balance() like mistfit task and when the capacity of src_cpu is reduced compared to dst_cpu (see comments in need_active_balance() for details). Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 487c73e..9b1e701 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8849,21 +8849,25 @@ static struct rq *find_busiest_queue(struct lb_env *env, */ #define MAX_PINNED_INTERVAL 512 -static int need_active_balance(struct lb_env *env) +static inline bool +asym_active_balance(struct lb_env *env) { - struct sched_domain *sd = env->sd; + /* + * ASYM_PACKING needs to force migrate tasks from busy but + * lower priority CPUs in order to pack all tasks in the + * highest priority CPUs. + */ + return env->idle != CPU_NOT_IDLE && (env->sd->flags & SD_ASYM_PACKING) && + sched_asym_prefer(env->dst_cpu, env->src_cpu); +} - if (env->idle != CPU_NOT_IDLE) { +static inline bool +voluntary_active_balance(struct lb_env *env) +{ + struct sched_domain *sd = env->sd; - /* - * ASYM_PACKING needs to force migrate tasks from busy but - * lower priority CPUs in order to pack all tasks in the - * highest priority CPUs. - */ - if ((sd->flags & SD_ASYM_PACKING) && - sched_asym_prefer(env->dst_cpu, env->src_cpu)) - return 1; - } + if (asym_active_balance(env)) + return 1; /* * The dst_cpu is idle and the src_cpu CPU has only 1 CFS task. @@ -8881,6 +8885,16 @@ static int need_active_balance(struct lb_env *env) if (env->src_grp_type == group_misfit_task) return 1; + return 0; +} + +static int need_active_balance(struct lb_env *env) +{ + struct sched_domain *sd = env->sd; + + if (voluntary_active_balance(env)) + return 1; + return unlikely(sd->nr_balance_failed > sd->cache_nice_tries+2); } @@ -9142,7 +9156,7 @@ static int load_balance(int this_cpu, struct rq *this_rq, } else sd->nr_balance_failed = 0; - if (likely(!active_balance)) { + if (likely(!active_balance) || voluntary_active_balance(&env)) { /* We were unbalanced, so reset the balancing interval */ sd->balance_interval = sd->min_interval; } else {