Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3963714pxb; Mon, 4 Oct 2021 13:50:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+D6zj/yrlmXHm57NZhamqOFIknkbKPjACvepnjlDh0PO7Oo3wLZsgxCXeA4rO1CSumC8c X-Received: by 2002:a17:906:1197:: with SMTP id n23mr20270887eja.407.1633380640758; Mon, 04 Oct 2021 13:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633380640; cv=none; d=google.com; s=arc-20160816; b=yzmzpAFTLurv9YGzjwss+9dL1Ti5asPiUzvMx5kRrnA2mp9oIGwK8GgkmjzXSxQJLV dX5iAfbbUItzLnwkQuON9BUUw27sjWE0B+EhThxfq25BS3qWyNb0ht35y1r6bAsJUsfR 2J/67/t3/MTOo5z5+A0SuX4PUhRsOO+VJDKhvhmj/CsOXjus5NKviw/o8dOqi5rmAtLK yOf1mnpEWMGZYGg5kPq2o8Iti1cYqw78PbinpHzxDltTCnfkFnigjHzbDvOzsTrPPwFa JOw3DET+tFQiHAL9EZ+9p6XkE+rY0LG61s1SzJUMk2KwgBNOhtmp2pXA+kjutoDsWMDI m0qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZYXbvM4FvijenALtXDk4Z6ptUdMPl0kGvyUYPsVfXbc=; b=cXQZbEC7lB1+Nm7EN9yiSrxBGAa9++mGIcJQveQUDVFH01mffr1x5Xx7Sm4FJk+5Rj BexjMBl2okGHj+Jt1uMzmKmd4Ih+Jz6nc1J0kJONCj+rArA0QnAhbycq9yP3uezGg/gb pCsZwQ7kkZ6Y0PIlW6kdXiisQcnvikgSCmxYO4c+/xBQol6GUaz+fHTrQ6tMy8NJeowX /mMIeehQO/obcmVgHjs+AO6nsi4W7SerwuRo0HY5zeMtDlwnoWHfcJqxNaKPKbn/EFPu jNe+U6h3xWXigXjIW9sKDgqN8eM7XSwCfBmvEQ6Q75+noi3yey18Gr/SHS728Ua7jT6Z 5QFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="cc1DJP/b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si21938061ejd.99.2021.10.04.13.50.17; Mon, 04 Oct 2021 13:50:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b="cc1DJP/b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238533AbhJDNkj (ORCPT + 99 others); Mon, 4 Oct 2021 09:40:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:53132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238530AbhJDNim (ORCPT ); Mon, 4 Oct 2021 09:38:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A436561B40; Mon, 4 Oct 2021 13:17:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353464; bh=oUY6r6g2zJSANNMIJWvWggTv5+RsvlHHqu1DztCnh3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cc1DJP/b6mIXIlyKrCCLxxKkAuMjulDjln/dcVw4JEQnaNxFZnEEOOe2od7lobwxd DXrkS6JTe2PS+uHpALqSD4JqMhmKENFpfB4oWifAOOcG2Oa4Is6uD3jl+vPnS7S6zy LQYj1CW1/keE8rzUk5WCFVe8nkfAWHNW04szf2Wk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Michal=20Koutn=C3=BD?= , "Peter Zijlstra (Intel)" , Vincent Guittot , Odin Ugedal , Sasha Levin Subject: [PATCH 5.14 139/172] sched/fair: Add ancestors of unthrottled undecayed cfs_rq Date: Mon, 4 Oct 2021 14:53:09 +0200 Message-Id: <20211004125049.457079331@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Koutný [ Upstream commit 2630cde26711dab0d0b56a8be1616475be646d13 ] Since commit a7b359fc6a37 ("sched/fair: Correctly insert cfs_rq's to list on unthrottle") we add cfs_rqs with no runnable tasks but not fully decayed into the load (leaf) list. We may ignore adding some ancestors and therefore breaking tmp_alone_branch invariant. This broke LTP test cfs_bandwidth01 and it was partially fixed in commit fdaba61ef8a2 ("sched/fair: Ensure that the CFS parent is added after unthrottling"). I noticed the named test still fails even with the fix (but with low probability, 1 in ~1000 executions of the test). The reason is when bailing out of unthrottle_cfs_rq early, we may miss adding ancestors of the unthrottled cfs_rq, thus, not joining tmp_alone_branch properly. Fix this by adding ancestors if we notice the unthrottled cfs_rq was added to the load list. Fixes: a7b359fc6a37 ("sched/fair: Correctly insert cfs_rq's to list on unthrottle") Signed-off-by: Michal Koutný Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Vincent Guittot Reviewed-by: Odin Ugedal Link: https://lore.kernel.org/r/20210917153037.11176-1-mkoutny@suse.com Signed-off-by: Sasha Levin --- kernel/sched/fair.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 30a6984a58f7..423ec671a306 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4898,8 +4898,12 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) /* update hierarchical throttle state */ walk_tg_tree_from(cfs_rq->tg, tg_nop, tg_unthrottle_up, (void *)rq); - if (!cfs_rq->load.weight) + /* Nothing to run but something to decay (on_list)? Complete the branch */ + if (!cfs_rq->load.weight) { + if (cfs_rq->on_list) + goto unthrottle_throttle; return; + } task_delta = cfs_rq->h_nr_running; idle_task_delta = cfs_rq->idle_h_nr_running; -- 2.33.0