From nobody Sat Sep 26 21:12:47 2026 Received: from LO2P265CU024.outbound.protection.outlook.com (mail-uksouthazon11021113.outbound.protection.outlook.com [52.101.95.113]) (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 4F56741CB20; Sat, 29 Aug 2026 23:05:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.95.113 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788044730; cv=fail; b=XcetpHWko4gh557jwlf5gvbySqkZXkKoo7msAB6y7Ren74lUOjG1RbMpZuHSz3LrYfyowhHuR1mTf8s6rg+Y3BYxoxStUBZ7kWWoTTj5t+2blXHxIYcXgHPWFYVC4+fFtwN3sJ+Zp39JOqcSyvk69dcZRaHiBSF9pfxPeiY1+tg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788044730; c=relaxed/simple; bh=XBWxHG0KNX2zQQzSCP7NAsj6y1h/2YJFLW3Rxng+wrA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=cSuEYFi4FlTCpbQN6uNeWGpdyxV55+Nu3QbICmKuGkSKFzBWj6SZQxoKVbZE8NCSRTvjXxDtgdM2lKcF5q9NqIAV9ypU24wh3bSxgpjhV3a1nWQlk3tx5Zx6Z4L651SoeHTlhIJAhexBAwZjBBHkdB+JHHgNIJ+1QSaX83cJAXo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com; spf=pass smtp.mailfrom=atomlin.com; arc=fail smtp.client-ip=52.101.95.113 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atomlin.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NyG0iuy2Ak5mbVksGCWGkUEUhKZrigIARqZrMbUUVP0pGavCFtu70bfOybhB+yMup7pnJxpCBlGjs785XDARD663GnjiB5jTshJoBRTstARsFytPDKHVvtSvJIcdSyRcSOUhGSZEKQedS7dlT0HABNPlAU2hVI+LWESm+U03COTbzXYgw0So2Z8Akohw3ph5TaPoSxYgwkbsD7cXC5ocEnuBpf6Qwc0RURanU8DrBoRu01t0FUwSlZensE0FVu1UywEn9Z8at1XyHhS6EVEzWNiViAxYx7hARA+wd6krntVx5wXIlecPRUyI3JY+TbKSJAbz/6qE5xbK1YceKrmovA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:MIME-Version; bh=OYMGu8J62ruScyV8VKzm0/riYEUw5t/297iGAfkwSmE=; b=rUcRRJjIOSWKF1w95/CSZu5HUS31GDkpO6FYbkh1WtSInYixYiUReaOgG8mSIyxneAxMzCPtSYFuwB/UqJbuyjIfUdI84PnxoCsFEC1bAJ+PSznVhlx6GZ/Cb435a9xkU+dHcHZdgfbN0iEVjtFRzoeMlN8GnCNF4Ftk8Xwi/pD4cgt7amJbIq4XYm+V7omhEoRxCFNj7e6d2SHFAYPTwlaTVBUUr/xUkQrVuKStYeXAdse9UDrUIL0/Jj8jabzeWN/3dWicUBRI47Hs69QBeoph4qyJTSL239DsYkXMAMBtuXC24tVoecPeuhzk6Bn19ZPc0EcenYDAzX1uVSPa5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=atomlin.com; dmarc=pass action=none header.from=atomlin.com; dkim=pass header.d=atomlin.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=atomlin.com; Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) by CWYP123MB9008.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:288::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.13; Sat, 29 Aug 2026 23:05:25 +0000 Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230]) by CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 23:05:25 +0000 From: Aaron Tomlin To: tj@kernel.org Cc: jianshanlai@mail.com, rostedt@goodmis.org, mhiramat@kernel.org, osandov@osandov.com, atomlin@atomlin.com, neelx@suse.com, sean@ashe.io, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH 1/3] workqueue: Add workqueue_cpu_intensive tracepoint Date: Sat, 29 Aug 2026 19:05:15 -0400 Message-ID: <20260829230517.42468-2-atomlin@atomlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829230517.42468-1-atomlin@atomlin.com> References: <20260829230517.42468-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0651.namprd03.prod.outlook.com (2603:10b6:408:13b::26) To CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLP123MB6607:EE_|CWYP123MB9008:EE_ X-MS-Office365-Filtering-Correlation-Id: 60df1c87-8165-4db6-9d66-08df062202af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|23010399003|366016|1800799024|10067099003|56012099006|6133799003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 7euXUixEav6WkwCS8VjTO9dUE3En0t7/bvTrjQU5g9ENLO55NLgmSiZ1Mnn6d5nL/r/GlysEykR0c19d/cWyo+KjudysJhfi12zEHOg9t136uCcxfdJ0w2tegK/UPAesbgBudi/YVNbccrgn1My9pT+bFqHZkPTxblU0h0t8kGhHkBblg0eC+xEr45tNpfS0/b8C6R583hwq3ukNuSdaPjCJsP9pefceDR7PZuaIbsevR8A5QDRywnXEkj3QV5geHGVMFOdpBWdWn65dxh3IMfBnY6kQacMocnPft36D/2HhKRdYPB14lab1l4nnmMluLSaTM7WJPHWHd90nuXYTVAuNSB0m5Q+PKNtzqB0BagXpG8W/O64QEBI9kuP5YTckSyMK5udLo91YkWXDwKiPagkjRqdrHqBsj4IzO3uIswFLcoKOU+SEidUvvoTjZ9TqfISOk1futkr88EwKP6bvHJBD4JbL8xxsj3TtBsq+X/xLhyhCmSw9jzkhPyuxO1HqGxtlH1BW4XixauAkf3u4FWaGEawPz7OCqPnCbRH8aiC9cNPh+DOZGsrtxDgdqeWiTP69I5L0OPwiMgL1RTm5i+AK+k0taARpeCosuLXAW8aymWF39j9aEseDjH4N+nbf61CtAht9lU3UVOM1fCyqygR8gjGyJM5YK9ppeQpKKl4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(23010399003)(366016)(1800799024)(10067099003)(56012099006)(6133799003)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?X+ec/QMDJ9IYG4W6HNb0Mitrr6xjLPswq+N8mn8pRE8z81CFxf8VqhIC8bMh?= =?us-ascii?Q?S5MQRtEBHXM97Q+ZvfaBXdirrL6zEb28AQ++xkVBXfD/hpnrQwpqi+OZtjQ5?= =?us-ascii?Q?YCVA+TaJwOMVpZ91jGXbF3FlTzt2kTSmUePFjW0sNC3nZJzECtAfeOIL/p2T?= =?us-ascii?Q?PmD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tFz5EaJVufT7Cx/VjQhMy+?= =?us-ascii?Q?1H62GH9GMObXnnQGbGIkeboGm0Cx74/o7vYV6mG3csxCL1xfDrMOer8wWAuA?= =?us-ascii?Q?uXYIZnMD6FMp7z4C5OjQVvjhQxFSj1HXIAChyfwjPTkX2SElBLA/EtFM5scT?= =?us-ascii?Q?wMxehPuXJzHE3bS73kIeZ3X2GL7r8NhYvFUvuT4eXFdZ73lDXMXi+s06eohf?= =?us-ascii?Q?hsW0WVbKn6VzJZteXmdLl61QpYu3ktCT0rSb+wCQ0l2heT5UIQOt5+VBtcXW?= =?us-ascii?Q?XzuMPqLFpF24SV1Rp5m1sWQ9YtL7gjdyQqtwPmqsgItUvDYcyTXrpHCibXdJ?= =?us-ascii?Q?0lJ0H1fQDl7vebXncaUNUiLDFp1r6pWeCxQmDXVA3cpKop/NS1wFNs4J08cy?= =?us-ascii?Q?JZgkycTDyCqlRPyXCtW8MAN2pwTrZvOoa3Oro6LQe20EUGiXp8HS9YBfkw4c?= =?us-ascii?Q?wXHpNngAtzz+YbrOZ45n2fnyjGDmMxNA3VYDoyA3ERmsfQ/D/xBibMcXTaRy?= =?us-ascii?Q?hUHvAYRtVk/Btji+6RDT9lLwr2nKWsA/oyMcFzEy3+Rgf3/HYPzKSdIsB+Wh?= =?us-ascii?Q?OC4424Z36f1tSQnI6T0vKNPp5zHrfey+StjmMyWGODxtDnJQjkVYN9MYNlI1?= =?us-ascii?Q?CxtLUIBFklCZl9SIe++kO+8rTQZAnwK4HDb/rOmH7g4ulesJWRVpzQV+4ljb?= =?us-ascii?Q?1qcF6yPuJA=3D=3D?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60df1c87-8165-4db6-9d66-08df062202af X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 23:05:25.5387 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e6a32402-7d7b-4830-9a2b-76945bbbcb57 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 13IXyykOofZ1zwnur6t0ftTNiiNYBWAvysb9KPuWOZsIMU2cAP9JPbIcHa/d+lqJP10fPTu08CG4XmH++yESkQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWYP123MB9008 Content-Type: text/plain; charset="utf-8" When a concurrency-managed per-CPU work item runs continuously without sleeping for longer than wq_cpu_intensive_thresh_us, wq_worker_tick() marks the worker as WORKER_CPU_INTENSIVE and kicks it out of concurrency management so that pending work items on the pool are not starved. While CONFIG_WQ_CPU_INTENSIVE_REPORT logs rate-limited warnings and pwq->stats[PWQ_STAT_CPU_INTENSIVE] maintains a cumulative counter, there is currently no tracepoint emitted at the moment of this transition. Therefore, add the workqueue_cpu_intensive tracepoint, recording the work_struct pointer and callback function pointer, workqueue name, executing CPU, and the runtime duration consumed in microseconds. This enables eBPF profilers, bpftrace, and Ftrace to immediately detect and attribute CPU-hogging work items in real time. Signed-off-by: Aaron Tomlin --- include/trace/events/workqueue.h | 39 ++++++++++++++++++++++++++++++++ kernel/workqueue.c | 9 ++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/include/trace/events/workqueue.h b/include/trace/events/workqu= eue.h index b0de2bc9ed52..ef0f3a4b73a8 100644 --- a/include/trace/events/workqueue.h +++ b/include/trace/events/workqueue.h @@ -126,6 +126,45 @@ TRACE_EVENT(workqueue_execute_end, TP_printk("work struct %p: function %ps", __entry->work, __entry->functio= n) ); =20 +/** + * workqueue_cpu_intensive - called when a work item exceeds cpu_intensive= threshold + * @pwq: pointer to struct pool_workqueue + * @work: pointer to struct work_struct + * @function: pointer to worker function + * @duration_us: CPU time consumed in microseconds + * + * This event occurs when a concurrency-managed work item runs for longer + * than wq_cpu_intensive_thresh_us without sleeping and is excluded from + * concurrency management to prevent stalling other work items. + */ +TRACE_EVENT(workqueue_cpu_intensive, + + TP_PROTO(struct pool_workqueue *pwq, struct work_struct *work, + work_func_t function, u64 duration_us), + + TP_ARGS(pwq, work, function, duration_us), + + TP_STRUCT__entry( + __field( void *, work ) + __field( void *, function ) + __string( workqueue, pwq->wq->name ) + __field( int, cpu ) + __field( u64, duration_us ) + ), + + TP_fast_assign( + __entry->work =3D work; + __entry->function =3D function; + __assign_str(workqueue); + __entry->cpu =3D pwq->pool->cpu; + __entry->duration_us =3D duration_us; + ), + + TP_printk("work struct=3D%p function=3D%ps workqueue=3D%s cpu=3D%d durati= on_us=3D%llu", + __entry->work, __entry->function, __get_str(workqueue), + __entry->cpu, __entry->duration_us) +); + #endif /* _TRACE_WORKQUEUE_H */ =20 /* This part must be outside protection */ diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 3c034cbc5bb3..6ee644155b82 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1532,6 +1532,7 @@ void wq_worker_tick(struct task_struct *task) struct worker *worker =3D kthread_data(task); struct pool_workqueue *pwq =3D worker->current_pwq; struct worker_pool *pool =3D worker->pool; + u64 dur; =20 if (!pwq) return; @@ -1557,9 +1558,10 @@ void wq_worker_tick(struct task_struct *task) * double decrements. The task is releasing the CPU anyway. Let's skip. * We probably want to make this prettier in the future. */ + dur =3D (READ_ONCE(worker->task->se.sum_exec_runtime) - worker->current_a= t) / + NSEC_PER_USEC; if ((worker->flags & WORKER_NOT_RUNNING) || READ_ONCE(worker->sleeping) || - READ_ONCE(worker->task->se.sum_exec_runtime) - worker->current_at < - wq_cpu_intensive_thresh_us * NSEC_PER_USEC) + dur < wq_cpu_intensive_thresh_us) return; =20 raw_spin_lock(&pool->lock); @@ -1572,6 +1574,9 @@ void wq_worker_tick(struct task_struct *task) pwq->stats[PWQ_STAT_CM_WAKEUP]++; =20 raw_spin_unlock(&pool->lock); + + trace_workqueue_cpu_intensive(pwq, worker->current_work, + worker->current_func, dur); } =20 /** --=20 2.55.0 From nobody Sat Sep 26 21:12:47 2026 Received: from LO2P265CU024.outbound.protection.outlook.com (mail-uksouthazon11021113.outbound.protection.outlook.com [52.101.95.113]) (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 2C00D437448; Sat, 29 Aug 2026 23:05:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.95.113 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788044732; cv=fail; b=A9Bs9qvgBiZtkiCLLPn9hbKBADCmRmp+hh6eZKZNpNr8MxPklSutph/iulelaaa9DN8PuLivYm+t2jnSNKbJ25WX3f2nnMW09ZVwG/c/lnISLxep5Pub5o3JDUkmsmqbSX0gu90CN3gRGTNTopQhBs0lt8exWnRXOHvJ7JqxDww= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788044732; c=relaxed/simple; bh=zddBvMQBCSVhPaMGDET8Z6JCF8m6G5eMjzXjbDNPRLM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=ReWwkPdX9mlariqMgYSogEULhll7fkTyESi4qsW/7KPmwnaDH1jb4UDxcR5ZEkOkkvP/M6QmqugXxZoqqK2Zn3Lva5oah24wr0hvPIkI34VjWvO6y6H+vAHM2k5EiirDzNh0mhA1s3u/XvdSx46MtCbms1AUi7LEjgUxHzG3hUk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com; spf=pass smtp.mailfrom=atomlin.com; arc=fail smtp.client-ip=52.101.95.113 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atomlin.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fgiNGuiAe5JAZOenoCYpb3+woVIeTFQHNnWzwZxmk8xr68lmBvSEa4sI9NnRihipK5O3nklL/tzQd6bUP8qJctGI6r0CATddowAL8mYr3whwCPyW2Opa53LSaG3v+vtIxhSJO+Q70PrMatYvODbP7OEeH8f9iAVqFuFKJqmpUvLovu1uHCAuv6Q0pQlK9BFHQ7xaKY8fz4A5hE6j3natjYZ0ki9BgL1DhjMhC3GWkECtPjDll2qNEDvmZPO6DP3r/x6DhrKrD3mj5QSiM2/25l4Tc63oL07Nhb6ZnG3sa8UiIYVndewN3qIG+I5WKnIBUqnIBjYKRyIvGU4pXF1tzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:MIME-Version; bh=L8xm2tL5NuuQRIsBY4MHChqgqO4ZLhZlZXMQtcUJ424=; b=LyUoLC9DFRGQHdKHxcTMIj3SmIlJ/LDfNMpP62lqfv/Z1IJqsAkWxlh+LOrbZGjB7k43Y+w6u0utcFjAP0j5jJvaH6q/Pm3QUUBviNJpp63Xe7agszUHfIIdJ/XhThfzlfl7tzQWMFlWNRV5vE3Igxci8f8iBZAfbULwrwvzL597f5zXnxlfHM5CvFsDAC8eBVGWetaaE531WGTa79whugqxx+F/jHHvi0XR2PtBENrLw6ep3b8kVf5s5/7Wzfbn2sSFDXz1NycViECxbzSuOubop+0qegUImKVU6nsGdWujUl8fm89Xlu2RNa3Q5fBmoAqJEFS+nWIhiQI5NbIuqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=atomlin.com; dmarc=pass action=none header.from=atomlin.com; dkim=pass header.d=atomlin.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=atomlin.com; Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) by CWYP123MB9008.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:288::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.13; Sat, 29 Aug 2026 23:05:29 +0000 Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230]) by CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 23:05:29 +0000 From: Aaron Tomlin To: tj@kernel.org Cc: jianshanlai@mail.com, rostedt@goodmis.org, mhiramat@kernel.org, osandov@osandov.com, atomlin@atomlin.com, neelx@suse.com, sean@ashe.io, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH 2/3] workqueue: Add workqueue_mayday and workqueue_rescued tracepoints Date: Sat, 29 Aug 2026 19:05:16 -0400 Message-ID: <20260829230517.42468-3-atomlin@atomlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829230517.42468-1-atomlin@atomlin.com> References: <20260829230517.42468-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0461.namprd03.prod.outlook.com (2603:10b6:408:139::16) To CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLP123MB6607:EE_|CWYP123MB9008:EE_ X-MS-Office365-Filtering-Correlation-Id: d7e98a29-559f-42cd-3575-08df062204d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|23010399003|366016|1800799024|10067099003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: h2UrXfp6TIgnH/P8a1KnbIA9dMylgpuM+SWnOvh+GeeMDl0iIIl3ZzT9Y2beZs1KP6fF7teLA7HN2oTSxG0doY9zU2etLrlmXW7ZejWyOi0IHdF3CCp3reizF3ESFNfJYIEKbMfaccom68NAXnAX/YT/sVpOv6whNYTdB7orkgb7EmonnQot0iVchLy/rOvnjRTGBkelCEYDcwYdPcJA7Zxh8rtfzNoPFquBW7mZ5dT5ecNvXsVmT9KybdGpcGXHYGlQVV1Tn3mOddL1LEZ3vgYmVxXkKSlFnutcwuVO+AFqPYsR0WR4NEu96OskI6fnO4dq0FF0JYTcgLMdsRdbWGwBj+vsV3s6m36NJJ0JeupPfvQavtrf/PxYmrGK1lnHUwX06+5Y2MrpgSBKCOBo5zWX5FbuMLK1CFRLf9ej5BiFd69RVrGbQ2dG8zB/yFo+n7Qp94gkndGI69EtbwwkZRps5vgL7qoYgG63laj9fcXv/doQmew1Xl2qWKZIVEsuxjqdaLCu3cTjimOCb5fz4K4rIB3u0Ne80VtoiQwMhIhWlClWG+Pa4qyrZ5PW5fkQIB1LBTFYU3UL8AhdKoMa1sURHewiscJgxhhEPiBrunXXTH1iwrChNMWyqhNxKlyepHqIEkM09832CRzGtWYcVaXybhyHUGvxk9wMC1v/LBI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(23010399003)(366016)(1800799024)(10067099003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?VXOnB0yT6xuotdSdEXFPhpXW2dU4ZyLsMd9svUwhF0sbe1fqO44t5c0pZSCY?= =?us-ascii?Q?0v/xRU8s1WhaFQMCUZok6GsVvWzuWpiaO0BMyvNTgYzXYKkTrWz8Z5w5yGbH?= =?us-ascii?Q?vk0ghH/DCLWtpB7rX9if+KtFmUDdCb6rgPTZz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9pbWFbmRRO+KSrJ6f//z+xiUoiKdr5s9WV9aNXpcbmRZwgrWceE9GJ8Vp?= =?us-ascii?Q?c4rNjyA9GnTX0yCcbClglORaO5jVG547R2v2z9llCZHvEIByey7ZW3eZMQaA?= =?us-ascii?Q?UeG4gkIb6+iMGMevXZDT8Z9dOjoZR0aRSfZphyS8YACLdlqjpAzAX1UK2EPu?= =?us-ascii?Q?+F5uhBDkw/hWCNTRQK/ZPXfF68kwg6julBu9/tYHm73GBpunVJ+r6pWvzTpB?= =?us-ascii?Q?OZg8lLh4zej5609QFVIp1O56vpZmEDkpKu0N0hFuZE2+SAUBx5LaXSqNw93A?= =?us-ascii?Q?UMaliUxiCJHnIeIIMByFrJzaAsCgHKHu4+hixinisB1OAh75WjSmDIyDYlGp?= =?us-ascii?Q?PC+e/fp4GsNRFG13hSu47fkv7OWubDBeNL7/AfAcGf8/FZaORGW/87UW3eQN?= =?us-ascii?Q?51SB/NqeP3RuLSfyHzcQ1vOZJbuJSqIrxjZjKC2lBDLMveZ/6AYRyQHj9mUm?= =?us-ascii?Q?zxxsyy3A9N5N36i/QiXtCOmxNzJwwtpwFQJhJ0YoAS+CwaR4K0FLW04lG/dQ?= =?us-ascii?Q?1+HF8i6a7P2fhZg8X8B8YZtkgFBN2zEYpp5gprw/w9KEZqcZ/jjcZ2+dasv3?= =?us-ascii?Q?UnUx+HVrqF7QNTpSz39aRt/d73jctFiLGAz7QMtJc3km4pkCxX47e/Ea4q6U?= =?us-ascii?Q?R1OmtMsB8wh7iYKy7NM0DaBnldhEgwvJ6aokoKuljwge6DeJ6QokxbEzrZ+4?= =?us-ascii?Q?cPLh6/sHnw=3D=3D?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7e98a29-559f-42cd-3575-08df062204d4 X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 23:05:29.1289 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e6a32402-7d7b-4830-9a2b-76945bbbcb57 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MX6byvM+p3kg49RgBJnlJxWWoRkY4IbGH7/1dHUD5Nk/cJRrEGZngf1H+F35c/5V5C6JMuo9BbRcMvwcRuS4Hw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWYP123MB9008 Content-Type: text/plain; charset="utf-8" When a worker pool fails to create a new worker thread within MAYDAY_INTERVAL (e.g., typically under severe memory pressure where memory reclaim paths depend on pending work items), send_mayday() signals distress to the workqueue's rescuer thread. The rescuer then takes over processing the pending work items via assign_rescuer_work(). While pwq->stats[PWQ_STAT_MAYDAY] and pwq->stats[PWQ_STAT_RESCUED] track these occurrences cumulatively, there is currently no event-driven mechanism to observe exactly when mayday distress occurs or which work items require rescue. Add two new tracepoints namely workqueue_mayday and workqueue_rescued to make distress and rescuer execution easily observable (e.g., via Ftrace or eBPF). Signed-off-by: Aaron Tomlin --- include/trace/events/workqueue.h | 68 ++++++++++++++++++++++++++++++++ kernel/workqueue.c | 2 + 2 files changed, 70 insertions(+) diff --git a/include/trace/events/workqueue.h b/include/trace/events/workqu= eue.h index ef0f3a4b73a8..013cfa472f6d 100644 --- a/include/trace/events/workqueue.h +++ b/include/trace/events/workqueue.h @@ -165,6 +165,74 @@ TRACE_EVENT(workqueue_cpu_intensive, __entry->cpu, __entry->duration_us) ); =20 +/** + * workqueue_mayday - called when a pool_workqueue sends mayday to rescuer + * @pwq: pointer to struct pool_workqueue + * + * This event occurs when a worker pool fails to create a new worker + * within MAYDAY_INTERVAL and requests the workqueue's rescuer thread to + * process pending works. + */ +TRACE_EVENT(workqueue_mayday, + + TP_PROTO(struct pool_workqueue *pwq), + + TP_ARGS(pwq), + + TP_STRUCT__entry( + __string( workqueue, pwq->wq->name ) + __field( int, pool_id ) + __field( int, cpu ) + __field( int, nr_active ) + ), + + TP_fast_assign( + __assign_str(workqueue); + __entry->pool_id =3D pwq->pool->id; + __entry->cpu =3D pwq->pool->cpu; + __entry->nr_active =3D pwq->nr_active; + ), + + TP_printk("workqueue=3D%s pool_id=3D%d cpu=3D%d nr_active=3D%d", + __get_str(workqueue), __entry->pool_id, __entry->cpu, + __entry->nr_active) +); + +/** + * workqueue_rescued - called when a work item is assigned to a rescuer + * @pwq: pointer to struct pool_workqueue + * @work: pointer to struct work_struct + * @function: pointer to worker function + * + * This event occurs when a work item is claimed by a rescuer thread + * to guarantee forward progress. + */ +TRACE_EVENT(workqueue_rescued, + + TP_PROTO(struct pool_workqueue *pwq, struct work_struct *work, + work_func_t function), + + TP_ARGS(pwq, work, function), + + TP_STRUCT__entry( + __field( void *, work ) + __field( void *, function ) + __string( workqueue, pwq->wq->name ) + __field( int, cpu ) + ), + + TP_fast_assign( + __entry->work =3D work; + __entry->function =3D function; + __assign_str(workqueue); + __entry->cpu =3D pwq->pool->cpu; + ), + + TP_printk("work struct=3D%p function=3D%ps workqueue=3D%s cpu=3D%d", + __entry->work, __entry->function, __get_str(workqueue), + __entry->cpu) +); + #endif /* _TRACE_WORKQUEUE_H */ =20 /* This part must be outside protection */ diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 6ee644155b82..6f6fe2068389 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -3122,6 +3122,7 @@ static void send_mayday(struct pool_workqueue *pwq) list_add_tail(&pwq->mayday_node, &wq->maydays); wake_up_process(wq->rescuer->task); pwq->stats[PWQ_STAT_MAYDAY]++; + trace_workqueue_mayday(pwq); } } =20 @@ -3619,6 +3620,7 @@ static bool assign_rescuer_work(struct pool_workqueue= *pwq, struct worker *rescu list_for_each_entry_safe_from(work, n, &pool->worklist, entry) { if (get_work_pwq(work) =3D=3D pwq && assign_work(work, rescuer, &n)) { pwq->stats[PWQ_STAT_RESCUED]++; + trace_workqueue_rescued(pwq, work, work->func); /* put the cursor for next search */ list_move_tail(&cursor->entry, &n->entry); return true; --=20 2.55.0 From nobody Sat Sep 26 21:12:47 2026 Received: from LO3P265CU004.outbound.protection.outlook.com (mail-uksouthazon11020081.outbound.protection.outlook.com [52.101.196.81]) (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 AE64B418368; Sat, 29 Aug 2026 23:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.196.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788044736; cv=fail; b=rpfybyRmkr2ubgrmCq1ZrHNnMYN+mh8NHyPWBgdv9g27m6y/DfajS3jGT0BVd9jpcbgaIiscGaVbc9HQDr3voI4opivFMqAJd+HsUjvheNHR0vUPWx+KZe1c/z69S5+Yz6g3qe4BqvkMTe9CtlkR+MiyOw1uKp/0RJySX1qCUjU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788044736; c=relaxed/simple; bh=NaPyIlHx8ghcGwJtZOAq6uPO6PcQVLGOEkVa48QNvoY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=qtZoAe4OrZ7doTmZYknrHnByjjJdnHUjCx9mHd+ddo4AZpJvNPeRMgB2/PwmiNJEGcXG+Ul5jqMeu933trhb8TF2354mOT5loGwRWtdiV/5XYIGSBw+TdACB1OBC+n/1vIVXhQWPbXaJ/AAerSn0FnP0jWIfBsgrpmRyilZ8lmQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com; spf=pass smtp.mailfrom=atomlin.com; arc=fail smtp.client-ip=52.101.196.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atomlin.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=R5Yz8JaYnMTXHeElTALvZFEda9CD41/oVQHgChRh1yVqpHo876CrUcF71FH2H9+HJkDJF49suapLP2963on/Irk//u9rzbCybx/5p6lpiSP+klo+/z/yyX4IFHys5iElgRCo2s187hic42n/wBA738OHeNQti52HIZwhZAKh0H27xWGU8u7U6d0TsK28h8kNs+vIUxLQJGyAziwbEvm4L2oULxjwnAAZU4dL5UN+TuWdJHxVh2incCDgo5oNGrsqzBb8ziOOS6IwICAr+4WrmLErokX5uTheAYsoKE58mCdOSQuumK5kF1qh6AJIwcx4vOIy8Lx1rPmCmiQLqQwwRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:MIME-Version; bh=PuAZnavNyxaJG6TXExzJNZfyM2o8Afuwwsk1CGR47rs=; b=Y5qqGaremD7QgtDeA0DVtdzlu5ZPVSGcb97la9o/xNtzW6w/1k4DVkCZvgWGrFGqAiXyTlBfnLcFYYzYlwtOZrbltDuaqKmsGW/cEh3ovdBTf0r6qS8Sv5CyV++pVOlk7mQDUV2Z1bsSjn9bGRu/R7OJK90Mlp4PPxl0oLfxy2uncEN6XkSHAnhkkozpc84GFFeECVfAkTRJKFeDigks8bIXOj8XRA+sPccG0YhzqsONgGjRxrNiNxRrT0OSZNgXlSiPGth5x1JgtDd8pnJ3O/RzO5CTkParqUpZZUOTOaEXCTVNpSZV/KM68xTTVaYYadz6am7oD7TWYipY1lKPeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=atomlin.com; dmarc=pass action=none header.from=atomlin.com; dkim=pass header.d=atomlin.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=atomlin.com; Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) by CWYP123MB9008.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:288::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.13; Sat, 29 Aug 2026 23:05:32 +0000 Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230]) by CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230%4]) with mapi id 15.21.0360.008; Sat, 29 Aug 2026 23:05:32 +0000 From: Aaron Tomlin To: tj@kernel.org Cc: jianshanlai@mail.com, rostedt@goodmis.org, mhiramat@kernel.org, osandov@osandov.com, atomlin@atomlin.com, neelx@suse.com, sean@ashe.io, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH 3/3] workqueue: Add workqueue_bh_budget_yield tracepoint Date: Sat, 29 Aug 2026 19:05:17 -0400 Message-ID: <20260829230517.42468-4-atomlin@atomlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829230517.42468-1-atomlin@atomlin.com> References: <20260829230517.42468-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN0PR07CA0024.namprd07.prod.outlook.com (2603:10b6:408:141::33) To CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLP123MB6607:EE_|CWYP123MB9008:EE_ X-MS-Office365-Filtering-Correlation-Id: 8251c154-a7c6-45bb-a925-08df062206a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|23010399003|366016|1800799024|10067099003|56012099006|6133799003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: cZj0lL9VUhsrnG0tZU91LOkaau0Dh9758HHJSKOEB1UUSNIrj35QmX58A3sZ9uQN5FP8pbxtjdeQ5dHTNxYfivpwv547KWedipRQIukYokZmHT0e0WmO+2Myr2MqmhO3iI3FrghwauRRuqgzTv7WLIdbNb6IdwSIhTjVDu4O+NtHJ9k/FcT4zELiaeHEouOJC/9RFmhiM3ng1IkYB2FDApnJwPSEtsEzh9uwwoDCHFs3wK+dQQmich9degeMF1FJpw2AlzjtNrn6CgJ993DR2b7VJbl0Uhl84mTks2+3oHkmU7boWxVkPSn+YGKzr4tDv2V74uunoXqToyhgqc0HVBZv9ffOPt/DHgVKzck1wzqGC5jHocccobJI8jLbYSfTQst9DP9RIMRWELpWrDkfaQ5EUsNpNWCURGb+vGz/qMd/UG+5bpQM90H+9IXfv1QENRF/bUFy8RqteNtANExnSDOWsk7A08kp4OeWqMRSsk2Cu8UYjR9Bsk3qDKhbj8wkak31dZ3tcyINl3vofmjFzU6eFL4f6dJ02WXYQ6jg8fvsSi+uX9cExmVZbj4Ml+c7hCGGNh1CyYeOOgSFRfd1L5TyJ1Y0HsxG4q/49i+Pso8vkbKwqoUGawot090aa0sQRhABNQ7Bzipc6upzXjaPRFasbuQAoXyj9x4Ghb25HJE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(23010399003)(366016)(1800799024)(10067099003)(56012099006)(6133799003)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?0prC23BrIWvVumgXOnJvtbQ3vK8YSJrWiuj+mZtpAT5gad1IYbR8wd+9GlnE?= =?us-ascii?Q?h8IcX8Avgvoam64PxDjwt00GCIEo5rIVLUscvckLmbNkXhOAEMFdE/ch9hM+?= =?us-ascii?Q?6Jx+9ew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L9rj?= =?us-ascii?Q?AjDlefSUOeNDwF9gYbv5352LR2gPLWaEJSv0DZymfwvpKtVjwRRiVLlXQnVl?= =?us-ascii?Q?J3PBBysQkNjANQ7N7f296pJanmDqwgz+t943yhlcjAJE5RKbf4NmJxttEa0e?= =?us-ascii?Q?2iWWFWjCmks6EdM9uufQXmf8/jnZD+QPGphJPqY6p7eYyoYhF01iJDM2uj1T?= =?us-ascii?Q?vd6aBDDc4rcJx9+Bbj8ldL/0Bx/MymbklckbbPoyVUfwEaa1bVDf7nEvtwQ1?= =?us-ascii?Q?7aBZCyHUXyN22Ba6wtsENHDZg3NaFqn4oHjqD728Lh0g/ZVcwEkrrFeiXlx1?= =?us-ascii?Q?6Oxi5G9KOJHFsvQwvoG8h3nj7+HWMpupznaw+W7/VXm0k00ahpLQupcUgmu2?= =?us-ascii?Q?+yY4jcbwqJTYHwf1HTRkhCIn02sHLz0Ka3jwHfcwonkLQN2JWJmIHn1HVeaK?= =?us-ascii?Q?5HAdwfXhaRV/aLILXX/ebBPWw5AwfJKNE9DJ7pKpk8JHD7urys8E4xUcoRgs?= =?us-ascii?Q?BcCv577j/EHKFm0vNF5IvhVv1YCVduSZaFQK+p7gfNrJtsDGBrdgm71N3eVh?= =?us-ascii?Q?3UL/rGkdYMIbCqgTQhnuZFh5FMR3skZCPTpuCh95JX3c17d3teRKU5Nu9re7?= =?us-ascii?Q?Vt6jIxKWF7jPFgQu+gvLcUqDviXCgSyBZohdWEBag5DTmh1r84V2u2gGhExp?= =?us-ascii?Q?T8A5BHcRedklSkuK2nMRI7OCVVPjNNBkGm5XmjqfpkoZ2LtEoNXJKNtx7NWc?= =?us-ascii?Q?5TLy6IHiag=3D=3D?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8251c154-a7c6-45bb-a925-08df062206a9 X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2026 23:05:32.3047 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e6a32402-7d7b-4830-9a2b-76945bbbcb57 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: b21xi/5/CgUq6mqQh3Offt/s/LN/E77bHD//TTJNHW/KTshEeN3z9dajdIYrc0y/9p0hwy7BUv2QXr7vrw9Z/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWYP123MB9008 Content-Type: text/plain; charset="utf-8" Bottom-Half (BH) workqueues execute work items in softirq context. To prevent softirqs from starving user and kernel threads, bh_worker() enforces execution limits (i.e., BH_WORKER_JIFFIES and BH_WORKER_RESTARTS). When keep_working() is still true but either the time slice or restart count is exhausted, bh_worker() yields execution and re-raises the softirq via kick_bh_pool(). Currently, there is no observability into when a BH worker hits these limits and is forced to yield. Add the workqueue_bh_budget_yield tracepoint, emitted when bh_worker() exits the processing loop with pending work items remaining. It records, the worker pool ID, executing CPU, number of loop restarts consumed, a boolean flag indicating whether the yield was due to a time slice timeout, and a boolean flag indicating whether this is a high-priority BH pool. Signed-off-by: Aaron Tomlin --- include/trace/events/workqueue.h | 39 ++++++++++++++++++++++++++++++++ kernel/workqueue.c | 13 +++++++++++ 2 files changed, 52 insertions(+) diff --git a/include/trace/events/workqueue.h b/include/trace/events/workqu= eue.h index 013cfa472f6d..ad1d0ff1a96d 100644 --- a/include/trace/events/workqueue.h +++ b/include/trace/events/workqueue.h @@ -9,6 +9,7 @@ #include =20 struct pool_workqueue; +struct worker_pool; =20 /** * workqueue_queue_work - called when a work gets queued @@ -233,6 +234,44 @@ TRACE_EVENT(workqueue_rescued, __entry->cpu) ); =20 +/** + * workqueue_bh_budget_yield - called when a BH worker yields due to budge= t exhaustion + * @pool: pointer to struct worker_pool + * @restarts: number of restarts executed + * @timeout: whether execution hit the time limit (BH_WORKER_JIFFIES) + * @highpri: whether this is a high-priority BH pool + * + * This event occurs when a bottom-half (BH) worker pool running in softirq + * context exhausts its execution time slice or restart limit and must yie= ld + * execution. + */ +TRACE_EVENT(workqueue_bh_budget_yield, + + TP_PROTO(struct worker_pool *pool, int restarts, bool timeout, bool highp= ri), + + TP_ARGS(pool, restarts, timeout, highpri), + + TP_STRUCT__entry( + __field( int, pool_id ) + __field( int, cpu ) + __field( int, restarts ) + __field( bool, timeout ) + __field( bool, highpri ) + ), + + TP_fast_assign( + __entry->pool_id =3D pool->id; + __entry->cpu =3D pool->cpu; + __entry->restarts =3D restarts; + __entry->timeout =3D timeout; + __entry->highpri =3D highpri; + ), + + TP_printk("pool_id=3D%d cpu=3D%d restarts=3D%d timeout=3D%d highpri=3D%d", + __entry->pool_id, __entry->cpu, __entry->restarts, + __entry->timeout, __entry->highpri) +); + #endif /* _TRACE_WORKQUEUE_H */ =20 /* This part must be outside protection */ diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 6f6fe2068389..1c25df68f7ae 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -3756,6 +3756,9 @@ static void bh_worker(struct worker *worker) struct worker_pool *pool =3D worker->pool; int nr_restarts =3D BH_WORKER_RESTARTS; unsigned long end =3D jiffies + BH_WORKER_JIFFIES; + bool budget_exhausted =3D false; + bool timeout =3D false; + int executed_restarts =3D 0; =20 worker_lock_callback(pool); raw_spin_lock_irq(&pool->lock); @@ -3781,12 +3784,22 @@ static void bh_worker(struct worker *worker) } while (keep_working(pool) && --nr_restarts && time_before(jiffies, end)); =20 + if (keep_working(pool)) { + budget_exhausted =3D true; + timeout =3D !time_before(jiffies, end); + executed_restarts =3D BH_WORKER_RESTARTS - nr_restarts; + } + worker_set_flags(worker, WORKER_PREP); done: worker_enter_idle(worker); kick_pool(pool); raw_spin_unlock_irq(&pool->lock); worker_unlock_callback(pool); + + if (budget_exhausted) + trace_workqueue_bh_budget_yield(pool, executed_restarts, timeout, + pool->attrs->nice =3D=3D HIGHPRI_NICE_LEVEL); } =20 /* --=20 2.55.0