From nobody Mon Jun 8 22:51:08 2026 Received: from pdx-out-011.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-011.esa.us-west-2.outbound.mail-perimeter.amazon.com [52.35.192.45]) (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 57A5E3612E7 for ; Mon, 25 May 2026 19:20:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.35.192.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779736806; cv=none; b=nwOc3RtYNy9tu8isfbiDRwYU8nduiT9zVJAgY4xR2U1/FVVnlEX2/qiclXrJhA11TMOM/AWJGiAIXcFWogsAdhXJLf/hH9eo6dGZrbyP3UBp0p655OHNoIY95OEgUwWCOx0TNVRvYoqlnLecRYifdK5gAI8p8i5F88e5bBu1o3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779736806; c=relaxed/simple; bh=V9yoP1TM3nWwBmeCecrDmtvMPPUCF/vDk/WE/5UBKzE=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=vBmGunt8jnnXOV7PKI7hyeuTraftYQHuKZ2ymxVT5nd2HBT1X8UcZsL4ppc6UEdhU7b0638rbIJ17irrohzol6KlttGYi3BuBkGCSmtvkOrNuz0kZZCTW4a7aB/UFAT3W7WOZ4//apMJ9b2aLJFWN5gS0Ap6pQq044xYKARkfkU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.com; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=sxpK5bin; arc=none smtp.client-ip=52.35.192.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="sxpK5bin" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1779736805; x=1811272805; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=IkTI7aPtU53+Ovkjk0RYAXLqM5sU9t4orXbZ8mK1+H0=; b=sxpK5bin3EcyF0z11C4st9GJI+Abxwjt1yy0k+ZSxFSgSbuivN+x+o0y KjosVDBYNNd78qR3CEd2oZ3dY3xsrTW+x5gRvOGwlAS/+nPV+EY0XQIQ1 vvJcxqp38802D3w8Ik/Hl/uPzxm6dTlXNVsOiQ2ObSeQGFWeEozPj7aBV fe22UvVILy2XmDCqAIgODRxu3f+ejGdDli1pF1+h676A2GTzms+aRAop3 R4t3avvt01e4UR3HWNX3E1IIgyHJihdN8p0wlVuL/76XeMCAI4/UvgEIm gw+pFLrMlkZYIajhkRQCnPAvbKwi4vmVvDDGWG0nSepT3iunDb+mtlq8q Q==; X-CSE-ConnectionGUID: WXcNVcr5Qr2EhkNmVUsBQA== X-CSE-MsgGUID: i+bDFywVRBa2XpzebOIZFw== X-IronPort-AV: E=Sophos;i="6.24,168,1774310400"; d="scan'208";a="20208786" Received: from ip-10-5-12-219.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.12.219]) by internal-pdx-out-011.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2026 19:20:02 +0000 Received: from EX19MTAUWC001.ant.amazon.com [205.251.233.53:4010] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.48.135:2525] with esmtp (Farcaster) id dc5b7a03-2592-461c-bd1e-d2e878992f24; Mon, 25 May 2026 19:20:02 +0000 (UTC) X-Farcaster-Flow-ID: dc5b7a03-2592-461c-bd1e-d2e878992f24 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWC001.ant.amazon.com (10.250.64.174) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Mon, 25 May 2026 19:20:01 +0000 Received: from dev-dsk-sieberf-metal-1a-7543e84d.eu-west-1.amazon.com (172.19.116.227) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Mon, 25 May 2026 19:19:59 +0000 From: Fernand Sieber To: Tejun Heo , David Vernet CC: Andrea Righi , Changwoo Min , Ingo Molnar , Peter Zijlstra , Vincent Guittot , , , Fahad Mubeen , Hendrik Borghorst , "David Woodhouse" , Fernand Sieber Subject: [RFC PATCH] sched/ext: add sched_info_enqueue in dispatch path for schedstat Date: Mon, 25 May 2026 21:19:42 +0200 Message-ID: <20260525191942.2349-1-sieberf@amazon.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D046UWA001.ant.amazon.com (10.13.139.112) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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)); =20 + /* Track queue time for schedstat run_delay accounting */ + if (!p->sched_info.last_queued) + sched_info_enqueue(task_rq(p), p); + if (!is_local) { raw_spin_lock_nested(&dsq->lock, (enq_flags & SCX_ENQ_NESTED) ? SINGLE_DEPTH_NESTING : 0); --=20 2.47.3 Amazon Development Centre (South Africa) (Proprietary) Limited 29 Gogosoa Street, Observatory, Cape Town, Western Cape, 7925, South Africa Registration Number: 2004 / 034463 / 07