From patchwork Tue Aug 7 15:56:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 143592 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4668657ljj; Tue, 7 Aug 2018 08:56:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcz662c0nJ0EGh6ZkFPDbNYTfhdKll+GZOpog7llHsGiyF0292vz1soL4+lbbCVTJjDHBpr X-Received: by 2002:a65:41c6:: with SMTP id b6-v6mr19119048pgq.174.1533657401494; Tue, 07 Aug 2018 08:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533657401; cv=none; d=google.com; s=arc-20160816; b=MI5/tOVxK3TkC4cAx/0aKJfLsHr0DY+A5JW8gNgEqNj3bXYbZUpRYHm7IgR3XYgj2y keoIYv5ITG1fO3fRi64e3Uc21phEM+X7zvhhIHVcAYKwiNNm1bFh23iMDW+NcQwLhPgV dE+h7GfP5AUiB9sGkGyw4ATCup00RL/V5jGjwgu7Vz4D477CSQ7W1b6KOEEEggKmy6Bl om8N0J37G9nBlWwL/p2FBFClPbbpyMC0ruXX8Yr4hQgxCE8GEpMwu25YJAjkewJ6zT+b 24tOc/PGtDQO40fTqW6U9zpPY2kSol05RdXT9H00KI+tPlUU14i2j6QZYG6JKhbOm+4X wElw== 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:arc-authentication-results; bh=zsbT0P20/sYtkb53CZMMxTX0UzHPPoWw6TQr3C9fHXs=; b=kZHKEM2nDXMNL3Vr1UZLSG3oIxt41gafVOoqw7Vb4FFZefyBJqNVoCmYDl2CjKqavt V7LZWQWqkxeoXTCc3+sQWC/9kFbzu6L3jiG3RC7YvD67OKVg91SatG/aRXMhe2eeFyix 6Fx9MVPWoQt1R9XtxTadKePMbPu+5jz46UFEaGiVGDSM+2YukWJeiSAlP9L9BOHJdebH eCABCvTpBke8PIaFa6Nw+yc9WWeOcSwVb1uUZavFbvAF5y5M4dPCmt511ZvWDl+qdFzm +WSIs4ClIxApqngMuxVbOqZNLd+MFCCCjvWPkcNf4ZmD+uGhRi6RB4dSfnHDHolkB1UE AEgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CZGyoVQE; 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 n3-v6si1685020pga.298.2018.08.07.08.56.41; Tue, 07 Aug 2018 08:56:41 -0700 (PDT) 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=CZGyoVQE; 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 S2390081AbeHGSLf (ORCPT + 31 others); Tue, 7 Aug 2018 14:11:35 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33083 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388481AbeHGSLe (ORCPT ); Tue, 7 Aug 2018 14:11:34 -0400 Received: by mail-wr1-f66.google.com with SMTP id g6-v6so16284482wrp.0 for ; Tue, 07 Aug 2018 08:56:37 -0700 (PDT) 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=zsbT0P20/sYtkb53CZMMxTX0UzHPPoWw6TQr3C9fHXs=; b=CZGyoVQEbRJTOPIWdQDZjNw6wGPqEVRUM/eKPkzdL8HEZZG9q4PLdESaURmaXDmfEI edsUe5Jk90EF8XmG8g0iV0AFe+F0RZA6vguo5bqt/w6Mi7pvZQKSWds1JuK2A1AUrTc3 InhsmpJcKSJsfboerQhNENN9WE2e3mvPoAs/Q= 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=zsbT0P20/sYtkb53CZMMxTX0UzHPPoWw6TQr3C9fHXs=; b=OTL4UE7ywFpzZCWzZOrz87tTdAzgS6IpwiUZNk9RnU6UZQTylpENjp2OqqXAP2eyPu pbhcZK4cZ4+IlyD9VqBCIq2KMnVsJ7yC/GNHT1Omvb0Mp89YhBtkZVc1kcF4omZaovLu twDn/6/MCzsk6efBOWfBtDRlMNb9hQ3IsvhzNBkrOSqJKR0kmCrskSXF1mqohmcGSivJ RtlnSleQDoxRpbZlnovEu71d1/GWcVut58aZvajv2oabIC6AzMrE3l1oIDRSC6QxpMqd N3akdTxB8OrtjuByCZxFAxq/ZtyzFe3V+Fl6/QsIm1YRkfKshfGOIQP5Ek2im04KdA5a HZCg== X-Gm-Message-State: AOUpUlHOoaep0LUiKLFFOc4FObYlK5bdmqg719MriTVHglslDbpuap/i rdWETFeRJcQFPlLBUVJjWU17S41/nFU= X-Received: by 2002:adf:a197:: with SMTP id u23-v6mr13916157wru.50.1533657396773; Tue, 07 Aug 2018 08:56:36 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:f:6020:41ad:95bb:4cb8:621f]) by smtp.gmail.com with ESMTPSA id y203-v6sm2903644wmd.1.2018.08.07.08.56.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Aug 2018 08:56:36 -0700 (PDT) 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: Tue, 7 Aug 2018 17:56:27 +0200 Message-Id: <1533657387-29039-4-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533657387-29039-1-git-send-email-vincent.guittot@linaro.org> References: <1533657387-29039-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 all_pinned detection mecanism. Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 5f1b6c6..ceb6bed 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8360,22 +8360,32 @@ 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(enum cpu_idle_type idle, unsigned int flags, int dst, int src) { - struct sched_domain *sd = env->sd; - - if (env->idle != CPU_NOT_IDLE) { + if (idle != CPU_NOT_IDLE) { /* * 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 ((flags & SD_ASYM_PACKING) && + sched_asym_prefer(dst, src)) + return true; } + return false; +} + +static int need_active_balance(struct lb_env *env) +{ + struct sched_domain *sd = env->sd; + + + if (asym_active_balance(env->idle, sd->flags, env->dst_cpu, env->src_cpu)) + return 1; + /* * The dst_cpu is idle and the src_cpu CPU has only 1 CFS task. * It's worth migrating the task if the src_cpu's capacity is reduced @@ -8650,7 +8660,8 @@ 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) || + asym_active_balance(env.idle, sd->flags, env.dst_cpu, env.src_cpu)) { /* We were unbalanced, so reset the balancing interval */ sd->balance_interval = sd->min_interval; } else {