From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) (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 2C1E723EA92 for ; Wed, 8 Apr 2026 14:17:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775657827; cv=none; b=W+i0lCdjiuloLd7S4NRdQYdAkxsRgkOq04NjfSLatxd9T7R5ritnZB0eeVCEhJVDZ2lWcs7HOQXTizCYikSJFnyCVbcSwBMvl8d9c4Q6MNiAWRj17c2qSFlkbd2d5M77uloSlxczOZkCPGYCh4xDSSEz4jnUyzEg3F2sEOlF5Fg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775657827; c=relaxed/simple; bh=nSI338Ccn8ILyzTjAkaW21CrjBT7dTNzQLbIMCA+rCY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=MbqtmPC5t6C6zmPkHdqwgqKB+HREMzDnR5nv8wR1rD8JELLdG8Uj1sf6iFE8b7gZRd9PfHDWYbkG4jECXt//u7b/CSC00TgpupF2g0fEsOAWX7NUUm/CsJp01PygQ9zNszkRYSZMKpHn1IKHmuOtuR/jKFMu/lMukoQwljRNbwk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jpiecuch.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=K7eUJXfP; arc=none smtp.client-ip=209.85.218.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jpiecuch.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="K7eUJXfP" Received: by mail-ej1-f73.google.com with SMTP id a640c23a62f3a-b90484c398cso577781466b.3 for ; Wed, 08 Apr 2026 07:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775657824; x=1776262624; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Upw3TvEeXMqMSg5wbe3ZInJcp8Ry8VNUQGJklwbJAiU=; b=K7eUJXfPJxmCe+ugxNB9gHftR/5q/61i5JV5Cc684wptplY0uJHSCv5+ahUSTa89DZ VTL1z0gXTN4s7UupFBpbjh/DFB70jA0T3Cjb+IkmAhUHgPgfAF1ChQglJCJ6haYqSJZS tZx/OfrY3MV65TV0BOYtawIuid9x+2YJ2/PhxeCqHfmzUmW4s0YI3U3cjjFTEhrmy5JH sn9w+Lh0NlYFBdiI0CUKQVV5uB/8CUPMzyzw2cNEzDKgbCnpJZQ4+rlu4sEvNFv5og4J fc6CHfAfgpq5nUrxWJImxRq1smlqtOLOeX8vKGuOkmUDRgAGSyHba8hRWz6G9fYAOpFF 92/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775657824; x=1776262624; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Upw3TvEeXMqMSg5wbe3ZInJcp8Ry8VNUQGJklwbJAiU=; b=E1RWDBaGx50GqH8J4/ZKZNmv1z5yU7lWqQqFKa3Wp5a6P9JtHEZPiLpeFUBFpm6cr2 zu8XTxWilUSzUMR0a9ueMJS5/3I/qwQOL4n9Hvp1004RqJ2uw3880pf8f/zQH4rai7EJ oUG+tirQpBa1vl/PIY3gzQWmQEB+LAteUG4fTVcVGI+URmMV0acj6FWY/cC6zVWhrmD3 oREq1XUTA8UlrLl7I4L/5WT+UWVjWKRce2RBsWUJhGpTSX/D/co9y2lect63j2YDHLS1 TTTvPW5TdCD2WLJcUKr8V54eHvVk66DCnl1rT50mPHvdRGi48l4Ie1yw/N7sED0THdTc yd4A== X-Forwarded-Encrypted: i=1; AJvYcCW4kVAJZkinCIHtiYKhSkO6AN3RqFzuWDk1UlT5h2D1oN+9z3NxyEXsvKabO2B3sTH6qAiLb7DfzYLle+U=@vger.kernel.org X-Gm-Message-State: AOJu0Yxmj5HWkS2ej9SRwutIs9dK6roQmIjNsqsxWzLNntYS0Hh2z74a 4nMd0+fMFPsgoYfPQj8afkfgFiJEtUTU7fw7kAAAkOFj/80zTrTWpz3gQrMI0uyh2vdgv2ZpXBt lSu5DYbSsDNU9jw== X-Received: from ejcdm17.prod.google.com ([2002:a17:907:9491:b0:b9c:3a86:44b2]) (user=jpiecuch job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:c011:b0:b98:8365:be with SMTP id a640c23a62f3a-b9c6795190cmr995024666b.25.1775657824169; Wed, 08 Apr 2026 07:17:04 -0700 (PDT) Date: Wed, 08 Apr 2026 14:17:03 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260408091821.91063-1-jpiecuch@google.com> X-Mailer: aerc 0.21.0-0-g5549850facc2 Message-ID: Subject: Re: [PATCH sched_ext/for-7.1] sched_ext: Documentation: Add missing calls to quiescent(), runnable() From: Kuba Piecuch To: Andrea Righi , Kuba Piecuch Cc: Tejun Heo , David Vernet , Changwoo Min , Christian Loehle , Emil Tsalapatis , , Content-Type: text/plain; charset="UTF-8" On Wed Apr 8, 2026 at 1:49 PM UTC, Andrea Righi wrote: > On Wed, Apr 08, 2026 at 12:40:09PM +0000, Kuba Piecuch wrote: >> Hi Andrea, >> >> On Wed Apr 8, 2026 at 11:28 AM UTC, Andrea Righi wrote: >> ... >> > >> > Looks good, but I noticed another issue, should we also change the condition up >> > above as following? >> > >> > Documentation/scheduler/sched-ext.rst | 2 +- >> > 1 file changed, 1 insertion(+), 1 deletion(-) >> > >> > diff --git a/Documentation/scheduler/sched-ext.rst b/Documentation/scheduler/sched-ext.rst >> > index 29d36e248f58b..99df4cc982375 100644 >> > --- a/Documentation/scheduler/sched-ext.rst >> > +++ b/Documentation/scheduler/sched-ext.rst >> > @@ -423,7 +423,7 @@ by a sched_ext scheduler: >> > ops.runnable(); /* Task becomes ready to run */ >> > >> > while (task_is_runnable(task)) { >> > - if (task is not in a DSQ && task->scx.slice == 0) { >> > + if (task is not in a DSQ || task->scx.slice == 0) { >> > ops.enqueue(); /* Task can be added to a DSQ */ >> > >> > /* Task property change (i.e., affinity, nice, etc.)? */ >> > >> > Because we trigger ops.enqueue() when the task expired its time slice or it >> > becomes runnable and has not been added to a DSQ. >> > >> > This also represents correctly the sched_change() scenario: a task being >> > re-enqueued after sched_change() still has its time slice > 0, but we need to >> > call ops.enqueue() for it. >> >> I agree that the condition should be changed, but I'm not sure that this is >> what it should look like. >> >> Is the "task is not in a DSQ" part of the condition there to handle direct >> dispatch? Apart from direct dispatch from ops.select_cpu(), I wasn't able to >> come up with a situation where we would reach this condition with the task >> present on some DSQ. > > The intent is to represent the direct dispatch from ops.select_cpu(), since in > that case ops.enqueue() is skipped. > > Honestly I think if we change the && to || in that condition, everything should > be pretty accurate. In the case of direct dispatch from ops.select_cpu() we don't invoke ops.dispatch() and ops.dequeue() before ops.running(), right? The current pseudocode calls them unconditionally. Another inaccuracy not related to direct dispatch: property changes can occur while a task is running, while the psedocode only allows for property changes while a task is queued. There's also preemption by a higher sched class, which is not covered in the loop condition (task_is_runnable(task) && task->scx.slice > 0), unless we take task_is_runnable() to return false if there's a higher-priority sched class with runnable tasks on the CPU, though that would be in conflict with the actual implementation of task_is_runnable() in include/linux/sched.h. > >> >> A more general comment about the pseudocode: I think it can be useful to >> introduce someone new to the general flow of the callbacks in sched_ext, >> but the documentation should be clear that this is a simplified view that >> makes assumptions about the behavior of the BPF scheduler itself (flags like >> SCX_OPS_ENQ_LAST, whether the scheduler uses direct dispatch), as well as >> the overall system (Can sched_ext be preempted by a higher-priority sched >> class? Can scheduling properties of a task be changed while it's running?) >> Without stating these assumptions clearly, we risk leaving the reader falsely >> believing they have a complete understanding. > > Of course this schema is not a complete representation of the entire sched_ext > state machine, if we put everything it'd become too big and complex. I think we > should just cover the most common use cases here. Maybe we can clarify this in > the description before this diagram. Let's agree on what inaccuracies need to be fixed and I'll send a v2 with fixes and attach an appropriate disclaimer to the pseudocode.