From nobody Thu Apr 2 20:28:18 2026 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 547913A6EE2 for ; Thu, 26 Mar 2026 20:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774557773; cv=none; b=uFyLEdx5U6SsfSzu70zMsSyfTnKD1izyxrPVzdgzr1SbQ5neJhsXW1fy4/Rz3HhBXF8Mzsk4Z086pRMbxu1qAoPs5ZqlBR7lOu3ILw0eSLv4wkS7Z7gOBlvxOOZyUHfT8GVDLFCoLSTw1aXSa22xSdayo5b5Yg3s4HfioI7Y2yg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774557773; c=relaxed/simple; bh=Q65uh6cjjBWAZ3c12PK6mxOEKiuylXPXPaMvVDeeBbE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AagY2cT4Ha120TyF8udwhRpACpOfDPcgQyMdze5Sla4SPWRn6Kri//oNvqc4+nnWB+zluedaLXJb+dmMuJhIVMwfi7ivDs/Tl7/jUYB7D/7EJ9sWsDaT4MwbsVvfEtYpTBjcRq75bzxLh6LN3oPe+MtoKX9sjzrtekqGB+1RGtU= 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=NQG8s7Ga; arc=none smtp.client-ip=209.85.216.42 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="NQG8s7Ga" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-3591cc98871so663551a91.3 for ; Thu, 26 Mar 2026 13:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774557771; x=1775162571; 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=mEZyVDr5e3OviCxoRt/q1KOLbWsrmmGkIE7t73Pzwgc=; b=NQG8s7Ga9L9d7vblA570UiJtP3krEpW7/FppQ15gUrx7w6pTFDRKqQLM/CM3gCwb/A mVGnO6tPpzKewDxDgmBZu1rTwKkbBGPbTTx9nEEtaN4doGgtAjQbi2c+EJfMj5mDPh3m K0dqSps8ypiGxvdLUS5QoTi/YUaIMw2/X1H7E0Y1OSbiMgC1B7LLYYeuU+zoznh01kbf KeLq/2rqIUxRParLxqYyVrRMOfSQbmEDajz8KxsW4kqMJGeaDVaiS/B957TxWaAtMqb2 ilx58O7B7GALG/5DFljnP+tMSBRbtjg5CYqbcNWgd6IXUOAhbzkMbZJTtH+xEdBL2v1f Jefw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774557771; x=1775162571; 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=mEZyVDr5e3OviCxoRt/q1KOLbWsrmmGkIE7t73Pzwgc=; b=JMw3vcys77NHmbXKsEbepGReVfltyAYTkKgz/1ScY1Ebobypt6aEaTae9ljnANCDIo sJt3taKsaqiMaCeQCN5KSlmyX3MrZq0D/jQXtijqaJvuVifjeKuskL/Y6tqGmTm+6wkL TUv1AwISw80qyyq6474AEJSyWH/ufzrBmETauKnt0H7tbctZVQwrKFx4fkZUtf+eHX9H nuKjTUnwPb4RWXclPv+ToWYawah93G9HBQOda1uqwCOoBvAkkinfPXj+MWa1S7o0A8dN q1BpcKCD/RV30Fb2TPL1Vhfvik7fdELl8RHpAHPVWzHlYL93/dPyD2m7rQumQC4h+cwP cXtA== X-Gm-Message-State: AOJu0YxLdNJ9xK3IyWqtHjFxYNOf3ow89Y2l73OCGyoJct0O8F+HH5wO oZ3oZvmQKjqiNTtl0buZoatzfSuwLk+Ad0j/LAZ2XS5yaiztK1Qpmm76 X-Gm-Gg: ATEYQzz2JL7VJovDxh3S4VMpSf/hnQP7ZISOpVJn9XhKNd1dGOgjQrY34CzRorg+eLB FM/cajBetRRjGE6HjH89TLYk9ny64dNSOWLFVFtiV4AQ5pFe9Am78xQgDAoY4zi6+PlfyJnAwjY 1WYvw/IcALh6jdlajNEsEwtcq1Ts4H6OEbtkazDlYspawhqdtSjeZtek7Ve7jsVYGXphIeJy0vF qNvbAt/LfWfvXOe94FOHaK3EPIl4NmoXXLDDl+m8Cw98Utm2S6FZPRlZXTiJj4MqQTjCkBh2jr5 x6LZse9badJSZGGQXPO752hzbnWxcvSNkqSkOjDX5KD1l+5xMWSjeT5CRrVHP0ntpix0ZbJIzyO OLT91gIzI7AbNNwvZsxjZBQCdPXRssoFw37KpgQHCYD3U2h6XEB6/SOHIM0XKeZSQWfYIEV7xoO tbjNqf74FgWi4BCKty5ILfNryUjE2HRPHbOGkKYVsjdjxyLZb1uZhAUZGAX1nfmUdPpIpLrhJ9d 58= X-Received: by 2002:a17:902:d487:b0:2ae:6457:3099 with SMTP id d9443c01a7336-2b0cdc9e5b5mr185225ad.26.1774557771457; Thu, 26 Mar 2026 13:42:51 -0700 (PDT) Received: from mi-HP-ProDesk-680-G6-PCI-Microtower-PC.mioffice.cn ([43.224.245.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b0cbfd17d9sm4004905ad.25.2026.03.26.13.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 13:42:51 -0700 (PDT) From: zhidao su X-Google-Original-From: zhidao su To: sched-ext@lists.linux.dev Cc: linux-kernel@vger.kernel.org, tj@kernel.org, void@manifault.com, arighi@nvidia.com, changwoo@igalia.com, peterz@infradead.org, mingo@redhat.com, zhidao su Subject: [PATCH 2/4] selftests/sched_ext: enq_immed: fix IMMED reenqueue livelock Date: Fri, 27 Mar 2026 04:42:36 +0800 Message-ID: <20260326204238.3755737-3-suzhidao@xiaomi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260326204238.3755737-1-suzhidao@xiaomi.com> References: <20260326204238.3755737-1-suzhidao@xiaomi.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the IMMED slow path fires, ops.enqueue() is called with SCX_ENQ_REENQ and SCX_TASK_REENQ_IMMED set. The original code fell through to the normal enqueue path, which re-inserted the task into SCX_DSQ_LOCAL_ON|0 (CPU 0's local DSQ) with SCX_ENQ_IMMED still present. This immediately re-triggered the slow path, which called ops.enqueue() again, creating an infinite cycle. After SCX_REENQ_LOCAL_MAX_REPEAT (256) iterations the kernel aborts with BUG_ON. Additionally, the dispatch handler consumed from SCX_DSQ_GLOBAL even though no tasks were ever placed there, so it was a no-op. Fix by redirecting reenqueued tasks to SCX_DSQ_GLOBAL so they escape the CPU 0 local DSQ orbit, breaking the cycle. Remove the now-pointless scx_bpf_dsq_move_to_local(SCX_DSQ_GLOBAL) call from dispatch. Fixes: c50dcf533149 ("selftests/sched_ext: Add tests for SCX_ENQ_IMMED and = scx_bpf_dsq_reenq()") Signed-off-by: zhidao su --- tools/testing/selftests/sched_ext/enq_immed.bpf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/sched_ext/enq_immed.bpf.c b/tools/test= ing/selftests/sched_ext/enq_immed.bpf.c index 805dd0256218..a006f07334ef 100644 --- a/tools/testing/selftests/sched_ext/enq_immed.bpf.c +++ b/tools/testing/selftests/sched_ext/enq_immed.bpf.c @@ -35,6 +35,15 @@ void BPF_STRUCT_OPS(enq_immed_enqueue, struct task_struc= t *p, u64 enq_flags) =20 if (reason =3D=3D SCX_TASK_REENQ_IMMED) __sync_fetch_and_add(&nr_immed_reenq, 1); + + /* + * The slow path re-enqueues IMMED tasks that couldn't run + * immediately. Avoid re-pinning them to CPU 0's local DSQ, + * which would trigger another slow-path cycle (livelock). + * Send them to the global DSQ instead. + */ + scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); + return; } =20 if (p->tgid =3D=3D (pid_t)test_tgid) @@ -47,7 +56,6 @@ void BPF_STRUCT_OPS(enq_immed_enqueue, struct task_struct= *p, u64 enq_flags) =20 void BPF_STRUCT_OPS(enq_immed_dispatch, s32 cpu, struct task_struct *prev) { - scx_bpf_dsq_move_to_local(SCX_DSQ_GLOBAL, 0); } =20 void BPF_STRUCT_OPS(enq_immed_exit, struct scx_exit_info *ei) --=20 2.43.0