From patchwork Mon Jul 20 15:38:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 237543 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp2126473ilg; Mon, 20 Jul 2020 09:23:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDR4h4sIRWcW/hYWJMZUayg6QTDe2Q+Qgg+dSNNzBRv5yHEPDjnGovQ3jxpyaC/RuR/Nrh X-Received: by 2002:a05:6402:319b:: with SMTP id di27mr22604311edb.133.1595262229519; Mon, 20 Jul 2020 09:23:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595262229; cv=none; d=google.com; s=arc-20160816; b=AwfV4fQsAZOKAOkHZQQ52/j2YC9kALcf415wCPqN/M43SNJ86ovZ519zDo6WMSOv9v t+CgdJIHS0xoPsmJOhPUydElUBynxQyy1PuQlX80CfsooDv4o9wcIidez3liT/tRA5So tLbFHAAMKSFC6+y89eNiA8vE2SpsutOF0jjqlYXFNJBYW7S7Zaq1MZ1fwAVb/8KyogRv hUppoQ9De3u1zWOj/OGuLeb397CYH7nBR9bRskuqXs0Gg+l/BpJ68xPTV8N9q/Fa4z1a l/VaUYResH41reDo94nFBhbr29n1Cl1aB/SPuLSSCh9RN2WjStVtnE1LbCs7WceANFeq v6+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0i+xfNAoqj8wyLYquuVB7yNnXnGSumMG40RWtsOdSSs=; b=AVWKoSasjKnb7R1gL4CrWXuR03YdjVo970tRTpuUDZ2EjkEEKn5rzDqKOoUt455t+V M3pUtDQlqanqseEpfgEYAIlobhfvzsRuuGVf+95YXiVYZOI+VbciM8K44cJIZACOZ82K z7i6f0T4WQLLaApMUP4voO60Kefj82XPIlNIp2TGnCHaUQsnbP6Sh4yuyjKAEoc9F2SV ZoOa2c2zkCg29VznHpc6NOKboffcslMvNY/sCY8R5vjZCcWbOnSTELyFvvjWHCWeqbPE hyRHyy0jet+8wKAVUHYICHmYcan8PpO+BI9485exogDbS66geUhVoHkh7mrpBvbL7n3w Zaog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uao4MNRY; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u6si11307929ejf.218.2020.07.20.09.23.49; Mon, 20 Jul 2020 09:23:49 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uao4MNRY; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731755AbgGTQX0 (ORCPT + 15 others); Mon, 20 Jul 2020 12:23:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:41196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732644AbgGTQFf (ORCPT ); Mon, 20 Jul 2020 12:05:35 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 26B5A2064B; Mon, 20 Jul 2020 16:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595261134; bh=9fcM8UNcJIVaRWwp8+SdABCME/wG7n29B/fICmrFgRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uao4MNRY0FK3yurvQKkMp0eNXoRFUkIY0SOCu9aaS1EJ0QKBc+z2DZpkKm6glRxV4 TZ+htyWveymbDOjNwcmQwhPabI2chlXkis4s5aqfYaMcy2eOW6S6KrniBtA8e7u8oE Kx4U7Dy4Nc37JuJDC5gRqdI2Ye4/q1yUEkU7giWE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Guittot , "Peter Zijlstra (Intel)" , Valentin Schneider , Dietmar Eggemann Subject: [PATCH 5.4 203/215] sched/fair: handle case of task_h_load() returning 0 Date: Mon, 20 Jul 2020 17:38:05 +0200 Message-Id: <20200720152829.823407143@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720152820.122442056@linuxfoundation.org> References: <20200720152820.122442056@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Vincent Guittot commit 01cfcde9c26d8555f0e6e9aea9d6049f87683998 upstream. task_h_load() can return 0 in some situations like running stress-ng mmapfork, which forks thousands of threads, in a sched group on a 224 cores system. The load balance doesn't handle this correctly because env->imbalance never decreases and it will stop pulling tasks only after reaching loop_max, which can be equal to the number of running tasks of the cfs. Make sure that imbalance will be decreased by at least 1. misfit task is the other feature that doesn't handle correctly such situation although it's probably more difficult to face the problem because of the smaller number of CPUs and running tasks on heterogenous system. We can't simply ensure that task_h_load() returns at least one because it would imply to handle underflow in other places. Signed-off-by: Vincent Guittot Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Valentin Schneider Reviewed-by: Dietmar Eggemann Tested-by: Dietmar Eggemann Cc: # v4.4+ Link: https://lkml.kernel.org/r/20200710152426.16981-1-vincent.guittot@linaro.org Signed-off-by: Greg Kroah-Hartman --- kernel/sched/fair.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3824,7 +3824,11 @@ static inline void update_misfit_status( return; } - rq->misfit_task_load = task_h_load(p); + /* + * Make sure that misfit_task_load will not be null even if + * task_h_load() returns 0. + */ + rq->misfit_task_load = max_t(unsigned long, task_h_load(p), 1); } #else /* CONFIG_SMP */ @@ -7407,7 +7411,15 @@ static int detach_tasks(struct lb_env *e if (!can_migrate_task(p, env)) goto next; - load = task_h_load(p); + /* + * Depending of the number of CPUs and tasks and the + * cgroup hierarchy, task_h_load() can return a null + * value. Make sure that env->imbalance decreases + * otherwise detach_tasks() will stop only after + * detaching up to loop_max tasks. + */ + load = max_t(unsigned long, task_h_load(p), 1); + if (sched_feat(LB_MIN) && load < 16 && !env->sd->nr_balance_failed) goto next;