From patchwork Thu Jan 17 17:44:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 155857 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2247403jaa; Thu, 17 Jan 2019 09:44:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN5IIQ8jKPCpDKCrYirQxB860uHrwSnLQE6ZuprNxzNMFw/Zmz4o4YpzaLgSlIYhJe+bExf2 X-Received: by 2002:a17:902:8346:: with SMTP id z6mr15881224pln.340.1547747061213; Thu, 17 Jan 2019 09:44:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547747061; cv=none; d=google.com; s=arc-20160816; b=CjmaldZ4YtUmqoptkJUHVwFYry6Noag0TvnrKWBOHB2WbO/R0EMKBeYe+YE0mvhzcE zXl0l6ywN1cU8NOydKICS/cloziHEi94WkCqAO9HgX1F1rFK1wqBuhZCzUGoV9bACB3m ZO8QGw9qwu+E6Yty4f46brGEqg2fVPVKupZLGiDlUScWNOI6e5PUtwYppiz2Pe6ohuhd HT1TPr5CD+ViISU0gCrKJuFGB9p/hKLWUxy7gnF4+u5vxThFgek0aLX5w8cVTyIujhfr l5xh5RsypfUsRUYCx3iEi534ca5u5VVs2TLIc/QXVV07MaqALfZa67JxNuDd3rzxCGyI HK7g== 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=1aBp5LxJH6+t5l6K90aaA3r7dWGab6glXC9WTdCKErQ=; b=M6TVDHrQfdzMWOJTCqaaEzV40H/IcT37VI9JO7b9PkKdl6XHcEcZvwSBtBYIza956E 9M55ajkU0t55z+MXwYkdNK5y9BYknaJ5647hsmWb8edN9qeJcyT58wlQq6YW60ApqClI myeLCZDSqcVYo8gEX9R0y0FwDvs2sQS9cS6RGHTYbauzas/hIEDx85JqjDRArnx4tzWL 3Cm8vTtZv08/eWvbMbIDDVsfE6DXZvt2nXPktgHbzbYipUImVvsv/r5hMXMDnTQPzShI BOjR5t8tnLo+l6vfAKmR50Ws6gRD9TfaUrsQKPSywO32I9Q5gJ1ZNL22AE8tgQq0zwW2 rSaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="RG19avk/"; 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 m3si2140924pfh.58.2019.01.17.09.44.20; Thu, 17 Jan 2019 09:44:21 -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="RG19avk/"; 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 S1728971AbfAQRoT (ORCPT + 21 others); Thu, 17 Jan 2019 12:44:19 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:35632 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726900AbfAQRoR (ORCPT ); Thu, 17 Jan 2019 12:44:17 -0500 Received: by mail-wr1-f68.google.com with SMTP id 96so12005247wrb.2 for ; Thu, 17 Jan 2019 09:44:16 -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=1aBp5LxJH6+t5l6K90aaA3r7dWGab6glXC9WTdCKErQ=; b=RG19avk/WOOK4DVDnChRNWLFFkb3g7VMzvivOx9FiYXAkGhigIri2RY0JDIvS4iqPH oBNk0tBjxL0azQ/01eaBFZF+EMaTL8APlcLVdeqMir1kKJwXNr+26CCRmGDzCeG90qGd 0/1EApEPEWLkrqxdcilfYsDG1NFYM824NgJ8E= 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=1aBp5LxJH6+t5l6K90aaA3r7dWGab6glXC9WTdCKErQ=; b=QFkFPnjcYRCKDzQC1MjKvfRVms5AL5Don62mqE9Ds5DrPp9vbpWJdyeT/c2SRyV1R/ +CW+/dr16WroFt8ebEKUBlEMMzzcWBVLdqPP4UY9JIqjgcxAvkwFBLwc6iwGmM8hQwUH k0QZtnItiWbzYtpmxZHvrSUvz4AOMW+fwCIT8u/J8XXRYn2JWb2WAwLfVjmv5yORAM9t vrJVQEQylpsjZ7KOUXME6UlQKauGjm0XBe+GJaVAHmoYQdpAjfmOujYi6x9cHEiKLi/Q cbNHphwSeoT6tkbjw+N3hb3tepVUT8RmyTrIpJx37U4qgS2HlBBFDsCRbZvrUpH98cgd iWKw== X-Gm-Message-State: AJcUukdSpMjI8iN6OwIva9AXgAKAP9elFdzGfb+PFjCYRspmixixTAyz BrfDSZmfWuvIfZiP8E2eRYtmcuguEF/WvQ== X-Received: by 2002:a5d:4ac7:: with SMTP id y7mr12301851wrs.196.1547747056158; Thu, 17 Jan 2019 09:44:16 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Jan 2019 09:44:15 -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 1/3] sched/fair: fix rounding issue for asym packing Date: Thu, 17 Jan 2019 18:44:07 +0100 Message-Id: <1547747049-6320-2-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 When check_asym_packing() is triggered, the imbalance is set to : busiest_stat.avg_load * busiest_stat.group_capacity / SCHED_CAPACITY_SCALE But busiest_stat.avg_load equals : sgs->group_load *SCHED_CAPACITY_SCALE / sgs->group_capacity These divisions can generate a rounding that will make imbalance slightly lower than the weighted load of the cfs_rq. But this is enough to skip the rq in find_busiest_queue and prevents asym migration to happen. Directly set imbalance to busiest's sgs->group_load to remove the rounding. Signed-off-by: Vincent Guittot Reviewed-by: Valentin Schneider --- kernel/sched/fair.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.7.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ca46964..1e4bed4 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8476,9 +8476,7 @@ static int check_asym_packing(struct lb_env *env, struct sd_lb_stats *sds) if (sched_asym_prefer(busiest_cpu, env->dst_cpu)) return 0; - env->imbalance = DIV_ROUND_CLOSEST( - sds->busiest_stat.avg_load * sds->busiest_stat.group_capacity, - SCHED_CAPACITY_SCALE); + env->imbalance = sds->busiest_stat.group_load; return 1; } From patchwork Thu Jan 17 17:44:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 155858 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2247499jaa; Thu, 17 Jan 2019 09:44:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN6y736SScrXXuyesKnStCh3uVuMO03kQdhb+Ocrx+v9q9EZHhqwvUI7gPmzO2Ji68sLq+RB X-Received: by 2002:a63:af52:: with SMTP id s18mr14300561pgo.385.1547747065983; Thu, 17 Jan 2019 09:44:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547747065; cv=none; d=google.com; s=arc-20160816; b=h7rXPEkKl1wNjyRMZRuK5RLU7Jnf+dOhFYyCrTMf0kKJPs0hxuwx4cwI/C78A/PnpV XQXtJyM1mXb64fK+/eEfQkWL3QSe0igZxvBQU7uXP+ePy9fYvzbekn+dLaSvRGTG6qER cZpWE/Tjr4ADp2vQcncshYbX2Qzdvt7+Ag96VxZLObd4zLzinyj2hGT0vYU/4rfIoDzn bqiWeDkMQAjd9lbAwlUUqbhs/aVpnhTR2lFR90lxyTIy7lERRUzo9uKEsF8PnogijVHa /FsC1mblx/67eZ/mtotENmUlX/zftCnVl/oEXawjM5PnP26D5QlBSIlia+549jdzFrv7 Z34A== 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=uaMFbDW5vM+8+YXiAv83MSY7jn86Anovx+UGEgOqUgo=; b=IElOZpxWTsNKMn/k36cU0QW13voh26MMxyfFic9iqoLuXQ3qfAeXIfcFL0VuxfNZgV J/5ghk+n6yvxtq13qFKuR3gLEqLU2XlG1ERvzyhoGzg52sJ2+jDZQHPBF5TlFVRltmD8 WOacvKHX1ICTN7/RjVFxl4zS8p2K76OcSskWK2ZPnj3ZFNTFTnefWmflV1YzaUD1AUZl SmeilrFShJBpp8xrON57eQo3PhmisodQ4BHKtHqsuv30U9Lmx5JIToc7UMn3/qTL54Re gP04l3ZeX9xWetTpt5h/CDXTqmCyiJvRAuLwyDBjihDUROpUyL6eNHOTvevh/tms5h1y 2BWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eG96rQKc; 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.25; Thu, 17 Jan 2019 09:44:25 -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=eG96rQKc; 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 S1729425AbfAQRoZ (ORCPT + 21 others); Thu, 17 Jan 2019 12:44:25 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38393 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727488AbfAQRoT (ORCPT ); Thu, 17 Jan 2019 12:44:19 -0500 Received: by mail-wr1-f66.google.com with SMTP id v13so11995935wrw.5 for ; Thu, 17 Jan 2019 09:44:18 -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=uaMFbDW5vM+8+YXiAv83MSY7jn86Anovx+UGEgOqUgo=; b=eG96rQKcFDARA+T56ZPel3qPYMvZY17GJQHiufMe2UrmJUbvHXxyYWuuA0odZAKgRU a/NuFZ5N7FUeQoqaCioqPiSPOkSS9/ATjS4+C2cZsSOSaY6VUU6dqwxo8EzPhNheMPdW QSPEoNOIceDz4tuuJsoIzmL1B5CGfFAtlHVxk= 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=uaMFbDW5vM+8+YXiAv83MSY7jn86Anovx+UGEgOqUgo=; b=TwRyd50xTBM46gGo60jv3ygvmWDCrcQc2eXjBVPqV5anvgwaY9WxBoQa3WkN9A6SF5 hchCd2d/RzcXCy1p3hKFWAKxFC3PPJKyDtC1Sz5qBMBBRbwTxsQDCTxkzbBcTvAVD730 CWldk9tBZVnt/QpVtb32LPvyvgE1zLXAdRyxhzzqSt5hzThk2Kc4gstpVORZWTEPLY3x BB90i0lgwW3F/LROP3i4dWQ0HSHmVRnKwhByEVNF1MqBrhFboJlHEXIi501/zPLxY6Fk TvjBnnGvc1oTTYW1E4mOHc695AuBQHLph7uL+0fGvo/aBp/8CSvFHG0EyAyh8FRr70ls Rdaw== X-Gm-Message-State: AJcUukcbvtjRe5aeuV5hEDnVh4qsRGVmKTsE2L8FCRgTmnhD+9p45lEq kFfk9Ifk1m8YN8xmvoqgQBZuxqn2w2CP4A== X-Received: by 2002:a5d:6684:: with SMTP id l4mr14022779wru.154.1547747057358; Thu, 17 Jan 2019 09:44:17 -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.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Jan 2019 09:44:16 -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 2/3] sched/fair: trigger asym_packing during idle load balance Date: Thu, 17 Jan 2019 18:44:08 +0100 Message-Id: <1547747049-6320-3-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 newly idle load balance is not always triggered when a cpu becomes idle. This prevent the scheduler to get a chance to migrate task for asym packing. Enable active migration because of asym packing during idle load balance too. Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 1e4bed4..bd3b0ac 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8853,7 +8853,7 @@ static int need_active_balance(struct lb_env *env) { struct sched_domain *sd = env->sd; - if (env->idle == CPU_NEWLY_IDLE) { + if (env->idle != CPU_NOT_IDLE) { /* * ASYM_PACKING needs to force migrate tasks from busy but 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 {