From patchwork Tue Mar 3 17:41:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 229862 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00179C3F2D1 for ; Tue, 3 Mar 2020 18:13:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C79A4214DB for ; Tue, 3 Mar 2020 18:13:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583259235; bh=3A9kwl5TKMwVP1EqZMueu/S+j3AgCJh1wr+utIdz7i8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=up+ADevb5bA62YCGI5PljNUD/k75C/GXgqLOyrNaDQQR6v6pNx8v8hCXJ4jMSYqGS Nt0Jp5fIRcVSVq5opONlHtWyb6mRyDfl4lYYhwqawr3knXv5D9mD5HvyhsQQoP/MJ6 YO5iIL/qs5WPkiPM2n0gM8hQ1CMpRacfbGsY5WqQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729117AbgCCSNv (ORCPT ); Tue, 3 Mar 2020 13:13:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:51522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730916AbgCCRp2 (ORCPT ); Tue, 3 Mar 2020 12:45:28 -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 8930A2146E; Tue, 3 Mar 2020 17:45:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583257528; bh=3A9kwl5TKMwVP1EqZMueu/S+j3AgCJh1wr+utIdz7i8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xI7abLUZYzniF010/zdlMOUilX+Ou2ebbdnzg9mPGrAnv0OFdu2FVbY20oSBsgZJ3 y7bol6ursFbNN+F5nGvZ2+HU0vBpSgC4CvjKocXwYC+iX/RNrWdxXo+0GfLihmRZOd hVBsB15xU/zkRex2T/+7CtwRCIPxxTWw7UVJ1pLA= 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.5 029/176] sched/fair: Prevent unlimited runtime on throttled group Date: Tue, 3 Mar 2020 18:41:33 +0100 Message-Id: <20200303174307.871622078@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200303174304.593872177@linuxfoundation.org> References: <20200303174304.593872177@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 [ 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 65ed821335dd5..9e7768dbd92d2 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7068,8 +7068,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); }