From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796180938; b=AqVxCzAVt3wf9Z96CPrcxpsE4PaStRjbsPZnEmg+YkmSv2X1ZDGWbW6nxUX/At2vsSn2 H2eC7TncYE3xE+JIfQxi0zuxISq6iHWOniCErMwlzbeCoqLp9puvA5/2HYfZclPkfmL2E T21mPmo5GMic3pThNXCe5PnPJ1yFqwj0/Cltn3ZHWJfTJX6mgKKZOUgqMrBZfmVfEPxrN mpfnOZR8oa700I25BNuBcXlIykRQhzfWrWndAAE386ZPGfuSac3FX5SGGIg3pXsNP8mCo K+n5JlhktDZuJXmFvfXZa0hyE9J1mlUPUUIaLDAehMF8gvTw6lTypK0rInMo2ClkPvQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796180938; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Cc:Subject:To:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=hYpgkV2wVGPUb8pzUBvKwh0SrmtDOSwY55iYsmmAfWo=; b=4FJaeihnmLO+qCcR5rhqRJL4gSM2MayjB3HRHbJsA/mRu4CCD/bTf/FqdCcN/UPUWp0e /AomkG9/F8DaGd9SntC0dHKXggW9I+CD9+uGte4ug8fhz7YDAwOm7bFu7fQGOu1XZMcbt 7RA8hvey7gmMqk97bD0fo7z4XDHvim4WUkM4CxcHYZjvZgRJdMMfLTldCn6GDhYOLN1Qj t6QEDyajEp2VAE2OQdaxiiLcuizhThqLbiVbNc4oOxmqABeT7y/b8Q9zfvkZ98i6ssDdT C9yj18HVONmNxhm3OCJWcqWZx9wSzxhotP09KW2Frs4i9xjnF8whOp8PyzH4WK34vtA== 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=a6HTa0MI; arc=none smtp.remote-ip=91.218.175.44 Received: from mta0.migadu.com (out-44.mta0.migadu.com [91.218.175.44]) (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 6C442606A323 for ; Wed, 2 Dec 2026 03:08:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6C442606A323 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=a6HTa0MI X-Envelope-To: sched-ext@lists.linux.dev DKIM-Signature: a=rsa-sha256; bh=TCfJcWShdMcJA5Y7vvEgMRvDFOZ1fSEOh27pLMRRVLI=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796180935; v=1; x=1796785735; b=a6HTa0MIdJbbvBaf9reuhxBGxd8Y+31OiYV7FJToQBMH1uh76+GnqxyE5DXu9pzi6JdAVfG7 Tg2erP6Tjr4ogQIPi6f+e3JEK4eX//OBa9X+mTBDvCpSVpLEvT4FkB9ehW4BNBo+DUhjMjhc0lx 8nr15BE0JI+KSexClkBodTnE= X-Envelope-To: sched-ext@lists.linux.dev Received: by smtp.migadu.com with ESMTPS id 6d9226beb5b846b7; Wed, 02 Dec 2026 03:08:55 +0000 X-Mizu-Trace-ID: 6d9226beb5b846b7 X-Migadu-Flow: FLOW_OUT Message-ID: <4b0a4f64-2bf1-4ed8-9bf3-55f7d6da69c5@linux.dev> Date: Wed, 2 Dec 2026 11:08:48 +0800 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 User-Agent: Mozilla Thunderbird Cc: cui.tao@linux.dev, Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , John Stultz , David Vernet , Changwoo Min , Tao Cui , sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/4] selftests/sched_ext: Check that blocked donors are never enqueued unadmitted To: Andrea Righi , Peter Zijlstra , Tejun Heo References: <20261126111649.208476-1-arighi@nvidia.com> <20261126111649.208476-5-arighi@nvidia.com> From: Tao Cui In-Reply-To: <20261126111649.208476-5-arighi@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hello, Andrea, 在 2026/11/26 19:14, Andrea Righi 写道: > enq_blocked attaches the BPF scheduler while the fair class retains a > mutex-blocked donor, so the root enable moves the donor into sched_ext > through switching_to_scx(), the same path taken by every other class > transition into sched_ext, such as PI deboost or sched_setscheduler(). > > On top of the donor state checks, verify that ops.enqueue() never sees a > retained donor without SCX_ENQ_BLOCKED during the whole run, including > the scheduler attachment. A full wakeup enqueue happens before > is_blocked is cleared, so SCX_ENQ_WAKEUP enqueues are not counted. > One thing I noticed while testing patches 1-3: on the baseline kernel, ops.enqueue() is called for the PI-deboosted donor only about a third of the time. The donor appears to keep SCX_TASK_QUEUED across the RT excursion, so enqueue_task_scx() takes the SCX_TASK_QUEUED early-out. In the minority of runs where ops.enqueue() is reached, is_blocked has already been cleared. So this counter would have read 0 even on the baseline kernel and wouldn't detect the behavior this series fixes. It doesn't affect the conclusions from the test, the donor state checks still verify the entry path, I'm just noting it here in case someone later relies on that counter to catch a deboost regression. Thanks, Tao > Signed-off-by: Andrea Righi > --- > tools/testing/selftests/sched_ext/enq_blocked.bpf.c | 9 +++++++++ > tools/testing/selftests/sched_ext/enq_blocked.c | 11 +++++++++-- > 2 files changed, 18 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/sched_ext/enq_blocked.bpf.c b/tools/testing/selftests/sched_ext/enq_blocked.bpf.c > index 212690bf4e07b..72d562f16b694 100644 > --- a/tools/testing/selftests/sched_ext/enq_blocked.bpf.c > +++ b/tools/testing/selftests/sched_ext/enq_blocked.bpf.c > @@ -20,6 +20,7 @@ u64 nr_blocked_enqueues_donor_cpu; > u64 nr_blocked_enqueues_owner_cpu; > u64 nr_blocked_enqueues_other_cpu; > u64 nr_blocked_wakeups; > +u64 nr_unadmitted_enqueues; > static u64 vtime_now; > > UEI_DEFINE(uei); > @@ -34,6 +35,14 @@ void BPF_STRUCT_OPS(enq_blocked_enqueue, struct task_struct *p, u64 enq_flags) > { > u64 vtime = p->scx.dsq_vtime; > > + /* > + * A retained proxy donor must only be enqueued with SCX_ENQ_BLOCKED. A > + * full wakeup enqueue happens before is_blocked is cleared. > + */ > + if (p->pid == donor_pid && p->is_blocked && > + !(enq_flags & (SCX_ENQ_BLOCKED | SCX_ENQ_WAKEUP))) > + __sync_fetch_and_add(&nr_unadmitted_enqueues, 1); > + > if (enq_flags & SCX_ENQ_BLOCKED) { > int cpu = scx_bpf_task_cpu(p); > > diff --git a/tools/testing/selftests/sched_ext/enq_blocked.c b/tools/testing/selftests/sched_ext/enq_blocked.c > index 54ee5633c5720..ec6ffb9625fb8 100644 > --- a/tools/testing/selftests/sched_ext/enq_blocked.c > +++ b/tools/testing/selftests/sched_ext/enq_blocked.c > @@ -497,7 +497,7 @@ static enum scx_test_status run_one(bool enq_blocked, bool cross_cpu, > size_t i, nr_contenders, nr_contenders_started = 0; > size_t nr_contenders_joined = 0; > u64 nr_blocked, nr_blocked_donor_cpu, nr_blocked_owner_cpu; > - u64 nr_blocked_other_cpu, nr_blocked_wakeups; > + u64 nr_blocked_other_cpu, nr_blocked_wakeups, nr_unadmitted; > struct enq_blocked_stats stats; > > err = select_test_cpus(cross_cpu, &allowed_cpus, &thread_ctx.donor_cpu, > @@ -815,6 +815,7 @@ static enum scx_test_status run_one(bool enq_blocked, bool cross_cpu, > nr_blocked_owner_cpu = skel->bss->nr_blocked_enqueues_owner_cpu; > nr_blocked_other_cpu = skel->bss->nr_blocked_enqueues_other_cpu; > nr_blocked_wakeups = skel->bss->nr_blocked_wakeups; > + nr_unadmitted = skel->bss->nr_unadmitted_enqueues; > result->nr_blocked_enqueues = nr_blocked; > result->nr_blocked_enqueues_donor_cpu = nr_blocked_donor_cpu; > result->nr_blocked_enqueues_owner_cpu = nr_blocked_owner_cpu; > @@ -830,8 +831,14 @@ static enum scx_test_status run_one(bool enq_blocked, bool cross_cpu, > (unsigned long long)nr_blocked_other_cpu); > printf(" nr_blocked_wakeups=%llu\n", > (unsigned long long)nr_blocked_wakeups); > + printf(" nr_unadmitted_enqueues=%llu\n", > + (unsigned long long)nr_unadmitted); > if (status == SCX_TEST_PASS) { > - if (enq_blocked && proxy_enabled && !nr_blocked) { > + if (nr_unadmitted) { > + SCX_ERR("ops.enqueue() received %llu blocked donors without SCX_ENQ_BLOCKED", > + (unsigned long long)nr_unadmitted); > + status = SCX_TEST_FAIL; > + } else if (enq_blocked && proxy_enabled && !nr_blocked) { > SCX_ERR("ops.enqueue() did not receive the blocked donor"); > status = SCX_TEST_FAIL; > } else if ((!enq_blocked || !proxy_enabled) && nr_blocked) {