From nobody Thu Apr 9 23:26:10 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (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 924F63CF679 for ; Thu, 5 Mar 2026 16:16:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772727369; cv=none; b=cr6C1a5edFGHy/9JgzL5GVqRwwfJYU2PDBbwGAM3Aqpui6q9AkzAlE2pUs7q6xW5hyVlnxCfCyx+dFWM3Zc42D/r2Z3FmvB7iiptH3eyLXt/vLBaG0wUCaTvf2XQtDhiYUrfsTvhp1rKt8JGvy906KTH4XX8hXuCnJmFdSbjv3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772727369; c=relaxed/simple; bh=6FexgOl/YVWpjj0jIRoVNTpnAdN4iYrWi4l+UFPFdMU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I1l0ZORnOPqNdezzRHfLZjnNyxIRmORZ6TTrFWxuhOcM/1fGQ2LRSWa/VrpcgsnlDwCXLXOFqdUt2MONezFp6VRKLJ5yUZMcMxuu37vhKzIk03uPqKr+lLMTQVJ5wNG4O3072DpYj9xssKGu/9iB9gzaUj8BGx6RvtR0m0PB6n0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=none smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=mgME5aVF; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="mgME5aVF" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=/p5loGM8jok20LIPIaiNcteQRMdR3qdR3xO0RfQ3suo=; b=mgME5aVFrmQCyqUATCjnDUHcrO BwFBXbJL31mp67Xp5TnMKWpPbLVp4qTk3GmroY04gNmyLk7fujcn1U2tQJ86eo6klesyNYAx9yyeW Q7QvLoVM/1mC854UXsbodF/v4avgh+LeB1haxNY2F2DK6ZvwuQa+pM3CBKxB1WYgqghCNa0PfKbuo FexRwW45rI4OsJ4nKK7Nl5vCeg42ajSmC9z2kl6kZnB3sz6Lv7hbCebh9m/yb0qiL/v1EDnlS2vaj 5Y0qNdOPQDzwA7SPyQ7oNsm22ELCIb0Kz4RebXS7T5kYUB2DqwptxFPnkr1uNa/TncS/c+nVsVpOh QP2oUH8A==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1vyBMr-00Gqqh-8x; Thu, 05 Mar 2026 16:16:05 +0000 From: Breno Leitao Date: Thu, 05 Mar 2026 08:15:39 -0800 Subject: [PATCH v2 3/5] workqueue: Show in-flight work item duration in stall diagnostics 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260305-wqstall_start-at-v2-3-b60863ee0899@debian.org> References: <20260305-wqstall_start-at-v2-0-b60863ee0899@debian.org> In-Reply-To: <20260305-wqstall_start-at-v2-0-b60863ee0899@debian.org> To: Tejun Heo , Lai Jiangshan , Andrew Morton Cc: linux-kernel@vger.kernel.org, Omar Sandoval , Song Liu , Danielle Costantino , kasan-dev@googlegroups.com, Petr Mladek , kernel-team@meta.com, Breno Leitao X-Mailer: b4 0.15-dev-363b9 X-Developer-Signature: v=1; a=openpgp-sha256; l=2206; i=leitao@debian.org; h=from:subject:message-id; bh=6FexgOl/YVWpjj0jIRoVNTpnAdN4iYrWi4l+UFPFdMU=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBpqaw0TAz/Z05WDXEWmt2FKYK+iZ/e261ng5cVl LBj4qKqu+aJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaamsNAAKCRA1o5Of/Hh3 bXauD/9uatHOJbfvUmvQ+aZQo6ietoqjfzHWNG7lgcm5OuGbOWKexKTQLk5uDmFDm3AatM1NjSd r6qG6KO6iUCrAlQKhiMGv8cqxURUdx1WwwvaBLqIbmRVD0jDFv5nGrUN013v9lw+t2dfGUkx+8r 9FxPQXQIWKqsVF4yhVhzDnAnbtsgnrN5u7tRpxPpM7C5jVKcpBn0iFyoZsF7b+PBSN9KlkKCh/9 bMnhamRCLxjMO3xomfcfVcfjjkzdV+uslmYsgDUbVa7EMkokG55p6FU92mTH5/9PhizwEmyEk9E CRSAy53kT/XvBtVCqRnRqH+jujw4ClC/19NftRVpLFu6mkwjQKvwi3QF5U1fWBFTiDKz3jkG3oB l2pqKDibvfJbu38oSo1aABvGiMyKEVNBZgBILv3uql2P6S0h5IiwEYGJMR1VNO781kXUuM6UX4T kikn4vktRTgdoqQm0/MM9vrwcc2yUqseMbxZPlH7GfIJlLgGb9thuuGoFYybVy766Fb0KI+iMvv BE6LsOBRHTJ0wHELnH+Ne3Nj9cWb5G7sen7+MQD9xEQwCNOiZ1cKeASgMPV0xLoyCYERG+SUTGk eY/56XmW8OtuE0eu+cxvwyOIqAi1w2fDGXNP8S3ajkou5ddvi2wWk3eNM6k0V7N1CRs/tL87cpC sbC2y3cAhr+0MUQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao When diagnosing workqueue stalls, knowing how long each in-flight work item has been executing is valuable. Add a current_start timestamp (jiffies) to struct worker, set it when a work item begins execution in process_one_work(), and print the elapsed wall-clock time in show_pwq(). Unlike current_at (which tracks CPU runtime and resets on wakeup for CPU-intensive detection), current_start is never reset because the diagnostic cares about total wall-clock time including sleeps. Before: in-flight: 165:stall_work_fn [wq_stall] After: in-flight: 165:stall_work_fn [wq_stall] for 100s Signed-off-by: Breno Leitao Acked-by: Song Liu --- kernel/workqueue.c | 3 +++ kernel/workqueue_internal.h | 1 + 2 files changed, 4 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 687d5c55c6174..56d8af13843f8 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -3204,6 +3204,7 @@ __acquires(&pool->lock) worker->current_pwq =3D pwq; if (worker->task) worker->current_at =3D worker->task->se.sum_exec_runtime; + worker->current_start =3D jiffies; work_data =3D *work_data_bits(work); worker->current_color =3D get_work_color(work_data); =20 @@ -6359,6 +6360,8 @@ static void show_pwq(struct pool_workqueue *pwq) pr_cont(" %s", comma ? "," : ""); pr_cont_worker_id(worker); pr_cont(":%ps", worker->current_func); + pr_cont(" for %us", + jiffies_to_msecs(jiffies - worker->current_start) / 1000); list_for_each_entry(work, &worker->scheduled, entry) pr_cont_work(false, work, &pcws); pr_cont_work_flush(comma, (work_func_t)-1L, &pcws); diff --git a/kernel/workqueue_internal.h b/kernel/workqueue_internal.h index f6275944ada77..8def1ddc5a1bf 100644 --- a/kernel/workqueue_internal.h +++ b/kernel/workqueue_internal.h @@ -32,6 +32,7 @@ struct worker { work_func_t current_func; /* K: function */ struct pool_workqueue *current_pwq; /* K: pwq */ u64 current_at; /* K: runtime at start or last wakeup */ + unsigned long current_start; /* K: start time of current work item */ unsigned int current_color; /* K: color */ =20 int sleeping; /* S: is worker sleeping? */ --=20 2.47.3