From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 16B5C3EBF0F for ; Mon, 23 Feb 2026 07:12:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771830730; cv=none; b=kQEcV6kODXbBL3Y0yTBusyj+aPsYn8RneY1fsEzt2g5w3go4pJijR8wsbYUXZdYWWwaZDK6E3nJ+Y/6Nkjt7TATfXsFCSGi0T5fzYzLyamayhgCLP1wVD2KEXe3iojvv4Fy706KMlnWoOFRlj/TfDIL+29PkqvIzbFUvecuQnK8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771830730; c=relaxed/simple; bh=7SQ9yonpiZcgFQLFPU68ywSGnuSeEx/p6F++hd10coM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GNIztm91YnpAP0gzVMKRShPe7YqCK9FmmPiWUxWVpc3do6HyoRhJ/CTyzP3vVtuexfEfNuVw+Xil8XtvtGO7IvOC6hW/aOeSimaTiu2PsXi0euJHdjW+TPOFHVZ3OzaDl9YgrMDu9B7PrkrMeLjYgV5BsT3lZH5NEC07PThE3u4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZyNYHjI1; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Wm57RSQY; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZyNYHjI1"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Wm57RSQY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771830728; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Oqkz0VXUiDb+za1KG2dUiDS07XLP1fxzKChYeZrP3xM=; b=ZyNYHjI1Bupekmec/wgxg/ONqyrGd8pKUdbgo00vtgoKL8wsiJTKGyCjQLtuevo7sxi9c3 U2tBHbxvXATz1A8yK1hW4DsrX0tPp9psEDpJJSWmSniAtiSfp31TFUkKykkRXeAHIuJAxX Sw7r4mjuzHVlOtJ67GVmcck01ZyHzjw= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-520-nvDF2b7BM9e4no33exGMeA-1; Mon, 23 Feb 2026 02:12:06 -0500 X-MC-Unique: nvDF2b7BM9e4no33exGMeA-1 X-Mimecast-MFC-AGG-ID: nvDF2b7BM9e4no33exGMeA_1771830725 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-43637c70876so847245f8f.2 for ; Sun, 22 Feb 2026 23:12:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1771830725; x=1772435525; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Oqkz0VXUiDb+za1KG2dUiDS07XLP1fxzKChYeZrP3xM=; b=Wm57RSQYVFbxeJveQuwvG+2AXGmokaqUAv3vRG5B8nGXdyP5KJxL0KwTC2bsRzziNF NRAj9XAb4IodO4YhzXZDndaWJ1XOexL6pyi+rwtyhC8feOBPIj8uBFb4NJO4P2beAKNX +b8JeEZUVixJB4rqtXKcBiONQoIfn+xRvW7XijqXqm2LSgRPDhBE6LLMkMdapoISpcEY m9Q1+dkoXrpMgPS01XFxakUi4oQNxSieyGgy2bUkhK6AKWNiLCXmXzhSfricqJr3R6XM 4vMzC81xomGnCjrIhz7QBhFuzjIMuFQ0kA+Qf8iqagZKuwGXVDu4JebzWNqXIKskj6SU CWXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771830725; x=1772435525; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Oqkz0VXUiDb+za1KG2dUiDS07XLP1fxzKChYeZrP3xM=; b=tHl/EL42NBcQIIUW8tU8HP4lDVZrtCYkTI8rFF2HVhHdkKS4oHkFfss8H8Gnnw034P L6CGmsgFBS0ecR8dzXjscFG77UeA3Wpf6O5HVIx83PPTds2GO4jb52yEy0XAgdApQe7C PlHcIFl6DnBMYgUjUUoTkO+QC1suDBDSwwi3O7l/9Tl/mb6+FK9+OgUGtG1kK1dE+B8L L7ofGWsxd9N/490Tf/6UQlihH6/tiSITsB8bh/DCBAYHpGkBRL9Z02laWIl5Npd3uJM+ nPqFOeCTtC0beeG9sAExpOUWvp3zxl9lP9yw5eFaq3svojrPlyyj7TMmJwyh+JOTmzAR wLRw== X-Forwarded-Encrypted: i=1; AJvYcCUkmzh5QWlaNq6mIhaShNErvIkEAVcVIwkE5k/wtnpPcFfqJHDhw02M/Y9kbHfIATjLx+yFVMEkBVb6J8c=@vger.kernel.org X-Gm-Message-State: AOJu0YxRosUxsThZOQ0d4jFpjUSu4bxJOzWX4RwbgEXf5RyGcMWh40uq 1uGm19TvY+LpjEny5jp7YifD2muPScbqRhoNx2kyGqkzUEveRHVYjgbSB0cEjIeyCIQVS5fYZJk MBrr2PelhhJ3Rus391Bbpl9CKfx//GzLjhPVMdlOuEgp/WliA8MRaIitaVltq09bPlA== X-Gm-Gg: AZuq6aL0ZpQqSaU5lLDzGwidMwZtDlDHD/FzHPe8lM60lCK/KNkpGfwycAasC0umwj8 k5O7QXtmUMdP4sLmuNUl9n8t+k3VUXepuaHVe/OiKD6c6UCJKbzldaaTC0zUBAoeE/EWpSiM1tS fy1MrbiETFFNZKKl9fhhdE+O8GqC/JERKDy0bbCeOOrDBVoO9EVy1LjX8pOyRRZHMkYJk5fD6px G9D4UlilALQRyTzpCywMns+B+CDa62iJyrlli0JU1D696MON1ukN2OIszt9zyILmhAoOKBGKLWq 2lK1sQL1Dvc2JmLg9REbYXJmTM2rQJMckgeNYKk43s9kLGkzjYMYXLluIoMyM1qdv9P+jd2RQYp TfSnaXFyHpALRd2slSE7r8g1ihfOO0gyr0JDLWi5wkn6ol3exUQY= X-Received: by 2002:a05:6000:2f83:b0:431:a0:7dea with SMTP id ffacd0b85a97d-4396f181aa5mr14389809f8f.40.1771830725424; Sun, 22 Feb 2026 23:12:05 -0800 (PST) X-Received: by 2002:a05:6000:2f83:b0:431:a0:7dea with SMTP id ffacd0b85a97d-4396f181aa5mr14389774f8f.40.1771830725035; Sun, 22 Feb 2026 23:12:05 -0800 (PST) Received: from jlelli-thinkpadt14gen4.remote.csb ([151.29.73.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43970d4bf89sm16246902f8f.29.2026.02.22.23.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Feb 2026 23:12:04 -0800 (PST) Date: Mon, 23 Feb 2026 08:12:01 +0100 From: Juri Lelli To: Peter Zijlstra Cc: Ingo Molnar , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Jonathan Corbet , Shuah Khan , Qais Yousef , Clark Williams , Gabriele Monaco , Tommaso Cucinotta , Luca Abeni , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH RFC 1/4] sched/deadline: Implement reclaim/soft mode through SCHED_OTHER demotion Message-ID: References: <20260219-upstream-deadline-demotion-v1-0-528b96e53d12@redhat.com> <20260219-upstream-deadline-demotion-v1-1-528b96e53d12@redhat.com> <20260220194702.GO1282955@noisy.programming.kicks-ass.net> 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: <20260220194702.GO1282955@noisy.programming.kicks-ass.net> On 20/02/26 20:47, Peter Zijlstra wrote: > On Thu, Feb 19, 2026 at 02:37:34PM +0100, Juri Lelli wrote: ... > > @@ -1419,6 +1444,84 @@ s64 dl_scaled_delta_exec(struct rq *rq, struct sched_dl_entity *dl_se, s64 delta > > return scaled_delta_exec; > > } > > > > +/* > > + * Check if a deadline task can be demoted when it exhausts its runtime. > > + * dl-servers and boosted tasks cannot be demoted. > > + * > > + * Returns true if demotion should happen, false otherwise. > > + */ > > +static inline bool dl_task_can_demote(struct sched_dl_entity *dl_se) > > +{ > > + if (dl_server(dl_se)) > > + return false; > > + > > + if (is_dl_boosted(dl_se)) > > + return false; > > + > > + return !!(dl_se->flags & SCHED_FLAG_DL_DEMOTION); > > It is already implicitly cast to bool by virtue of the return value, no > need for that explicit !!. Indeed. ... > > +/* > > + * Demote a deadline task to SCHED_OTHER when it exhausts its runtime. > > + * The task will be promoted back to SCHED_DEADLINE at replenish. > > + */ > > +static void dl_task_demote(struct rq *rq, struct task_struct *p) > > +{ > > + struct sched_dl_entity *dl_se = &p->dl; > > + int queue_flags = DEQUEUE_MOVE | DEQUEUE_NOCLOCK | DEQUEUE_CLASS; > > + > > + lockdep_assert_rq_held(rq); > > + > > + if (dl_se->dl_demotion_state != DL_NOT_DEMOTED || !dl_task_can_demote(dl_se)) > > + return; > > + > > + dl_se->dl_demotion_state = DL_DEMOTING; > > + > > + scoped_guard (sched_change, p, queue_flags) { > > + /* > > + * The task's static_prio is already set from the sched_nice > > + * value in sched_attr. > > + */ > > + p->policy = SCHED_NORMAL; > > + p->sched_class = &fair_sched_class; > > + p->prio = p->static_prio; > > + p->normal_prio = p->static_prio; > > + } > > + > > + dl_se->dl_demotion_state = DL_DEMOTED; > > + > > + __balance_callbacks(rq, NULL); > > + resched_curr(rq); > > Doesn't sched_change already force resched on class degradation? It does. Will remove. > Anyway, I love how simple this has become ;-) Yes! Quite handy. :) ... > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index c16b5fd71b2d5..59e5459a75492 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -9415,6 +9415,14 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env) > > if (p->sched_task_hot) > > p->sched_task_hot = 0; > > > > + /* > > + * Demoted DEADLINE tasks cannot migrate. Their bandwidth reservation > > + * is tied to the demotion CPU and will be released when the task is > > + * promoted back to DEADLINE or explicitly switched to another policy. > > + */ > > + if (!dl_task_can_migrate(p)) > > + return 0; > > I suppose this works, the alternative is doing migrate_disable() in > demote and migrate_enable() in promote. Not quite sure which is the > least horrible in this case :-) Yeah, I was undecided between the two. Can switch to migrate_disable(). I actually spent some time trying to figure out how to actually allow migration while demoted w/o breaking things, but the attempts so far ended up with not really pretty locking and retries. So, I decided to leave this 'for later' and check first for interest on the feature. Thanks for taking a look! Juri