Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4459327imw; Tue, 12 Jul 2022 08:17:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vqc/YYvkEdqdegRaIn7yp8cuPYUzgAm3XqFSIQ0om8K1cUWMJ2jeGKKP7IkqVhd01CPabZ X-Received: by 2002:a17:906:9b0a:b0:72b:4f33:b247 with SMTP id eo10-20020a1709069b0a00b0072b4f33b247mr12692242ejc.267.1657639035535; Tue, 12 Jul 2022 08:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657639035; cv=none; d=google.com; s=arc-20160816; b=vJHLDwtSvanSckdn2Y87bccV05zUHSNoSR3CHqEl+O8P43egCoJBeHKH4pSLxfP29r eWyVqmGOmLnQiT4PUJcLlNTKiOlF5qcCvpt40pbqcMVelwx9/YR/72XTh6O2IQIAlHPD R7jQtxnf4nVLGCzBp5hE/PU71U+uCwxYK3kz0anQONNzb51pjgKjmnLb9XWHlhPfXpV1 bVRxQA4wMFNJ3YDNCJuHYHb4xyHsW0O6BbyAZMacl9NbJEwSgGmW4GgHV+npPuFe6/A3 uBqk0j3M//R1Q4FNsY5jDpXiT2LEICHkF217/7r8GprYIira3gm/G6+hQx8A6l/ZfxbC 2/HA== 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=NhpshgXDQ+xUzk4h6Lh4yF5CzXccahZmLMQ/b5lYlGY=; b=XWtUeOszJaevXWkwXMiooKHyQu2YLi5k+D0X5YAQRDyWr8COLaBbFiCyTsacpdEe6Z 5pHuhMp4Iy+eocE68fQhsLLVGQI7bwWUBiq64JY88SfJAo5FgQfBAdpFTYGGWHvbl6zq uSm4o6AWH9DkdvDqBcnk3pCHl8Oz+LeONPDMcHFlA9R7n5DadIwCA5RSrXePjfJwEg7V ob6QclfNTDHSBiCaEApj/XUgbZ4lT0XfEUQPcct0xlmwFk1UjDGkcUH35q9f2tDps6Ot hzS0BJXs3IpFt0JGPYVooGe4RxWc33FmOZKX1HaYwtXW3yk8D6raN1yo1g4ng7oL2OFx WKtQ== 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 g7-20020a056402320700b004357feb6876si14164880eda.36.2022.07.12.08.16.47; Tue, 12 Jul 2022 08:17:15 -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 S233192AbiGLOaP (ORCPT + 99 others); Tue, 12 Jul 2022 10:30:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231289AbiGLOaA (ORCPT ); Tue, 12 Jul 2022 10:30:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2394A0262 for ; Tue, 12 Jul 2022 07:29:58 -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 ams.source.kernel.org (Postfix) with ESMTPS id 7050EB816E1 for ; Tue, 12 Jul 2022 14:29:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2D1DC3411C; Tue, 12 Jul 2022 14:29:54 +0000 (UTC) Date: Tue, 12 Jul 2022 10:29:53 -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, zhaohui.shi@horizon.ai Subject: Re: [PATCH v5 2/2] sched/rt: Trying to push current task when target disable migrating Message-ID: <20220712102953.02d4a3bd@gandalf.local.home> In-Reply-To: <20220712013125.623338-2-schspa@gmail.com> References: <20220712013125.623338-1-schspa@gmail.com> <20220712013125.623338-2-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 Tue, 12 Jul 2022 09:31:25 +0800 Schspa Shi wrote: > When the task to push disable migration, retry to push the current > running task on this CPU away, instead doing nothing for this migrate > disabled task. > > Signed-off-by: Schspa Shi > --- > kernel/sched/core.c | 6 +++++- > kernel/sched/rt.c | 6 ++++++ > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index da0bf6fe9ecdc..0b1fefd97d874 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -2509,8 +2509,12 @@ int push_cpu_stop(void *arg) > if (p->sched_class->find_lock_rq) > lowest_rq = p->sched_class->find_lock_rq(p, rq); > > - if (!lowest_rq) > + if (!lowest_rq) { Probably should add a comment reminding us that the find_lock() function above could have released the rq lock and allow p to schedule and be preempted again, and that lowest_rq could be NULL because p now has the migrate_disable flag set and not because it could not find the lowest rq. -- Steve > + if (unlikely(is_migration_disabled(p))) > + p->migration_flags |= MDF_PUSH; > + > goto out_unlock; > + } > > // XXX validate p is still the highest prio task > if (task_rq(p) == rq) { > diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c > index 7c32ba51b6d85..877380e465b7a 100644 > --- a/kernel/sched/rt.c > +++ b/kernel/sched/rt.c > @@ -2136,6 +2136,12 @@ static int push_rt_task(struct rq *rq, bool pull) > */ > 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_migration_disabled(task))) > + goto retry; > /* > * The task hasn't migrated, and is still the next > * eligible task, but we failed to find a run-queue