From patchwork Thu Jan 17 17:44:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 155859 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2247570jaa; Thu, 17 Jan 2019 09:44:30 -0800 (PST) X-Google-Smtp-Source: ALg8bN6UISYR62ZYmSzm4R+Sq3zdF9kIcI3bZ/kwKcIUQrrnQUGZTdNSTorUpd1Rt6S73ezLqhRt X-Received: by 2002:a63:2ac9:: with SMTP id q192mr14348904pgq.58.1547747070177; Thu, 17 Jan 2019 09:44:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547747070; cv=none; d=google.com; s=arc-20160816; b=u7kWs1ZiO8f3l7IgHjTro1WSz/CZxAuN7oVyz0r4/6G8kj8tRw/jFxZQaHd1M0EuKM JlKiuzz0Xe5N3Kpp9L9Ny1Rb/2FU0nYTxtQvhqKc2Fbf64tngFzrPA59Y64JaV0XDTZT u3onDnKh6R36oMHy8v6mLWTxyilp3kyZOw5hcZvdmHrh3mhhInmtys69f4Ski0lnxATq 8fimrE2utEvb0FhzbLAgFnMEOHDkDVeWLz3PFPNMc2eQK6VXhwN0JC/5DfpeNmqT9miN OqiReK4MNny7lUgqh6SDbUfauNnRSAt0I8+XIWsnWCpts+bXVPEqp9/FGuISEm0mA31W zJqw== 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=h4pmLxlqAAwEK/Le9rcYUHoEVmGCswsbfr3X31WPqMU=; b=B7IM3QejaNuNQvrjNm/7Wjuqqrd50IF4wXl57ffB7GZ+fe9tApDCNBfH9cK26Q78Qg n/1/XKy23tkAfvrX1dandjPs9d7QdM+AHLXp5D/UDf9V8b9I2aonx7SNx9dUWY3tjONN yihtq9XZyV7mC8SEcIuppa8qdsdr2ogAIWHWOps+pZ57KEeGxUnR4ZxB+VJU1AUEcEJR 8FRtksdeC24rL1nLmPF33DwSUyK/mEi1Sb9MEzGYoaq4ARFjdw2ZFPj3eaT0owiCidFy vD2Et60hPWjZ55trzkp80UUqJZ3zOzjYQCxKa4L3Fs1YY4weNRPjqeC4qu0Xp2+K1Elz 1klg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KN+PBl2O; 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 c81si2261370pfc.82.2019.01.17.09.44.29; Thu, 17 Jan 2019 09:44:30 -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=KN+PBl2O; 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 S1729111AbfAQRoY (ORCPT + 21 others); Thu, 17 Jan 2019 12:44:24 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:35634 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728907AbfAQRoU (ORCPT ); Thu, 17 Jan 2019 12:44:20 -0500 Received: by mail-wr1-f65.google.com with SMTP id 96so12005383wrb.2 for ; Thu, 17 Jan 2019 09:44:19 -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=h4pmLxlqAAwEK/Le9rcYUHoEVmGCswsbfr3X31WPqMU=; b=KN+PBl2OyDHJD2XvvJ6txUy0nqqE+nyLLH211c1wQ2UupVfDfTv91YjDdfkED6uuBQ LLWeeM7oBRWYr71cZkPc0kBgTe3Gl5xFSCm4APkqNr6nbnbGRBS83gStFfJ+LVOh/JZA 88kubaeSN/v+tI53XOXGj3jxOs8oL8Cer1NNw= 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=h4pmLxlqAAwEK/Le9rcYUHoEVmGCswsbfr3X31WPqMU=; b=uhImNnlceRhmXNNSeNkDfTsvRqFTHIULPNWefw/yFLL9IwgO7avvKMdmYIX1SaPE8h 6WRNmYCK5jWfQNR86mRs37U6oZhMk5lrT8OSCb/HovFxsNw8jiMBtUTyaRQBZNW0zCk8 Y4KEzNO6x8Az8QKxkWQQ7ntd0lhlurnLZrIZ8VA2phl1o4mvsBSSEeaolAhN1+GigCiy 8uUZgKHY9RDpC3u+1zzIfrJ9x8s3lBG/cxSYOZNbCEHoObaDH9fefz9A4tmUBtNXrzoG cOELP/L0zu+KQCvdqz9rW9PaElzscFy5wMKaTGKrEEb27/2fQ16mnhKoUk/1gyXlSBQ7 JP6w== X-Gm-Message-State: AJcUukdgC5LxDxbqLbZwcj+xmgCR33f+fIVIjPVqn8IGdCaZVyVMAIww P/C1mZNhmHGAqARC48XKeLbDuQ== X-Received: by 2002:adf:d146:: with SMTP id b6mr13055449wri.156.1547747058779; Thu, 17 Jan 2019 09:44:18 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:8435:96d6:e03:9e78]) by smtp.gmail.com with ESMTPSA id i186sm47583622wmd.19.2019.01.17.09.44.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Jan 2019 09:44:17 -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 v4 3/3] sched/fair: fix unnecessary increase of balance interval Date: Thu, 17 Jan 2019 18:44:09 +0100 Message-Id: <1547747049-6320-4-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547747049-6320-1-git-send-email-vincent.guittot@linaro.org> References: <1547747049-6320-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 bd3b0ac..0e17991 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 {