Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1176970imw; Wed, 13 Jul 2022 15:13:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1soFQz+/TFZidXaZivo58zO0W+zbumM7Zl/secvVE+LtBFJg+GAFGC8EhxhEf6VnsIP2nZO X-Received: by 2002:a05:6a00:1a46:b0:525:82e2:a0d3 with SMTP id h6-20020a056a001a4600b0052582e2a0d3mr5023267pfv.48.1657750431130; Wed, 13 Jul 2022 15:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657750431; cv=none; d=google.com; s=arc-20160816; b=P2viIWwoz8NSnxOyzVv3j8GBUTWaUglTDPTDU3jC96eb0P7y6o3kJXVzNX9BA7pjV/ vJS6GrcjcJU/YGvrZHIlIN+JLx4a7AXewdOhluWJ/6sJ/ptaGiFNe9T6rbBTW+8uEA3S KE8sfLyVo8WG1Gx9geq3IuOnzVvwrSZZl1oFWPjHoMrzTgjlncr3IsYbo4v7u5ZmLwvg piDtlkLIc7WN1yGZBB7K5Up6qr2IESNMGhbd8/ihOiexFJl6cKLpPem7g0mLrCf1hZL2 fq60tUFAPUJIGsqIWnYPsGz0m7f8iCem/KLSONVKsoYVzfXyVHLZYemYWcwyc83/lETs eVqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to; bh=ETjvWG4Qa5vk389hd38gRhLY5fmK6es2qV9Jvw6KrCs=; b=IXsuthDQ7HzhqN4AmmdD/p4Vf9Qt7d6F6yiAvjnme/2pJZpNVhRwWmLtd8dGUhdADG cauWitRCm/f04I7RyoT1UCZbYVKnb0z3z6URPFT8cQpBx6mbV+k/vlkOYSFDlqn9E93C LLq74pPq4GoTBqVTVLfbFYDZLRjf0XiG5a6vaTQQ/LYMAjOpvjLQ8Y/Wila3jh+z4qdc n43GrdlgdQOnpuOnYGTtFZrsSpGQRHD8zPpBB9BlX+C8oJQ4wRnM8tRK8/+zeTLlq0zF Lhl0z5uvnCkINA5k9gOi0ch2VYI7eO1rjVV9hGfStYKGYrdMMD3r4oRUA06MpUBH+PY5 R2lw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=csail.mit.edu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c9-20020a056a000ac900b00529a32a966bsi88013pfl.169.2022.07.13.15.13.16; Wed, 13 Jul 2022 15:13:51 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=csail.mit.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237408AbiGMVbd (ORCPT + 99 others); Wed, 13 Jul 2022 17:31:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230142AbiGMVba (ORCPT ); Wed, 13 Jul 2022 17:31:30 -0400 Received: from outgoing-stata.csail.mit.edu (outgoing-stata.csail.mit.edu [128.30.2.210]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBA0222B2C for ; Wed, 13 Jul 2022 14:31:29 -0700 (PDT) Received: from c-24-17-218-140.hsd1.wa.comcast.net ([24.17.218.140] helo=srivatsab-a02.vmware.com) by outgoing-stata.csail.mit.edu with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1oBjwx-000X0z-Mp; Wed, 13 Jul 2022 17:31:15 -0400 To: Juri Lelli , LKML , linux-rt-users Cc: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Sharan Turlapati , bordoloih@vmware.com, ankitja@vmware.com, Keerthana K , Anish Swaminathan , Srivatsa Bhat References: <20220713075014.411739-1-juri.lelli@redhat.com> From: "Srivatsa S. Bhat" Subject: Re: [PATCH] sched/deadline: Fix BUG_ON condition for deboosted tasks Message-ID: <806a86d3-5204-145e-af46-023bf0142aa8@csail.mit.edu> Date: Wed, 13 Jul 2022 14:31:12 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20220713075014.411739-1-juri.lelli@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 Hi Juri, On 7/13/22 12:50 AM, Juri Lelli wrote: > Tasks the are being deboosted from SCHED_DEADLINE might enter > enqueue_task_dl() one last time and hit an erroneous BUG_ON condition: > since they are not boosted anymore, the if (is_dl_boosted()) branch is > not taken, but the else if (!dl_prio) is and inside this one we > BUG_ON(!is_dl_boosted), which is of course false (BUG_ON triggered) > otherwise we had entered the if branch above. Long story short, the > current condition doesn't make sense and always leads to triggering of a > BUG. > > Fix this by only checking enqueue flags, properly: ENQUEUE_REPLENISH has > to be present, but additional flags are not a problem. > > Fixes: 2279f540ea7d ("sched/deadline: Fix priority inheritance with multiple scheduling classes") It looks like this problem goes further back than the above commit (which was merged in v5.10). Even the oldest LTS kernel (4.9) has code like this: if (... && p->dl.dl_boosted && ...)) { /* code */ } else if (!dl_prio(p->normal_prio)) { BUG_ON(!p->dl.dl_boosted || flags != ENQUEUE_REPLENISH); return; } And we have observed crashes in the 4.19 kernel series too (CC'ed Ankit Jain and Him Kalyan who have reproduced this issue). I believe commit 64be6f1f5f71 ("sched/deadline: Don't replenish from a !SCHED_DEADLINE entity") introduced the problem, which dates back to v3.18. Would you mind updating the Fixes: tag and adding a CC: stable tag as well, when you respin the patch, please? Thank you! > Signed-off-by: Juri Lelli > --- > kernel/sched/deadline.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index 5867e186c39a..0447d46f4718 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c > @@ -1703,7 +1703,7 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags) > * the throttle. > */ > p->dl.dl_throttled = 0; > - BUG_ON(!is_dl_boosted(&p->dl) || flags != ENQUEUE_REPLENISH); > + BUG_ON(!(flags & ENQUEUE_REPLENISH)); > return; > } > > Regards, Srivatsa VMware Photon OS