Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp842029imw; Fri, 8 Jul 2022 12:47:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ut5TOhIevOoCf8Ay2upt+UUTWQUnC6rcyk4rC2CtDCBsoi34t+rWrkTCaigTSLJYwmEHfJ X-Received: by 2002:a05:6402:1bda:b0:43a:55d7:9f2f with SMTP id ch26-20020a0564021bda00b0043a55d79f2fmr6887948edb.360.1657309648087; Fri, 08 Jul 2022 12:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657309648; cv=none; d=google.com; s=arc-20160816; b=NHikRyBFzCenr4HWx6pGh5ig7FQzItm7OBRI4c+VM3fzakPqT9v3tBJJIvgrsYDq4z bIeWQtCDGbYofHq5UOlFUaefajwpy9ZHwb3VEY32aspyrd9pfYriZ3k4MmAymP8zuLrp FW6A8sSgG4ft1J48jqt9Wn8hmu5BBEf2OjKmtC7oa52qvHtwLSsRi9FKjOzgmmdjZi4l t0LkjpatpSW1lGZdiy3XdrQPTZkaN7VxnL9x6xiQlyUu/2HembaM273qQWQ+Fa0Y+A7s W2U829z5NvS2HyGI/98rom096AaPC6XFDK4/obOdLo+t2h6t9SSf52nWyi8Pjk+aM2O5 NIZA== 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=R6QivZmGBT1Nz3GQRZChkyokMde1FZGN5tK7tslrTFU=; b=Poo44ZQYUz88DzmW9KdoqlUz1/C8qHLT+ukGUk34LASvM3mVd9ZrNLNE/9eA6+jDIQ s4O8c9qAoYj9n/Bl6pAcweIR+VJ1DIIvCYJt8XQUHv6NgoVpi0hppZ61t/YhMwG/uSYf qwUEBQpYHqwIw9kmynGQn8pEc26kA3oH5QYBWX5tdRXpPHJ/LbzxSz1EOLu3+yS8j4kE JlswhCsGBXvN8//2qX8We5H6Zz7knPQyu5PufWnJJV3oF90bfo/4gBrumkHXhToSxrwD M84r2lPYgsl1n5fMc61vOj359p/2JXNCmCFkBLIJ9LrKmj7dQHZZbkpe6SXsT7gHuS59 jMgw== 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 ji21-20020a170907981500b00711c8193ce8si30491649ejc.21.2022.07.08.12.47.01; Fri, 08 Jul 2022 12:47:28 -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 S238980AbiGHTlS (ORCPT + 99 others); Fri, 8 Jul 2022 15:41:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238577AbiGHTlQ (ORCPT ); Fri, 8 Jul 2022 15:41:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0700514D14 for ; Fri, 8 Jul 2022 12:41:15 -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 960B0627B6 for ; Fri, 8 Jul 2022 19:41:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1EA4C341C0; Fri, 8 Jul 2022 19:41:12 +0000 (UTC) Date: Fri, 8 Jul 2022 15:41:11 -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: <20220708154111.36e662b2@gandalf.local.home> In-Reply-To: References: <20220707165014.77127-1-schspa@gmail.com> <20220707135329.08cf74b0@gandalf.local.home> <20220708140000.6aa75a50@gandalf.local.home> <20220708150614.2cda886d@gandalf.local.home> 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 Sat, 09 Jul 2022 03:14:44 +0800 Schspa Shi wrote: > Steven Rostedt writes: > > > On Sat, 09 Jul 2022 02:19:42 +0800 > > Schspa Shi wrote: > > > >> Yes, it's what I did in the V1 patch. > >> Link: https://lore.kernel.org/all/20220623182932.58589-1-schspa@gmail.com/ > >> > >> But I think it's not the best solution for this problem. > >> In these scenarios, we still have a chance to make the task run faster > >> by retrying to retry to push the currently running task on this CPU away. > >> > >> There is more details on V2 patch's replay message. > >> Link: https://lore.kernel.org/all/CAMA88TrZ-o4W81Yfw9Wcs3ghoxwpeAKtFejtMTt78GNB0tKaSA@mail.gmail.com/#t > > > > The thing is, this situation can only happen if we release the rq lock in > > find_lock_lowest_rq(), and we should not be checking for it in the other > > cases. > > > > If we haven't unlock the rq in find_lock_lowest_rq(), it will return > NULL. It won't call this code added. > > if (unlikely(is_migration_disabled(next_task))) { > put_task_struct(next_task); > goto retry; > } Because it doesn't need to. If it did not unlock the run queue, there's no way that next_task could have run, because we hold the rq lock for next_task. Which means that its "migrate_disable" state would not have changed from the first time we checked. > > deactivate_task(rq, next_task, 0); > set_task_cpu(next_task, lowest_rq->cpu); > > Beside, find_lock_lowest_rq() return NULL doesn't means rq is rleased, > We need to add a _find_lock_lowest_rq to get the correct rq released > flags? It it returns NULL it either means that the rq lock was released or that it did not find a rq to push to. Which means there's nothing more to do anyway. > > > Perhaps add the check in find_lock_lowest_rq() and also in the !lowest_rq > > case do: > > > > task = pick_next_pushable_task(rq); > > if (task == next_task) { > > + /* > > + * If next task has now disabled migrating, see if we > > + * can push the current task. > > + */ > > + if (unlikely(is_migrate_disabled(task))) > > + goto retry; > > Ahh, It can be added, And do we need this to be a separate PATCH? Sure. The "fix" to the crash you see should be in the find_lock_lowest_rq() as I suggested. And then you can add this as an optimization. -- Steve > > > /* > > * The task hasn't migrated, and is still the next > > * eligible task, but we failed to find a run-queue > > * to push it to. Do not retry in this case, since > > * other CPUs will pull from us when ready. > > */ > > goto out; > > } > > > > -- Steve >