From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796180938; b=dpmp7jFFRQj0Dfs9FK8ekFIanNuFXRyXfwdgLOMW27R6QW+VPZDHuLoexEOKqrGmKq3G 2SxYlMsDeMevse0Wy6BPGS5ZJsemSc0z0uyvRbj25dxpIkLwRdIm7o9O7Xr46X2Fu/kcj Smc0Y9KlVc6B0gBipo+KqqSX7/ccsD9D6icL+/u+ea5JrYgxWEQi/VXbfEh6gzutZv3U5 +mV01ji7o0X2IaNLqm0IGk5rLCOs4VUqjD224W72V/eNcgwAY1KMMJ7XT/BQFgQYX/uFg ZrCd2uF1SzJnZ4Gjq1WBjGoaE1DlgtvTjxg+fyoy9iuF+tFlNVi682x1onttZtQxRdA== 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=qDRh7tMOYkNb6WWjeom3geFimNUWUIvcUynOTVm8aefibIXFh0EcqGWanQ6bluMWrBqB W1vgMDudWaRFNwECaEd912PbDCi8Q76eTN/2HnyxoKrOKFJ/Ukvvn1GUXGUOgvKWoMHih no+ldl93oL2uyjD+0Ah+N703ZyX+bdEl91WZE4x5QdMLdacUbbaGpKUifT5Dw6bpb0Eah kUkgugonxF7EEe7Rm1Mhyxft252BtrATjduy+OkpU0aTRd4eTSpU8l7FUvaerGhagyCd3 /BT3xaerQ0q+ZsHZTdJ3a8oCyY8pDLi37Mfsmx4NyTke+idOrkiQIAPgamwGFSavWEQ== 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.45 Received: from mta0.migadu.com (out-45.mta0.migadu.com [91.218.175.45]) (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 58CCC606A32C for ; Wed, 2 Dec 2026 03:08:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 58CCC606A32C 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: linux-kernel@vger.kernel.org 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: linux-kernel@vger.kernel.org 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: linux-kernel@vger.kernel.org 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) {