From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796055973; b=kYx2lm7uOGR9IuwuniccOzZDs2d9IwyeawgKUT0wXbKf47Uj3xCDyS5v0p7dP2fGXbUq +yMjgcsTGOjOK7nQSJDy/F6zbOGo5n0ByQhr9K5foBYlW5f1SvMWpmEpjDDzYoUoH0Fzp KiRfdKi8FevlhDHRq56UPvOwNiXW8OQI2723Ho6snbEut5IQKh7CwprIM/rQghjxfft2x ehXRPLDvpOUSEB24bjrnrC38iGmonhg5MPVC6xbPQg8Dc/Y/v8RQHP57Y1OtiCpRFvPVh n2YxoTcURbJM3rGSD5Oa0J5pxTvlOsKVVDrwNDAbqvoEejL9gDqD9Lw4hfhn02DvzSA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796055973; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=dKUwnWnpzGb+NNyQ7Cu/0QULtfofcdyrmzqBQRvxd40=; b=js0EM1ir1EmE0rIvXCp6DAgocgMtZ3D91ttKxqx7X49Kfchzz9nyuMiANWDr0aPiuQc6 +zGA2N8QrIURObMVUODeJNJgSWoaQ/YPuaB9ez883hAsnS3TYbMu9yFK1Cqjg9nUveH/k zzyl4QOh6SCfOl4HtUpZGJmnjgvX8koOeaLyCwgMv68SunwagdFHAeE9D4z86g1yv3UQk pJzutuCi1vnqjgpXll1+CeeGoozyunP3jdMiDuCot/2YdgGbeXFImzX1aDN+FGMGiRr1V /+6egPEgUD/z+YbG/ak5oVPhU/jN1oobvOoFGbL0qUjeG2xLMsO4JsZqOpwHTEDz6Aw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--jpiecuch.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=BHEdMkZi; arc=none smtp.remote-ip=209.85.208.70 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 215B0606A31C for ; Mon, 30 Nov 2026 16:26:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 215B0606A31C 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, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=BHEdMkZi Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-6ba4be5f951so7674566a12.3 for ; Mon, 30 Nov 2026 08:26:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796055971; x=1796660771; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=dKUwnWnpzGb+NNyQ7Cu/0QULtfofcdyrmzqBQRvxd40=; b=BHEdMkZiPJvYG3MJQV6mWU+3kJAAXFoae2xOBW703rrb6q7A6WhGBX8A95KdS5fqpU 7OCVbBYf1IjZdCKFUXJL64PUpFynt64Pk7LpV/r8a4nmpd1JFOTXuGpDZJTtwh0IuiWp hIUNfyoxO2hVNw0wDRmLHpvYF+LEPbQmN+NBX6xQjEvYqJsE2Z/aZa5icK40PpRvI1s0 E5D7ldnf9+QoQfMmDutcvP0Pt57RxRgYtPqdv18X39oXYfMkQFG34Gc4ESXOs6B7rHOH J45L9EcgYUfp/XVlBsSZi5JWxdjQXj24geHD+GSiYivdLHWwE4exFb7MCXw60mv0ly63 szcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796055971; x=1796660771; h=content-type: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:content-type; bh=dKUwnWnpzGb+NNyQ7Cu/0QULtfofcdyrmzqBQRvxd40=; b=ks9w97ycF8PRQPSTAhZf2duI6NpXBwob16LMyDHjTTMmimgIl9aRuaNvBNzXtPtHXF KFfcqmow3vbAGd/eY+bw3s7mzjBN6MMcmLFbtEvfOfRAXWDSFb4fDtIqDBUgQsAAZ4GP 4uHKsGiZs+6X2Kn1DmZlguU+jE0F2pgTndSqezo4M7pQGZD2J5cPqGyWMP4LIIDkwDN3 EZbyc3qd+8IPTLyXAh2wjLXuJD8Yp7runAb1MSsFUxruZerSqZSk+E+hYIipHeE472SB 63+9oKzBYTSejwdwydd9FTozk3SGlboLXVLRMv5RF77iKR+bCBh4HJ7ycqxMj3Ef9so1 rNkQ== X-Forwarded-Encrypted: i=1; AL+hErE51dI9T9oLAsJx5O/cv8X+ylMw+GeciF+jP7AlansPnDfbvUgcflq7Xh1iP8qD1edLoFgIGf2N/KQtr+A=@vger.kernel.org X-Gm-Message-State: APuU4Z/FYgvDpjQ9QZEB1qIDc0AYnd9S/1iyj2X7mper35O1RrMcMd8q zYEAWo8tSasgRXKjBh04fYJdL9sQ8TCpgv6c1GXZ17KnfSp3tuHJ92seS2DA9EvxWSrZ+CXHPbh HOVGvDQupPYvKZA== X-Received: from edb21.prod.google.com ([2002:a05:6402:2395:b0:6bb:6fc1:476f]) (user=jpiecuch job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:280e:b0:6b7:d55:87d3 with SMTP id 4fb4d7f45d1cf-6ba37ea7696mr21361437a12.36.1796055970981; Mon, 30 Nov 2026 08:26:10 -0800 (PST) Date: Mon, 30 Nov 2026 16:26:10 +0000 In-Reply-To: <2c4bde68cd5b1ad1bbb7a3cc7d3e3139@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261125114932.3198836-1-jpiecuch@google.com> <20261125114932.3198836-2-jpiecuch@google.com> <20261130111711.2673199-1-jpiecuch@google.com> <2c4bde68cd5b1ad1bbb7a3cc7d3e3139@kernel.org> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261130162540.3997064-1-jpiecuch@google.com> Subject: Re: [RFC PATCH 1/2] sched_ext: Reenqueue IMMED tasks when a higher class wins the pick From: Kuba Piecuch To: Tejun Heo Cc: Peter Zijlstra , David Vernet , Andrea Righi , Changwoo Min , sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Hi Tejun, On Mon, 30 Nov 2026 15:11, Tejun Heo wrote: > This is just from reading the code and I could be wrong, but AFAICS there > are three cases where wakeup_preempt_scx() finds an IMMED task on the > local DSQ which doesn't already have a reenqueue scheduled: > > 1. The CPU is idle and hasn't picked the task which was just inserted. > > 2. The CPU is in dispatch. > > 3. The task was inserted with SCX_ENQ_PREEMPT or SCX_ENQ_PREEMPT_LAZY and > curr hasn't scheduled out yet. > > In the first two, the CPU looks to be already on its way to the pick, so > I don't think there's much difference. In the last one, triggering from > wakeup_preempt_scx() may be a bit sooner, but that doesn't seem that > significant to me, especially given that the task was already waiting for > curr to schedule out, which is the latency the preempt path already > accepts. Am I missing something? I think you're right. Put as an invariant: an IMMED task on a local DSQ either has a reenqueue scheduled, or its CPU is in the pick or has a resched pending. rq_is_open() only keeps a lone IMMED task in your three cases, and rq_owned_post_enq() provides the resched for them: through wakeup_preempt() when next_class is below ext, and through the slice reset and resched_curr() for PREEMPT. So when a higher class task wakes up, the CPU is going through __schedule() anyway, and scx_settle_pick() catches the IMMED tasks there if the pick lands above ext. If the pick lands on ext (the ext dl_server still has budget, or the woken task got pushed away), the IMMED task can run right after the pick. There are two exceptions I know of: - A forced idle pick consumes the resched and leaves the IMMED task queued with next_class at idle. That's intended (AFAIK), and a higher class wakeup goes through wakeup_preempt_idle() there anyway, so we don't lose anything by removing the reenqueue from wakeup_preempt_scx(). - Under core scheduling, the core-wide pick can dispatch on a sibling that has an RT task current. It gets to do_pick_task_scx() on the sibling through the ext dl_server, which lowers the sibling's next_class to ext and runs dispatch with SCX_RQ_IN_DISPATCH set, so rq_owned_post_enq() skips the resched. If the core pick then hands the sibling its current task, nothing reschedules it, and the IMMED task stays behind the RT task with next_class stuck at ext. That's the case Sashiko reported, and I'll fix it in v2. Dropping the reenqueue from wakeup_preempt_scx() doesn't make this case worse. That reenqueue only runs when a task of a class above ext wakes up on the sibling: because of the stale next_class, wakeup_preempt() calls wakeup_preempt_scx(), and then resched_curr(). The sibling then goes through __schedule(), which resets next_class from its pick, and scx_settle_pick() reenqueues the IMMED task if that pick lands above ext. All that's lost is the time until the sibling reschedules. So I'll drop the reenqueue from wakeup_preempt_scx() in v2, so that scx_settle_pick() is the only place. Thanks, Kuba