From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 896753C3BF7 for ; Thu, 30 Apr 2026 21:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777585143; cv=none; b=gJXOeCdinJ3t04/tyLYhPQ9JUiS+YQYb9D69PCAAXFZlVvgedd12Ntstt38KG17hq9iVOEJ3BB93riZJvaI72M/7A2ZtHOsRSkt4zrS9kCiRwxkpqnUWTU9SBTI4r71eAskY6gOFlO+ox4QVSciUz+MM4pmCcD4xVJlmHW3dCTU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777585143; c=relaxed/simple; bh=rFpu0D2aVCEzRgzR3XPVClzKVdrTKgkfikJlcU312Mg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gorAxnqt2GzJLMkbBfwEIAavFluNgzkpxB9JIdJRW4/rbx1jQpJuz45OqW3cgKXDtCmqFDd76nuRfBsKQKbzdjEyRon1ULkfXpX5IWzCxfC4okutMOuAPrMmy+P92POZMiiVmlYyHeseeaFQ6Abt9dIGj5+ao0flQP3GBRVeFYE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=sAuy9cNs; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sAuy9cNs" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-43d76dd4ee8so1107847f8f.2 for ; Thu, 30 Apr 2026 14:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777585140; x=1778189940; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Bx1RZ3koYOKbALeOWWHhUJW2PB0mUJKZsqlzc6GuGWc=; b=sAuy9cNsvV9nTCTNRLbYiklwliSGInaV+1S00fYORzF9WDlrr0N9VDf6MoWET9Bylg 6GEvA4P4+68hpxiW8B/rtk4eAQVLuBdLwkdtO/IWE7LFi9J0YCswscNx3xaBjSK+ADRi W4yTSl8i/SZQ7/QBbfSzpL4tvTvnK2mp+6DSjKMlJuZwfUSw+6B3+0VCZ4OzW7gXkSNS xuoEkWRtMnq5MNl1AzkJhVOGSzj7NWqSAIlFcAjRL/Eb+wS0FxtKgltShCWpwjZ8POfb ik0TVIgnYCi7G4oHauoNyX8erIa4h8R1WrdTypuPPbpC+NPayHJL8KiJfl6jALowv8bR 2Qbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777585140; x=1778189940; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Bx1RZ3koYOKbALeOWWHhUJW2PB0mUJKZsqlzc6GuGWc=; b=GkBRH5PDdpc0+q4wUk09wfpOPqYbc+gHRFSLrc4J7wuNV/Xf/Ir32ZR02t32Fm26Qz 53qnMnYnd59e3IKSDZ8oRK3ZHRSp6X99gtSpUAl5XCP3TMOprPQA1K6T6qrstGVWH1Zz jUp4jTN1yXxmQ0irAyiWGETzecVH1YKr6MFBNLa6fcDLSLdhgomesggFjN3hIKTqmJ9G epZC4LwzZNZ0jexFi7reHnK/tSPBiwT6qWxmhF88J5qnM9pmewhmys75Ll72TC7IdbbJ Nguwq1pEHCPU4jIvIwvNxRFtJ3lGruRIsehvgXPJOZ9RCyMHmM+NVxSrMwTEaVc+LSFB 47sQ== X-Gm-Message-State: AOJu0Yzl+hlks2DgVv4jhUQSMRDvVHWL68T6ZDy0urB9uGIxXuheL3hY m6Ii5fSLLBpx2zsHQPFyiANNZytvCrhIr+rbKPUZlQ4HH3VZrNFXXteE9/4pxw== X-Gm-Gg: AeBDiesr/ku+NygXejg0R3nStCltOW1TBvbkhFvb04tzvW2V4+4+JDb12SzgDKWtij0 E5PvKxvzPZamG8Iym6EUyhqkKjAh4t89cvmi5UAIDCX6fNY1nFJAr7wJv6A4vy9+uIGXsXzJqyS 0KLU9POXQ9R6Vbho2S1N0/GwbEdsXpSBE0g41OnOKL5rl1HraIyCxtBqYQx6fwvpEn5pMyBN2rl lCcU6UAx1mlsS9kXqMalUC3G862rf8+QHYCT63//Yr+0OgkKHR3OGMuD+jBcqO0u3zm+uKeH/vF ImEc7HUMUBu3zF3rdSgVCS3IW06ug8BoI7ehOiFxqvSPTlMkt5GAxRojaEQLO1fpK9hxYzxIrTb +WkAJjdVVpFQxbhCBabaP8nfNBA8csBJQwt0WiZ6hVVyMz62tLDrIpbJPNV1vqWO0Gq3cxs6VPG SDn/lAjtRhjQTrSzQbJBrV1y7HwXS3CPqS6UI+uYJg X-Received: by 2002:a5d:5f91:0:b0:449:fb9e:4b4e with SMTP id ffacd0b85a97d-44a85d97773mr579833f8f.15.1777585139824; Thu, 30 Apr 2026 14:38:59 -0700 (PDT) Received: from yuri-framework13 ([78.211.51.156]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-44a9879ef89sm418510f8f.30.2026.04.30.14.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 14:38:59 -0700 (PDT) From: Yuri Andriaccio To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: linux-kernel@vger.kernel.org, Luca Abeni , Yuri Andriaccio Subject: [RFC PATCH v5 12/29] sched/deadline: Account rt-cgroups bandwidth in deadline tasks schedulability tests Date: Thu, 30 Apr 2026 23:38:16 +0200 Message-ID: <20260430213835.62217-13-yurand2000@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260430213835.62217-1-yurand2000@gmail.com> References: <20260430213835.62217-1-yurand2000@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: luca abeni Account the rt-cgroups hierarchy's reserved bandwidth in the schedulability test of deadline entities. This mechanism allows to completely reserve portion of the rt-bandwidth to rt-cgroups even if they do not use all of it. Account for the rt-cgroups' reserved bandwidth also when changing the total dedicated bandwidth for real time tasks. Co-developed-by: Alessio Balsini Signed-off-by: Alessio Balsini Co-developed-by: Andrea Parri Signed-off-by: Andrea Parri Co-developed-by: Yuri Andriaccio Signed-off-by: Yuri Andriaccio Signed-off-by: luca abeni --- kernel/sched/deadline.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 5532ca4ad969..084af1d375b5 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -202,11 +202,22 @@ void __dl_add(struct dl_bw *dl_b, u64 tsk_bw, int cpus) __dl_update(dl_b, -((s32)tsk_bw / cpus)); } +static inline u64 get_dl_groups_bw(void) +{ +#ifdef CONFIG_RT_GROUP_SCHED + return to_ratio(root_task_group.dl_bandwidth.dl_period, + root_task_group.dl_bandwidth.dl_runtime); +#else + return 0; +#endif +} + static inline bool __dl_overflow(struct dl_bw *dl_b, unsigned long cap, u64 old_bw, u64 new_bw) { return dl_b->bw != -1 && - cap_scale(dl_b->bw, cap) < dl_b->total_bw - old_bw + new_bw; + cap_scale(dl_b->bw, cap) < dl_b->total_bw - old_bw + new_bw + + cap_scale(get_dl_groups_bw(), cap); } static inline @@ -3462,8 +3473,9 @@ int sched_dl_global_validate(void) u64 period = global_rt_period(); u64 new_bw = to_ratio(period, runtime); u64 cookie = ++dl_cookie; + u64 dl_groups_root = get_dl_groups_bw(); struct dl_bw *dl_b; - int cpu, cpus, ret = 0; + int cpu, cap, cpus, ret = 0; unsigned long flags; /* @@ -3478,10 +3490,12 @@ int sched_dl_global_validate(void) goto next; dl_b = dl_bw_of(cpu); + cap = dl_bw_capacity(cpu); cpus = dl_bw_cpus(cpu); raw_spin_lock_irqsave(&dl_b->lock, flags); - if (new_bw * cpus < dl_b->total_bw) + if (new_bw * cpus < dl_b->total_bw + + cap_scale(dl_groups_root, cap)) ret = -EBUSY; raw_spin_unlock_irqrestore(&dl_b->lock, flags); -- 2.53.0