Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp3963830pjo; Tue, 3 Mar 2020 10:10:52 -0800 (PST) X-Google-Smtp-Source: ADFU+vvdCXL9blJIq+LGF+gXOETVBOqpXkf2O7hrClDkVqReWh1qVy6LGdhi/DyF2g6jrD9I12Fz X-Received: by 2002:a05:6830:2110:: with SMTP id i16mr4208317otc.337.1583259052683; Tue, 03 Mar 2020 10:10:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583259052; cv=none; d=google.com; s=arc-20160816; b=PvZr3AohodYLfgGgvY+5g+TUNFpIYTWM1aumlmSoEzMCVdIVBmAN/RMAHivvCDbskh VAMt1TIO5e7Gczp886KVc+ecIoAyqqZGd/DnVE02r3vvtKuz/tEpiec2QAGHhY/prY+h ybje6C5MI67XfkF6vcF8Shh2en5aHbeqS9lUAtJRwvMJCZxMV2pAu54/C/z13um439vL /AqYUQnIEzfnymcR79NizztbkjML5I0iyMdZhORJI7BdTGFK2bIZsPCa3l19ehPf0nKH 9pfpzoQj1WwAEHxbgst6L4EOhbq3uNRvGTjfi6FO6H5oNBd+Uoi7WQdhpDlOnzFTBxiG gsrQ== 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=RZazJscXiUSvD7hTpx6sGUi0FxFWnCkK07WLPbQdqHQ=; b=XJGGECX4i4YsXEiqZROGE1XqtrRxYu29n2KXq1Pzxu6M3spsl60tD6dwi6xFlRd036 bUH+xk1SloYPebtAnoMWswkXkOIwQRVOylwtzfW41DaOvc2PssUFGKeqLTeAdKZtzCti qTupGOMs8cQ7pagKC2pMLv7pzIMpQzAb2Msu7XVYZv7H4QtX7Dvskk9qZt+cfZCeST4u LgYyLtQvQTqtXlmAuH23XFMQ2WZzJlwICZD4NW7qXGPPzGKAV3yGWmSKP6Pr/+CMZbDs Qlk/iP9+7a3fJQWh3DzCy38pSqVa2RWx+XA85PRIiEGoMgu3lpssFEutCoO7uesL2vN2 QVbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ewzsqmxp; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v25si8426275ote.90.2020.03.03.10.10.40; Tue, 03 Mar 2020 10:10:52 -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=@kernel.org header.s=default header.b=ewzsqmxp; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732283AbgCCRxH (ORCPT + 99 others); Tue, 3 Mar 2020 12:53:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:33430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731028AbgCCRxC (ORCPT ); Tue, 3 Mar 2020 12:53:02 -0500 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 49D8C20728; Tue, 3 Mar 2020 17:53:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583257980; bh=6ZdR+j7W/1OYrpvBOqvO9W3YcYR2SMwtDCKXi/fmZFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ewzsqmxpz41i7adSUKPSE1S4wPfHhF/er0HnDIs5HZ9iquA3ofaGxL/V+oz8jNt6/ 5EPkl4LuMKJwNP3+Y3yk1GjiRSo8UNx9AP6Zr47NHh7VKsFyBaLmjIKewiPRJHO5fe j80ktS1xmdN6zQVm1JIUBVdVSt5Q+lRH76E31bK4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Guittot , "Peter Zijlstra (Intel)" , Ingo Molnar , Ben Segall , Sasha Levin Subject: [PATCH 5.4 026/152] sched/fair: Prevent unlimited runtime on throttled group Date: Tue, 3 Mar 2020 18:42:04 +0100 Message-Id: <20200303174305.422479067@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200303174302.523080016@linuxfoundation.org> References: <20200303174302.523080016@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Guittot [ Upstream commit 2a4b03ffc69f2dedc6388e9a6438b5f4c133a40d ] When a running task is moved on a throttled task group and there is no other task enqueued on the CPU, the task can keep running using 100% CPU whatever the allocated bandwidth for the group and although its cfs rq is throttled. Furthermore, the group entity of the cfs_rq and its parents are not enqueued but only set as curr on their respective cfs_rqs. We have the following sequence: sched_move_task -dequeue_task: dequeue task and group_entities. -put_prev_task: put task and group entities. -sched_change_group: move task to new group. -enqueue_task: enqueue only task but not group entities because cfs_rq is throttled. -set_next_task : set task and group_entities as current sched_entity of their cfs_rq. Another impact is that the root cfs_rq runnable_load_avg at root rq stays null because the group_entities are not enqueued. This situation will stay the same until an "external" event triggers a reschedule. Let trigger it immediately instead. Signed-off-by: Vincent Guittot Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Acked-by: Ben Segall Link: https://lkml.kernel.org/r/1579011236-31256-1-git-send-email-vincent.guittot@linaro.org Signed-off-by: Sasha Levin --- kernel/sched/core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 8c89c893078af..e921126aec84b 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7058,8 +7058,15 @@ void sched_move_task(struct task_struct *tsk) if (queued) enqueue_task(rq, tsk, queue_flags); - if (running) + if (running) { set_next_task(rq, tsk); + /* + * After changing group, the running task may have joined a + * throttled one but it's still the running task. Trigger a + * resched to make sure that task can still run. + */ + resched_curr(rq); + } task_rq_unlock(rq, tsk, &rf); } -- 2.20.1