From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47C6338F65D for ; Tue, 5 May 2026 14:36:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777991821; cv=none; b=pF69mbI+SfrZ0+7rXuOOkX/d3exi1KfNSfdnFIehypDkd6+eIomUsLl0eqadmq/3L4HkthEtLKhX2gqdl2sONVB2lJjgyIEYnWeDe0WncypYlDYw4cmvd7GYfQDL1oXiQbQXZ+B9j0F72y5RMFDooTwyHFKXaMeihXVcWlZpLLE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777991821; c=relaxed/simple; bh=EXTA4VQHMXLo8XvUaTikcQQXMrJEDoEXwXKlSjPWfV0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fLy7zuLvkA0D68adX0HsjLyBfMiEIBmBJtQrmN6H549v9vGBRDF0ViEn4JJ3HFbmESF6jXJMe6Q0kXRzpD+dwftmgiH7j04wFREmO0qoyIIvi7ENe4O+3ns6gcor8JP6MVQCMl6lfZPQ1APovQXMZo2yPV1LHnwkD5ZOmgvTgNU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=QgxJ7a0j; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="QgxJ7a0j" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=KqZwLjgiymdNdbniW+qjRagiq+jnIq/ToBrQ8bKR7/8=; b=QgxJ7a0joGr/kw8u1NLFHMEqpV XncQtoQwrTP6+cNjGlzygjch2tHz87/AWIgKi5OMacatVJJTTdqgWu7Swl0/Ow53ViSN7Zfon50ED 1UfqOFaaQR6T7DIsrlj7tl7OkgxQ83tAkRXoIOcn7m78bc6owMyQdlOBFsx6mPIXinyQxhKyREH1+ +pyqjh5GB37yNkHzsQCNHca2R0Ff0XY3iOtbJ59r8spdN3iOfdFqv4V4pgZEGqkenVSxAvCdnWyCy 7IkVbqIn6Jv2dygJTmOTQWj1AiOtyaafS5raUHKVSb0mlCPKFo5JRHrhxAWcHgV917LoCQdO1dOb6 GHpc9c9w==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1wKGtH-00000002u5p-21Dd; Tue, 05 May 2026 14:36:51 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 0A9473001AC; Tue, 05 May 2026 16:36:50 +0200 (CEST) Date: Tue, 5 May 2026 16:36:50 +0200 From: Peter Zijlstra To: Yuri Andriaccio Cc: Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , linux-kernel@vger.kernel.org, Luca Abeni , Yuri Andriaccio Subject: Re: [RFC PATCH v5 15/29] sched/rt: Update rt-cgroup schedulability checks Message-ID: <20260505143650.GC3102624@noisy.programming.kicks-ass.net> References: <20260430213835.62217-1-yurand2000@gmail.com> <20260430213835.62217-16-yurand2000@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260430213835.62217-16-yurand2000@gmail.com> On Thu, Apr 30, 2026 at 11:38:19PM +0200, Yuri Andriaccio wrote: > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c > @@ -343,7 +343,39 @@ void cancel_inactive_timer(struct sched_dl_entity *dl_se) > cancel_dl_timer(dl_se, &dl_se->inactive_timer); > } > > +/* > + * Used for dl_bw check and update, used under sched_rt_handler()::mutex and > + * sched_domains_mutex. Please try very hard to express locking constraints in code, rather than comments. Compilers are very bad at verifying comments ;-) > + */ > +u64 dl_cookie; > + > #ifdef CONFIG_RT_GROUP_SCHED > +int dl_check_tg(unsigned long total) > +{ > + int which_cpu; > + int cap; > + struct dl_bw *dl_b; > + u64 gen = ++dl_cookie; This probably wants to be something like: lockdep_assert_held(sched_domain_mutex); or something like that? And if it really is sched_domain_mutex _AND_ sched_rt_handler()::mutex, it might make sense to pull that mutex out from that function to give it global visibility so we can test for it here. For bonus points, you'll use __guarded_by() from the context analysis bits; you'll need to add: CONTEXT_ANALYSIS_deadline.o := y to kernel/sched/Makefile and build the tree with clang-22 or later (although we'll be raising this to -23 soonish). > + > + for_each_possible_cpu(which_cpu) { > + guard(rcu_sched)(); > + > + if (!dl_bw_visited(which_cpu, gen)) { > + cap = dl_bw_capacity(which_cpu); > + dl_b = dl_bw_of(which_cpu); > + > + guard(raw_spinlock_irqsave)(&dl_b->lock); > + > + if (dl_b->bw != -1 && > + cap_scale(dl_b->bw, cap) < dl_b->total_bw + cap_scale(total, cap)) > + return 0; > + } > + > + } > + > + return 1; > +}