From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.104 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794315063; b=TGbI1K1umGpAfhyqfIwCF+eN6cAsJflhGcB7+rUtwQ3B5sLSb6Yj+IinXalrpt0Q3AMO c0Pf9hK0Xv2/ktDaLfKGS15qcuGt3BFiM9M9XNEH6wFF0oUwpqOz5GYXc+vk45EQtJ6vc Lsvugw8daHqL40TI4DFl4xFkNwnjGiW2CTIRZ4Z3CV3w1S6GEaKJwoe/HNL3oyhu70zzT YxYC5A46z85+cOIjKJ6YkLQM/UL8i5rj+Hu9H9gAqhKaYEbCPScjJ3wfPaGrl70/vAu2G N8CWiepwcpoDrxlBRrgnRsPNuziJ7arWDIwOFM6Wx9zrMqIO1jwS8Rr1qFVtNMv/y4A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794315063; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=pHWIyoAzkRKGt/Ae6HP4k4i1zKiGCLCBeF2M5OsTr4k=; b=ZP6i0y1x/0z3CJKnU2ayBDy5d0HnsIpVJKHkyjSM/U0U5MGaXNt0AYbwWFGQvzskxg7y Z8VT1Sti3uDZJUTfZwHKuQzU/eH7Y/hUTiA5tjzi/xLwDzcXw6wbmWMoTSY5eytoPDpdC 5MQF/BhkRAz7VoQq6/ibxIoSDPvYQcQmwIaKQN6cymTQUdVJ53RKpNBf3U7IAmwXKO+o1 UzrUe235qW0/HO4/C6cm3sMwpqavhs61ZUQL1PEN9/URAMDtXRSp8CH0ppnai5m4T+N4V FOQZ4O9ZDJmm4SbpcK7QPpYv1ToxPzw1m+r2vY4NfFVz6+7n0A2EXXjN+V+dALkTudA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="nnfwV/FY"; arc=none smtp.remote-ip=95.215.58.104 Received: from mta1.migadu.com (out-104.mta1.migadu.com [95.215.58.104]) (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 7CCB160A260A for ; Tue, 10 Nov 2026 12:51:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7CCB160A260A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=nnfwV/FY X-Envelope-To: sched-ext@lists.linux.dev DKIM-Signature: a=rsa-sha256; bh=DkQ2NcU3+tFcoDyU9HG1mfFsUe9Q7GZ8wrWu60m10JE=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794315060; v=1; x=1794919860; b=nnfwV/FYx3qYdyug5kYFoaPZFnh3XlKO7fAIR0r/P8PEpWRwQvaN9fEHMV8PxsDcsqvvunx6 kKCqScY5gD1sbMtF2rVkzyAa01VLI/5gNgLZ5zIttMDaueHFEn3P+7W7LZhPL0mUp0anFZbGQPn r/Pd82iqMfIkvg0Jo0fjJ7OM= X-Envelope-To: sched-ext@lists.linux.dev Received: by smtp.migadu.com with ESMTPS id 776503cc40e57f66; Tue, 10 Nov 2026 12:51:00 +0000 X-Mizu-Trace-ID: 776503cc40e57f66 X-Migadu-Flow: FLOW_OUT From: Tao Cui To: tj@kernel.org Cc: void@manifault.com, arighi@nvidia.com, changwoo@igalia.com, liwanwu@kylinos.cn, devnexen@gmail.com, zhaomengmeng@kylinos.cn, emil@etsalapatis.com, yphbchou0911@gmail.com, mingo@redhat.com, sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, cui.tao@linux.dev, Tao Cui Subject: [PATCH 3/9] tools/sched_ext: scx_pair: Don't abort when the dispatching cgroup goes away Date: Tue, 10 Nov 2026 20:49:55 +0800 Message-ID: <20261110125001.4167503-4-cui.tao@linux.dev> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261110125001.4167503-1-cui.tao@linux.dev> References: <20261110125001.4167503-1-cui.tao@linux.dev> X-Mailing-List: sched-ext@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Tao Cui try_dispatch() caches the cgroup id in pairc->cgid, drops pairc->lock and then looks the cgroup back up in cgrp_q_idx_hash. pair_cgroup_exit() deletes that hash entry when the cgroup is removed, so a plain rmdir of the cgroup that is currently being dispatched, a normal event for short-lived containers or cgroup churn, hits the lookup failure and scx_bpf_error() takes the whole scheduler down. The expiry path already knows how to re-pick a cgroup; make the fast path tolerate the disappearance too. Mark the pair as drained on lookup failure and return, letting the next dispatch expire the batch and pick the next cgroup instead of aborting. The enqueue side is left for a follow-up: a lookup miss is reachable there in principle (css offline runs under the cgroup mutex alone, and a sleeping-task migrate-out does not take the rq lock), but handling it gracefully needs somewhere to put the task, which on the enqueue path means a fallback queue; that is a larger change than this fix scopes. The dispatch path, where the miss costs one skipped batch, is the cheap half. Fixes: f0262b102c7c ("tools/sched_ext: add scx_pair scheduler") Signed-off-by: Tao Cui --- tools/sched_ext/scx_pair.bpf.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/sched_ext/scx_pair.bpf.c b/tools/sched_ext/scx_pair.bpf.c index 0d61b7b812db..d38d3a078ade 100644 --- a/tools/sched_ext/scx_pair.bpf.c +++ b/tools/sched_ext/scx_pair.bpf.c @@ -478,8 +478,16 @@ static int try_dispatch(s32 cpu) /* again, it'd be better to do all these with the lock held, oh well */ vptr = bpf_map_lookup_elem(&cgrp_q_idx_hash, &cgid); if (!vptr) { - scx_bpf_error("failed to lookup q_idx for cgroup[%llu]", cgid); - return -ENOENT; + /* + * @cgid can disappear from under us: pair_cgroup_exit() + * drops the hash entry when the cgroup is going away. + * Mark the pair as drained and let the next dispatch + * expire it instead of taking the whole scheduler down. + */ + bpf_spin_lock(&pairc->lock); + pairc->draining = true; + bpf_spin_unlock(&pairc->lock); + goto out_maybe_kick; } q_idx = *vptr; -- 2.53.0 base-commit: 5b740a72b55c4267ba4d8010f17dde26b26f52d3