From patchwork Fri Sep 7 07:51:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 146188 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp855589ljw; Fri, 7 Sep 2018 00:51:16 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZYmaIJ8+0ao20IfDgOjvQq8WtC8/T0iWZgU1D/LIoy145k2Jdvjecfc4u+7Td2kOzedQsi X-Received: by 2002:a17:902:ba86:: with SMTP id k6-v6mr6759327pls.84.1536306676185; Fri, 07 Sep 2018 00:51:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536306676; cv=none; d=google.com; s=arc-20160816; b=ZiKqyuPb6KmP7AjZPtQaQcP5nzD5ab26DQrOtjBRVVV4q48lR1j99rmMBRG1UiPSFs hlvYC8FKKaMNR6b8ZnwvBxQo6kKe+riLQjfJIvjvYyyBC/Dr/PQ8ntckCvIAhEiBFoYl WgU3+2h7s9qu9p8fjAbUReo+XqDxW5kOIF3RK37096JO+xXPKvDm0J/nT7NVXcX7QY0b TcEnsvq3bJ3PN2zAsbbUE4w6apCXH3O/aBG3BvvVSghquackZm5B3ffYqViJAVpj8hV7 2wphrff+9ucn/6Jr0Dy4KfTvA/kM36WbcuQHXM2IoahWSwm0TrwVAaxIiKR3vYeauyRd 00yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=U7rlz81RYPigwV+o2zgu9XiXkFpocxCgtLMOlpQ/v2A=; b=bSVLwQLXemUp5pDDYrCqVPMkM9iIFYcfWcx5S+SZCYqQfJMjUeCKZ6IAVQYJ4YjwOA b1ZaJUkW7fON6Q25NA2/VPfQ9f6eQbSY7AVA5KcjBGyUBHdZHcLdWxSc3RwM/I/Wlwi3 MWqsOUAQIMejjC0R2Df3p/9pv8izV76xx6CGyaBt2EtN3OboFD5fLPuPrNaPtInDuzkp rD4PukMEjXgkfBEKYarwzSq3NnGWu8G3+38kR5dfPE+HyqsD6jgFnX7KiSxEpGNPajVg bzwX+F+MddVDIedzEokd63Um9dTtDH/CP6VCW5XolAiwpqjYTFLxu0EqJHWbgpp/acNE j5TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hzZAyCYy; 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 t64-v6si7948519pgc.516.2018.09.07.00.51.15; Fri, 07 Sep 2018 00:51:16 -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=hzZAyCYy; 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 S1727880AbeIGMaz (ORCPT + 32 others); Fri, 7 Sep 2018 08:30:55 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:38751 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726334AbeIGMay (ORCPT ); Fri, 7 Sep 2018 08:30:54 -0400 Received: by mail-wm0-f68.google.com with SMTP id t25-v6so13605349wmi.3 for ; Fri, 07 Sep 2018 00:51:12 -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; bh=U7rlz81RYPigwV+o2zgu9XiXkFpocxCgtLMOlpQ/v2A=; b=hzZAyCYyZlXuT5G4TeKfd9gbGkmQgGuA95QhQT9hBLG/gHhJaPtf2sCpZQ8zZWkndt ESPdrHdkyyDZMDUv4DN6k74xwEETJ72C7/na2EtgOMpfnqYwf7ZddsH/y5bcuw2Gigch n3s9h5z+nLtDp9Nbop0NKF9/xLgg+XU+SXVUE= 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; bh=U7rlz81RYPigwV+o2zgu9XiXkFpocxCgtLMOlpQ/v2A=; b=umVFhsm9bcYsVnME6FQMCZfSOZRJbdNkfQsvELGOJQwAr/hPFwXSfJIVjwbX/WWhwH M3BZnNpDFPha9kxuSLDkW1m4wLRcWkNM857aEzcQh1/OiQHzYw+DIdOA1PnQvteSg8lv LAUEwxvyaCTGHLtVUXGYrAhM/TQuuLcPaxrX063rsz3OsIBk/S/ic67T8wt2YAlLZl2x 7cn3pLfEKmemUFvqIKLeTG5TfHyWxZZ48GFCXfbZ6/lIgtEfryEnU6Bs8P+yGFMYvo1l HnST+9kkKR/q0GdAKWtBCrUdNl6N64CO5K3V9IqM5djXSIXrgXIsbpcFwANUXdeqMNEH fACw== X-Gm-Message-State: APzg51Bru/w7aYMxNH13jBMwNMhS+0xvdGxEObLViivwnKQgCC+PLEzL KLxAAnhFullXLEu9x1IOG3POUg== X-Received: by 2002:a1c:e0d7:: with SMTP id x206-v6mr4012336wmg.74.1536306671203; Fri, 07 Sep 2018 00:51:11 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:f:6020:5981:ec43:6d36:934e]) by smtp.gmail.com with ESMTPSA id h8-v6sm10814247wre.15.2018.09.07.00.51.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Sep 2018 00:51:10 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org Cc: dietmar.eggemann@arm.com, jhugo@codeaurora.org, Vincent Guittot Subject: [PATCH] sched/fair: fix load_balance redo for null imbalance Date: Fri, 7 Sep 2018 09:51:04 +0200 Message-Id: <1536306664-29827-1-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It can happen that load_balance finds a busiest group and then a busiest rq but the calculated imbalance is in fact null. In such situation, detach_tasks returns immediately and lets the flag LBF_ALL_PINNED set. The busiest CPU is then wrongly assumed to have pinned tasks and removed from the load balance mask. then, we redo a load balance without the busiest CPU. This creates wrong load balance situation and generates wrong task migration. If the calculated imbalance is null, it's useless to try to find a busiest rq as no task will be migrated and we can return immediately. This situation can happen with heterogeneous system or smp system when RT tasks are decreasing the capacity of some CPUs. 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 309c93f..224bfae 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8464,7 +8464,7 @@ static int load_balance(int this_cpu, struct rq *this_rq, } group = find_busiest_group(&env); - if (!group) { + if (!group || !env.imbalance) { schedstat_inc(sd->lb_nobusyg[idle]); goto out_balanced; }