Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4007530imw; Thu, 7 Jul 2022 11:04:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sALZE+zXh5JW5T6tuNliUKofAh8szKxf3DHZ7ndBARIe9AkFzuzE0LJ3KVFzA6AMFxOeP3 X-Received: by 2002:a17:90a:a404:b0:1ee:e545:288b with SMTP id y4-20020a17090aa40400b001eee545288bmr6408327pjp.142.1657217054919; Thu, 07 Jul 2022 11:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657217054; cv=none; d=google.com; s=arc-20160816; b=nMncmJ+sg93XEVShT0UKI64PX/3ryXATtRVOSDWgi19MLUeGfTxAmkKKS1fVka/hed UauJK+MJ8f5OoD2l3DTOO3XM9YHok/RlFl9pDJd9Rm3+fI1eBwQqKVtbfobn5OBdqb7z 1mj1R9NJ1Ag320fJkKTiEKfcps0qMk7scp0wPM1p6tatHGzSjELoR3I+APEtFRYpK7IS 1dwiSxBk3c4zxzZbP9ruFnUBN8fsyXK3/LSwumZyh/IfvhsAYLFnJ45u3Xt5TUWr1Rux bxdNSgucmq2AUXeoSMkTj27MEb96BniXrBIPMuOwDp3hbyvGWUvk2csxAxeDxJDkR2sW 4x2Q== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=sbkVFnjxcQXuJBT4VZRMOPsP0Ld+oHI6QCqs3MTse2Q=; b=KGj//XffP9zmknBdTHBR6caxVZ7eatuYIS3zOqeZ23TZYUJhmhPtvUE3tV9FhaWb/q wQ+ZIfwjy93XptviFXdO2ZWe14n8zPlP5aMiQT7UF6hR12h1T88jEJ/E+Y7TjSpc7lTT dWtXbt848S+fBrkHJoP1gIFjaVeMdyxxFcTsh+38SrEt72c+JcTyAbbcopd0IEas6Lxu UZXD1d0RdGGJDDnF1DZs5LZFhCvC8ATxjqASvQyIyHWtAqUGN43ZQNNg04DzU4SWfHY7 rPEQh7Bu0K0yKnPD9QonuXMp06X0BHY1fwuVj+f26frCJB68NJ90OLrth4BErTfqJ5BV kE4g== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x70-20020a633149000000b004129a79150asi2679348pgx.309.2022.07.07.11.04.03; Thu, 07 Jul 2022 11:04:14 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236031AbiGGRxe (ORCPT + 99 others); Thu, 7 Jul 2022 13:53:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235636AbiGGRxd (ORCPT ); Thu, 7 Jul 2022 13:53:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD48213D2E for ; Thu, 7 Jul 2022 10:53:32 -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 5662F620B7 for ; Thu, 7 Jul 2022 17:53:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93487C3411E; Thu, 7 Jul 2022 17:53:30 +0000 (UTC) Date: Thu, 7 Jul 2022 13:53:29 -0400 From: Steven Rostedt To: Schspa Shi Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] sched/rt: fix bad task migration for rt tasks Message-ID: <20220707135329.08cf74b0@gandalf.local.home> In-Reply-To: <20220707165014.77127-1-schspa@gmail.com> References: <20220707165014.77127-1-schspa@gmail.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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 On Fri, 8 Jul 2022 00:50:14 +0800 Schspa Shi wrote: > Please refer to the following scenarios. I'm not sure this is what is happening. Do you have a trace to back this up? > > CPU0 CPU1 > ------------------------------------------------------------------ > push_rt_task > check is_migration_disabled(next_task) > task not running and > migration_disabled == 0 > find_lock_lowest_rq(next_task, rq); > _double_lock_balance(this_rq, busiest); > raw_spin_rq_unlock(this_rq); > double_rq_lock(this_rq, busiest); > <> > Here's the problem I have. next_task is queued on CPU0, (otherwise CPU0 would not be pushing it). As CPU0 is currently running push_rt_task, how did next_task start running to set its migrate_disable flag? Even if it was woken up on another CPU and ran there, by setting migrate_disable, it would not be put back to CPU0, because its migrate_disable flag is set (if it is, then there's the bug). After releasing the rq lock and retaking it, we check that the next_task is still the next task on CPU0 to push. > task become running > migrate_disable(); > > deactivate_task(rq, next_task, 0); > set_task_cpu(next_task, lowest_rq->cpu); > WARN_ON_ONCE(is_migration_disabled(p)); > ---------OOPS------------- I don't see how this can happen. -- Steve