Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2027411rwe; Fri, 2 Sep 2022 07:32:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR5uTxa9XVyR6iy60nOdtcrDoRsdNtrPZWAZguP7X+J3J1IqWRz2fg259zPsEmr3eH/XEoSU X-Received: by 2002:a05:6a00:1515:b0:536:c6ea:115f with SMTP id q21-20020a056a00151500b00536c6ea115fmr36392353pfu.37.1662129151256; Fri, 02 Sep 2022 07:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662129151; cv=none; d=google.com; s=arc-20160816; b=I+sqAKOZVP6Ou7cTQmdYGFO2rT+7Y0rTNYQUeCaL+QdsGAFPrKS4gpdhEOEnbkisbX ZVlV8hH+6Tu8odgkY8Jr4u+e0Sfr8V0JmfiBRkYgjP2E/1zom9rzDADVgxlqyXVmF7Sk 6vMjRVR2g73xmBjVTVXjBcsoIRLKht2B54T83iaqIjkruV01+/lv5tn8R99JHp4ksSZW cEM671uCs+4OfJh5ksEpfLZSR6QsVBAC/H6ge5nUe/7n2dKfh0KwPW6Ca2ke4yX7iZG6 p9mNF+LcLFvNd6mYLaruPdjgMcDSGdryhR3vZdCy9cW1oDf6AP1Fu8O2MO/8+sVwzbVi SQSw== 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=B9fpxKGi85qsskE9A4ufM2JK2kcQqsFx6eZRugqP13E=; b=WZ6FRKw0fZq20w+XjVEIaVNl1kKkNhOwIGnSz409CBKctgs6nJ8fYGkJPMII/AWExX NAmlNdeOHJ9hd/hLz2BPHcmLWSQvuNl8wOdmXuYGY9uE1DPDATPE2wlZgoJJrD9/oRvB k4okF88YecACDZ3n0o+IjFBh+Tq5cdB9erjlUvCZ8PH1KlsZ+36ybAgBtuxPW0P68Yy7 Bh2yF+gmvyI27DEi4mSeR2HE+AB0PujUS3qrhrMqgSDaBvjHW0uYWTB7bQZtzbOuFe/G SiTgqzJ4DOSa0NhpG0IpdSCR3yzc2d5MsB8Gp13DeO6unv/a4szE0xFpr/uIBOG6Vmo6 dRpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wcgek9BK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a16-20020a056a000c9000b0052d9e5f07d9si2355905pfv.210.2022.09.02.07.32.18; Fri, 02 Sep 2022 07:32:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wcgek9BK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S237979AbiIBNrg (ORCPT + 99 others); Fri, 2 Sep 2022 09:47:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237912AbiIBNrM (ORCPT ); Fri, 2 Sep 2022 09:47:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7224B32EC6; Fri, 2 Sep 2022 06:22:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6EBE96216A; Fri, 2 Sep 2022 12:25:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BB6FC433C1; Fri, 2 Sep 2022 12:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662121504; bh=Inn3o6JVhGcukmNOS9fSen8gB0FBNvdYR/bcr9er3v0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wcgek9BKxxMnYX8/2XfQkdhSz3pmKHuG5CnJC33nPN3ZQX6zCQUKgtjYAWwStEME7 wYWCDpVDb4X+mp8qcqW4EIT5qNBj0nDsbn3RKl4Bwz9Hp8PTlvPmIuPCVz9s3PUU4P e7bLC7oNiBLncr/slFrfDMukf11RDlKBe3iNWG6M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "srivatsab@vmware.com, srivatsa@csail.mit.edu, akaher@vmware.com, amakhalov@vmware.com, vsirnapalli@vmware.com, sturlapati@vmware.com, bordoloih@vmware.com, keerthanak@vmware.com, Ankit Jain" , Lucas Stach , "Peter Zijlstra (Intel)" , Juri Lelli , Ankit Jain Subject: [PATCH 4.19 06/56] sched/deadline: Fix stale throttling on de-/boosted tasks Date: Fri, 2 Sep 2022 14:18:26 +0200 Message-Id: <20220902121400.419941755@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121400.219861128@linuxfoundation.org> References: <20220902121400.219861128@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lucas Stach commit 46fcc4b00c3cca8adb9b7c9afdd499f64e427135 upstream. When a boosted task gets throttled, what normally happens is that it's immediately enqueued again with ENQUEUE_REPLENISH, which replenishes the runtime and clears the dl_throttled flag. There is a special case however: if the throttling happened on sched-out and the task has been deboosted in the meantime, the replenish is skipped as the task will return to its normal scheduling class. This leaves the task with the dl_throttled flag set. Now if the task gets boosted up to the deadline scheduling class again while it is sleeping, it's still in the throttled state. The normal wakeup however will enqueue the task with ENQUEUE_REPLENISH not set, so we don't actually place it on the rq. Thus we end up with a task that is runnable, but not actually on the rq and neither a immediate replenishment happens, nor is the replenishment timer set up, so the task is stuck in forever-throttled limbo. Clear the dl_throttled flag before dropping back to the normal scheduling class to fix this issue. Signed-off-by: Lucas Stach Signed-off-by: Peter Zijlstra (Intel) Acked-by: Juri Lelli Link: https://lkml.kernel.org/r/20200831110719.2126930-1-l.stach@pengutronix.de [Ankit: Regenerated the patch for v4.19.y] Signed-off-by: Ankit Jain Signed-off-by: Greg Kroah-Hartman --- kernel/sched/deadline.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1507,12 +1507,15 @@ static void enqueue_task_dl(struct rq *r } } else if (!dl_prio(p->normal_prio)) { /* - * Special case in which we have a !SCHED_DEADLINE task - * that is going to be deboosted, but exceeds its - * runtime while doing so. No point in replenishing - * it, as it's going to return back to its original - * scheduling class after this. + * Special case in which we have a !SCHED_DEADLINE task that is going + * to be deboosted, but exceeds its runtime while doing so. No point in + * replenishing it, as it's going to return back to its original + * scheduling class after this. If it has been throttled, we need to + * clear the flag, otherwise the task may wake up as throttled after + * being boosted again with no means to replenish the runtime and clear + * the throttle. */ + p->dl.dl_throttled = 0; BUG_ON(!p->dl.dl_boosted || flags != ENQUEUE_REPLENISH); return; }