Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp3083197rdb; Fri, 22 Sep 2023 18:46:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3tw1nzUEKT5gGuJ1MyYTvxZqNq3jBotfwye4JzArem00jAEW+AvP6VlN52jVzqJgSwVvs X-Received: by 2002:a17:902:f54d:b0:1b8:2c6f:3248 with SMTP id h13-20020a170902f54d00b001b82c6f3248mr1433986plf.39.1695433612398; Fri, 22 Sep 2023 18:46:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695433612; cv=none; d=google.com; s=arc-20160816; b=HmwTte90sDZl0xavVI21pCOm2oq7gw38oDDJqxPKXFldo74gxJ4Ar9BIRcaS0lAk0T uGIat7cjf1HfOG+g6oTj6kGQ4eXqpeTr/6zUQaScyInB5opqr9DYnK1pFjt7bSZR4rto PficeTgUPbKEgcyVK4cNg+mt3Nu0om46jffk6cmtt81s9x3KNJsqia6oZNeYgjdivYHI nLkuR3hjsgfwoBtaHXNSfYCQAzhsFSZfWfEjwtIC6XiJ5toL/U5SG+mwWGHgalN3OunB oUfPqbFLnL4nj5ik7g3Cm/rPtEnkgN87ImzCviqpcVdBuLdEmTtVepwkGyxjmH+lBPwW rSlQ== 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=+aYDPibI6R3vdw/4sHL7LAgoUe5U6jlZJRAO1ITL5Sc=; fh=37GqI620nIbt4wUFDpuJGLybMos2LuCNRFDm66HKxME=; b=q2cwrECKfASlFtzYdRGMz0dDDE+Ttkcj6r8iZsuZ417fnCmPwY1HpVz8HkATbJdinu C83mKFzf8H64iQfNI4ja6e2n8fqR742DBevztM8LQT3rW8Fpp/N8pJesTj8O2d5i7IDt NDase26DmKa5XS7WH6O53zoWDNNL6lsHqA6L7xW8lsuyDCi4iz0QFG6RMqd0l2NHgJdY NL/pU8W3mzFLbyoCGrH2cils8dnroeFuP3yuwoOEreQX/+ls+U9AxyZ5Ok48bdpt77bu 8t+O0EMjcWSSZBrS6MIL5lV6Gb80c1ArC9NFDa8m3yBZ/Tz6tWOq9Wq60Kk5nvJjRGhd nrKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id ld12-20020a170902facc00b001b8946f3f95si4811946plb.312.2023.09.22.18.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 18:46:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3FD61822741D; Fri, 22 Sep 2023 18:45:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230219AbjIWBpK (ORCPT + 99 others); Fri, 22 Sep 2023 21:45:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230047AbjIWBpJ (ORCPT ); Fri, 22 Sep 2023 21:45:09 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94A8D1A7; Fri, 22 Sep 2023 18:45:03 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A4A3C433C8; Sat, 23 Sep 2023 01:45:01 +0000 (UTC) Date: Fri, 22 Sep 2023 21:45:39 -0400 From: Steven Rostedt To: "Joel Fernandes (Google)" Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , "Paul E . McKenney" , stable@vger.kernel.org Subject: Re: [PATCH] sched/rt: Fix live lock between select_fallback_rq() and RT push Message-ID: <20230922214539.4e282609@gandalf.local.home> In-Reply-To: <20230923011409.3522762-1-joel@joelfernandes.org> References: <20230923011409.3522762-1-joel@joelfernandes.org> X-Mailer: Claws Mail 3.19.1 (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=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 22 Sep 2023 18:45:17 -0700 (PDT) X-Spam-Level: ** On Sat, 23 Sep 2023 01:14:08 +0000 "Joel Fernandes (Google)" wrote: > During RCU-boost testing with the TREE03 rcutorture config, I found that > after a few hours, the machine locks up. > > On tracing, I found that there is a live lock happening between 2 CPUs. > One CPU has an RT task running, while another CPU is being offlined > which also has an RT task running. During this offlining, all threads > are migrated. The migration thread is repeatedly scheduled to migrate > actively running tasks on the CPU being offlined. This results in a live > lock because select_fallback_rq() keeps picking the CPU that an RT task > is already running on only to get pushed back to the CPU being offlined. > > It is anyway pointless to pick CPUs for pushing tasks to if they are > being offlined only to get migrated away to somewhere else. This could > also add unwanted latency to this task. > > Fix these issues by not selecting CPUs in RT if they are not 'active' > for scheduling, using the cpu_active_mask. Other parts in core.c already > use cpu_active_mask to prevent tasks from being put on CPUs going > offline. > > Tested-by: Paul E. McKenney > Cc: stable@vger.kernel.org > Signed-off-by: Joel Fernandes (Google) > --- > kernel/sched/cpupri.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c > index a286e726eb4b..42c40cfdf836 100644 > --- a/kernel/sched/cpupri.c > +++ b/kernel/sched/cpupri.c > @@ -101,6 +101,7 @@ static inline int __cpupri_find(struct cpupri *cp, struct task_struct *p, > > if (lowest_mask) { > cpumask_and(lowest_mask, &p->cpus_mask, vec->mask); > + cpumask_and(lowest_mask, lowest_mask, cpu_active_mask); What happens if the cpu_active_mask changes right here? Is this just making the race window smaller? Something tells me the fix is going to be something a bit more involved. But as I'm getting ready for Paris, I can't look at it at the moment. -- Steve > > /* > * We have to ensure that we have at least one bit