From patchwork Thu Dec 20 07:55:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 154324 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5858632ljp; Wed, 19 Dec 2018 23:56:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/X/ieoI28B+DtH8sTAp0FK0yhWDQo+VKMJCXT5+6nHdlYjN/SbayHAEqgWrv0vz2DL7AUPM X-Received: by 2002:a63:4187:: with SMTP id o129mr20537812pga.370.1545292575406; Wed, 19 Dec 2018 23:56:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545292575; cv=none; d=google.com; s=arc-20160816; b=Suu4K2xFFSaSUBQb2JGn8pokL2ftstLu6IyMtauM0Uc0pUN4JNRqYPSSnbmzX92ZZG PfdBnP8L9WK4+Ld4zbzCntzZkYEVj//vDQBuQWlv9CaSnHy9YXXacGHz2BSGM4FRnFiI hAIhueMcHXjPulJ2hqSUa7uzn0eDWXh46VRS/di1ZLfkOWyzsi4a2KDB9vUAAhAlqG7P eTCGCq34kDgUgY3+Js3yRnPel+Eis1H5b3qZtlLHk2ivpawbCrX/6c97S+nPNaZZ0BqR tvphT2FLMSYe8D93A3xwzC6gDG3LkM/6u86v3L8SRsyffoZ1qufVHTrJQNRnvJZWk0ze bqeQ== 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=GFGQxWT3ZkEUOWnk0RCrGbiQU0QOjbOOWUD8Wmo9BcQ=; b=dpnqABw+b0FWR2ByzD3KL6EYtRTRILPukJc9v7aaKbPArriFOJwnAUmTrRaQBzsuSg aPUCr/eZP3itxW/kCBDQj3F8+lcQeGP1Nqief0yBCcfrE4oS/+LdSNsLdSrsmWY792ml K8MHOoYcNLQZVC6BtoIUmtu5bE/DSmmZh6RAzvpw08Lfw8w53l+WQ8meeDWD1L3BcSf2 BT4dsSgYfmuXvPE/mk67Pp4cEAGEuN2iklHBQojRIbjfg8O3+QvVbu1RvOXq6ORnEaHU pqs0xMNk1gddI+ZhdFtB+J4pgDNv8N7wYr3yDg3oynxefIlu8r8RIGtk4rqqh6fuuSwe ZRwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M6QXsA9G; 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 f23si1076903pgv.431.2018.12.19.23.56.15; Wed, 19 Dec 2018 23:56:15 -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=M6QXsA9G; 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 S1730729AbeLTHz5 (ORCPT + 31 others); Thu, 20 Dec 2018 02:55:57 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40356 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730649AbeLTHzx (ORCPT ); Thu, 20 Dec 2018 02:55:53 -0500 Received: by mail-wr1-f68.google.com with SMTP id p4so672204wrt.7 for ; Wed, 19 Dec 2018 23:55:52 -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=GFGQxWT3ZkEUOWnk0RCrGbiQU0QOjbOOWUD8Wmo9BcQ=; b=M6QXsA9GWl6z9aR19FVXi3McuENNUYA2mQI0RT0Wu8F7sLfqbugsdusqdeKEQubqI1 hmoEgkK7yi5g6YMv7TuV3IelnjeUTunVmnIodiPykfacP+69Ii9pk5hrMa7whyGDXMga DI3qV+LXm5IY/DnowtZtFkKSlSCgV0ZvAE9mA= 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=GFGQxWT3ZkEUOWnk0RCrGbiQU0QOjbOOWUD8Wmo9BcQ=; b=QGyt98rOgrvXD/RZPUV0b7bF8himF2Tr2EPUjNNdG0/ziXLk0849xhFL89u+XzHbs3 Tryt2BuWDx63cjTstf1igdriwuCK4BUV4nBBknw0cejOX++u3l39dTl0JKQ29Tad8OMQ 5zwffb2xktjpaDj7IXSLtvfF5mkbTCQHvKlZwhSd2Xmj6fc/63xcV5qJTCphOcuuzI5l bcLEyML5nRB+X3reyRD5FrgwjW4wjER0xcoSExypHUbuJkApkmrlShuDtMUrkMXQTH+Z o6yRyjwuqk/oUgtoumZqVTkIYXIbXHmKHx0dqH5TI2vSwMmf8K+EkzMbqCNQMV06tmi4 M0bQ== X-Gm-Message-State: AA+aEWZYTUqaWcrRhB1/GKzU6gcDJcLEiCiC6EZnTtgt8k7n8yESjKuq ArVdk0IWIY+vhSYwxnxNuFlk4g== X-Received: by 2002:adf:f390:: with SMTP id m16mr20794134wro.71.1545292551921; Wed, 19 Dec 2018 23:55:51 -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.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Dec 2018 23:55:51 -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 v3 1/3] sched/fair: fix rounding issue for asym packing Date: Thu, 20 Dec 2018 08:55:45 +0100 Message-Id: <1545292547-18770-2-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 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 sgs->group_load to remove the rounding. Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.7.4 Reviewed-by: Valentin Schneider diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ca46964..9b31247 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.avg_load; return 1; } From patchwork Thu Dec 20 07:55:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 154323 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5858612ljp; Wed, 19 Dec 2018 23:56:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ver7Z6i5gnXPDSDjoMucrGumqfeaQGTc+kFHE+/ngtCH0NW8W8eEAxT/jr1R5qOrsIFUgs X-Received: by 2002:a63:2bc4:: with SMTP id r187mr21890161pgr.306.1545292572836; Wed, 19 Dec 2018 23:56:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545292572; cv=none; d=google.com; s=arc-20160816; b=okjmX9B5GqaU6kF2rTpmdKM9EgZgN3+1EZ1tfeVaSqTUGQApjhxDFcnAtRBHxd5h+z 3bMfrMxoQESXpdbAX0IOwYQZORZUM1UvhoGEv2pldJzXJQSHWUIPrhXWaH20wf2X/8m0 ovQNqI7yi/E8HETWVaEJdBHqwslJU7XLF04Z/Q1UxzJDR2mpyN3us6QEiKdK/G/QYfTf SzworsoEGE+akNpjW99aynoM9StnLxXLXrdGA87TKgIo1PGhKYLs9ZHrgKhQw9ysQGle nEPG+ZcmUQpiyfW1F2jEjAxwsoxJ+WvvGanJmAO7okQkIKFzU7L2QJspUxX/wZHaN8DQ XA4Q== 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=SlBtkRSyk5NHoysVqYAQ3q4Z+DHM3H/qzoVSFkfbj34=; b=s2uNZDz97muG7ME2yQim2gJSvDabj3LvViTyIBlrSLcHquvd9ChZTAWdS8JjWJjAMN hS6X6V2z/z3C33UiYmPPOweHNcsg7bQV5iwSPUsI+WBD9BO0/qIrl7SJiOm46JVxcqQI znJlPpR/2G53HrG4czKIoH+rNULhWvUkYkIoX2dpMdWUbCaqNpgHBnMgyuHfusNsxLmR S6qpIgWOBlMWqRYgERoz/Irhwh1QjEdhEYobters/FrPRXuRXi0u+GSqix0qCWhmBgrc qmj4tU7+M5zhyNwWWHe6QmM6RVylqjrBmFlFH4tBHbZe4h0yXDFe7LIjEu2wdXxitVxD QGDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Y/N7UaR0"; 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 f23si1076903pgv.431.2018.12.19.23.56.12; Wed, 19 Dec 2018 23:56:12 -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="Y/N7UaR0"; 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 S1730757AbeLTHz6 (ORCPT + 31 others); Thu, 20 Dec 2018 02:55:58 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:54646 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727232AbeLTHzz (ORCPT ); Thu, 20 Dec 2018 02:55:55 -0500 Received: by mail-wm1-f66.google.com with SMTP id a62so924272wmh.4 for ; Wed, 19 Dec 2018 23:55:54 -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=SlBtkRSyk5NHoysVqYAQ3q4Z+DHM3H/qzoVSFkfbj34=; b=Y/N7UaR01MZ9zjpYKlA8dpIHsDzdewGmTT3wypxGl4ygv2VkfO1P4nR2S8uOeueKSZ zZUniYt9zSX+rfSOi/TbO4RJS44jzYP0ZPQ8cQkYDcUlz9YJTmYy6PjiwLYqbOgVqXMG mmVlZxOKPoealoTCkYLFb9cuLZlLuikDdu05k= 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=SlBtkRSyk5NHoysVqYAQ3q4Z+DHM3H/qzoVSFkfbj34=; b=KA0tiTSsFXcWnBAM4/Ee0iSwSYdq3TaFHEweWfyae0GPVG4QRyJLpN0FQaQtLdcmGi O02OTW01NiLeHOne35jhnqatEJdaVuRQ3rQAaN1rt/xeS5iDdaSq0P4pn0IKbsrCpm57 2JrU/ZMivm+c9R15/4eXXvlbTzseUv1NZZaDjsIuAGZA2Bbn+tLPWbS+e4FCszyh7mNY /18XroZd3TpjrarcNJ1vR8VlNErQparKtZi0OOMxPPZ1MTXNHMhgvH7ObdSdds1IejW3 HDhFctyL7r6+ff9aHPfXImoCVb/oBuMKq1JXCwEH8c5mT20GWfbmbZnElbNUSnpE1Mee L/RA== X-Gm-Message-State: AA+aEWZf0mv+kv/kWp46yKM2QupNstvmwtp97hvDfjGEHPXrNKB7JLwV tB0QYMvQKIy2Yjlidr62TMgGcQ== X-Received: by 2002:a1c:9d57:: with SMTP id g84mr9612559wme.16.1545292553240; Wed, 19 Dec 2018 23:55:53 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Dec 2018 23:55:52 -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 2/3] sched/fair: trigger asym_packing during idle load balance Date: Thu, 20 Dec 2018 08:55:46 +0100 Message-Id: <1545292547-18770-3-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 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 Reviewed-by: Valentin Schneider diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 9b31247..487c73e 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 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 {