From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FCB7279903 for ; Wed, 27 May 2026 19:31:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779910313; cv=none; b=SjIygvne5z5JMJ7netQGI6s9VgeVod7VYgzcgxGFAFYzC5ItXdcJxJvlBIJ/8KtHAMH6Ohop2zqpUZ7/moa7POpowS69noqkmOBCunFCYbutKnaPneKamHVMMhQWvtAM2ghYnuO9whT3nfa1dWRLfD1KRx7PV/qtLN8zOei3oCE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779910313; c=relaxed/simple; bh=Wo4WoMe3OaJJ9JqIM2k+evZCUV7oW4fP9N3O371uY+8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FLkc39wF7+OP65WD4DuPvOCMMw5ysgHIdsZYPwuGAKDVaWSE23R9AJsLCN9XCfwH8VHjLPwZgPaw1kdQht/Pvb/LtZu4ugPK33vhUK7gZ0SiHGNyi/KyfwglfEs4lkAJ3rX4WvI41jgHVcD7PWu4nhVhZAxyAwEftiB7/3pe1gc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AGomMq5s; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AGomMq5s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93CC11F000E9; Wed, 27 May 2026 19:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779910311; bh=hrtqy6DO1hNWxAIHoldPlek/R2PxobgZBYEk0CeEPlk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=AGomMq5sDT0CiQttkkTLyRsm8lOMxeastYt25VqJJ0gZPXpsIOFDXWKb763ntoA0P RcSgfWtlAsbh5K6BoWgPHPqvg8qDNN4AJd1i2PuFWucrqKR4k+16h10leZA1vYMUVZ SkN608NGN2LXi6IzLU5RBcTKTa1uT8XoNezh7OaVt/CZpZgGP07k9moVnXKG8WBzfO yTt/WfeZ4jXBJqhpOlmn4HRBEabjrNlQeUg7kgVzzzuQfEyjKw9pN5vLJlw/2KRpK0 Ogd+EbgsF0YR/zRSkkKupvLBKKU1KP2B7VA3K1ZI2JO12NiETGtMu8Yvas5KYZc0uZ IliQN2nsrv7ZA== Date: Wed, 27 May 2026 09:31:50 -1000 From: Tejun Heo To: Fernand Sieber Cc: David Vernet , Andrea Righi , Changwoo Min , Ingo Molnar , Peter Zijlstra , Vincent Guittot , linux-kernel@vger.kernel.org, nh-open-source@amazon.com, Fahad Mubeen , Hendrik Borghorst , David Woodhouse Subject: Re: [RFC PATCH] sched/ext: add sched_info_enqueue in dispatch path for schedstat Message-ID: References: <20260525191942.2349-1-sieberf@amazon.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260525191942.2349-1-sieberf@amazon.com> On Mon, May 25, 2026 at 09:19:42PM +0200, Fernand Sieber wrote: > SCX tasks re-dispatched from BPF (e.g., after bandwidth throttling) > bypass enqueue_task() and go directly through dispatch_enqueue(). > This skips sched_info_enqueue(), leaving last_queued at 0, which > prevents run_delay from accumulating in /proc//schedstat. > > Add sched_info_enqueue() in dispatch_enqueue() when last_queued is > not already set. This ensures run_delay correctly reflects the time > a task spends waiting for a CPU after being dispatched, including > time spent in BPF-managed throttle queues. > > Without this fix, schedstat shows frozen run_delay values for SCX > tasks that go through throttle/unthrottle cycles. > > Signed-off-by: Fernand Sieber > --- > kernel/sched/ext.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c > index 7ebdaf75d..827a96e39 100644 > --- a/kernel/sched/ext.c > +++ b/kernel/sched/ext.c > @@ -1525,6 +1525,10 @@ static void dispatch_enqueue(struct scx_sched *sch, struct rq *rq, > WARN_ON_ONCE((p->scx.dsq_flags & SCX_TASK_DSQ_ON_PRIQ) || > !RB_EMPTY_NODE(&p->scx.dsq_priq)); > > + /* Track queue time for schedstat run_delay accounting */ > + if (!p->sched_info.last_queued) > + sched_info_enqueue(task_rq(p), p); I don't think this works. A DSQ can be used for throttling too and a BPF data structure can be used for non-throttling queueing too. I don't see how doing the above unconditionally would capture something meaningful reliably. Thanks. -- tejun