From nobody Sun Feb 8 04:12:40 2026 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 17A622040B6 for ; Thu, 9 Jan 2025 10:18:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736417929; cv=none; b=u7Ai8BbWGqOCuU7RQfSgWQA9bGB0UitCZnLqeZTYok6mcyL7Fd9GjzgWHMrxvzN4H+E+KFevF6Zyu9/RAQycRPR6U46iKg701ICnUBcyhpu8c3pt6T3vZGDci163/g3GCzAVLzJhWl3zra6xy2TJMruEUuEe5a6+1rPINJ2VfDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736417929; c=relaxed/simple; bh=Su8XzgCYbA1sFSntZ1m32FhxpGDeB8MP958tJz1aqF8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=cPbLfnqzt8pBbU9OU2TCW77mhUMItND0F5cftIttPpaminup/bqLILroF+A6cIDevdUXMw8whGYTt6Zd8hLZ3357sEgRrwYmKUm7QFLJlZ+2NxtaSGfD+JEG3IN9JRZWcuEa9Vs62o8S5EPkn0kESR+/uGsQt81dSreU3aOF+3w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=CDL0PmYw; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="CDL0PmYw" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5098ljkf026448; Thu, 9 Jan 2025 10:18:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=corp-2023-11-20; bh=iThnypqfCBZ0RemxbdaLdj/dlUfDd T2sKr5jXoC4gtI=; b=CDL0PmYwQQlmS7UbJ8PCyQAFMNWOEqX92Du45qR8Z7FrG QyBYcydi0vnFeZo95jyvTBwba9Nrmqvo9A3SRTb1hrtaUokzu6kxLQR1AlaTqfXo zX5niWZryGFEgqihgI0C7wKvhOipOdLrq+iL90HS9p8qaF3+7ng9TvmET1se8yye NWzsiGeR7b+/xu2NDvZlZTAXbNh2qDK61OpKs9k0PsZTELuSa0/KBVZmwMdXkMMT QzJ7Pd3N0naVqvI2JL+UNAMY4ZE2oUdjjr+WXbo4JiYq9eaTXusMlIP+sFXIxZ5+ h8Dh7gudn7wdQQ7GKJQEmPgJzhEjsF19wJfYes76Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 442b8ug4pm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Jan 2025 10:18:39 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 509AHuIP008568; Thu, 9 Jan 2025 10:18:38 GMT Received: from localhost.localdomain (dhcp-10-191-134-226.vpn.oracle.com [10.191.134.226]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 43xuearekg-1; Thu, 09 Jan 2025 10:18:37 +0000 From: Imran Khan To: tj@kernel.org, jiangshanlai@gmail.com Cc: linux-kernel@vger.kernel.org Subject: [PATCH] workqueue: warn if delayed_work is queued to an offlined cpu. Date: Thu, 9 Jan 2025 21:18:29 +1100 Message-Id: <20250109101829.2026320-1-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_04,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501090083 X-Proofpoint-ORIG-GUID: 1ER-XRiB-HdegHcWLeSYLot4LT79aGp8 X-Proofpoint-GUID: 1ER-XRiB-HdegHcWLeSYLot4LT79aGp8 Content-Type: text/plain; charset="utf-8" delayed_work submitted to an offlined cpu, will not get executed, after the specified delay if the cpu remains offline. If the cpu never comes online the work will never get executed. checking for online cpu in __queue_delayed_work, does not sound like a good idea because to do this reliably we need hotplug lock and since work may be submitted from atomic contexts, we would have to use cpus_read_trylock. But if trylock fails we would queue the work on any cpu and this may not be optimal because our intended cpu might still be online. Putting a WARN_ON for an already offlined cpu, will indicate users of queue_delayed_work_on, if they are (wrongly) trying to queue delayed_work on offlined cpu. Signed-off-by: Imran Khan --- kernel/workqueue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 8e0bb3c608239..10878b5e3d74f 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -2508,6 +2508,7 @@ static void __queue_delayed_work(int cpu, struct work= queue_struct *wq, return; } =20 + WARN_ON(cpu !=3D WORK_CPU_UNBOUND && !cpu_online(cpu)); dwork->wq =3D wq; dwork->cpu =3D cpu; timer->expires =3D jiffies + delay; base-commit: 6ecd20965bdc21b265a0671ccf36d9ad8043f5ab --=20 2.34.1