From nobody Sun May 10 06:27:47 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 79244259482 for ; Mon, 30 Dec 2024 06:45:21 +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=1735541123; cv=none; b=i70HoWzr72vn4aODEXm+FEKshwCIpdZcNamo92bYe+iQ2zeeRETIqkl2VXC1I/vvM6HB5a0MF09w7MKLMeUDgygxjx5rte9eMV/1b8ZurffLoiQuUHtTONsYrKaMov7b3QuyUBExMnW0cD30Dytie2OleSkTI1NH8bfjOBFYVkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735541123; c=relaxed/simple; bh=N+H1dz3sYI0adYl6uFx6N+FNgYzOWACqJN/04bNDu3A=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=YzmGC5GvDd338bDJ+5vSDN+tOtkLB9Un16KClRF/aZGLToAl8Xr0PgIuXEz/TCAd7zHfG4mPN1VeCpId9bCiVaX/85sNtWRILtgRAGEk82G7IyDeepECCBaHKEfCk16bBAGAfO8bpzP6QT9rOZ2r3DB5nXFSb9p2gfmXRfDtUYk= 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=k45fw1aG; 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="k45fw1aG" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BU1vJHX017059; Mon, 30 Dec 2024 06:45:06 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=dPB7B9l/nMOu8vL9J8N4wpJvVi7jZ vQjy7Nhf4Juzoc=; b=k45fw1aGNlOgVFAuM9XcH8lTwpBimhGrC1VqUlZuBfRln myMQ/ALHcNc2wR9SlwnCvpFr7pxLKXjzZ5pGjqX14FyZ2Ge0peF+4zif/lP1jPjc ky3sDmBvKUHeDGRrI1EpHGcMJbg4gnCBSNjbXXa6Jt7/HT1fDBYTjVQiZZ1AHRgs 4rwsCC/8sAFLg/sn+zlLsDeMZXxZJJ2eSuozkeeld9beyveM3omwZ3I5AP799xAS 5P67EzKC2PgZvMnRYnfst3JwQbDjKb1cqQOTG3eKArVgiIcRFyYKr+CmjB97X7LP ugW48ScULPfwN4lYPZABZdx4BLPmk66PlsuDatGWA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t7x01q3k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Dec 2024 06:45:06 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4BU45JT4008475; Mon, 30 Dec 2024 06:45:05 GMT Received: from localhost.localdomain (dhcp-10-191-131-253.vpn.oracle.com [10.191.131.253]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 43t7s6ev8f-1; Mon, 30 Dec 2024 06:45:05 +0000 From: Imran Khan To: tj@kernel.org, jiangshanlai@gmail.com Cc: linux-kernel@vger.kernel.org Subject: [RFC PATCH] workqueue: introduce WORK_STRUCT_TIMER_PENDING_BIT. Date: Mon, 30 Dec 2024 17:45:00 +1100 Message-Id: <20241230064500.1404206-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=2024-12-30_02,2024-12-24_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412300056 X-Proofpoint-ORIG-GUID: QalrsbbmBc3u9t-VeqWsR3j5_lypDjzE X-Proofpoint-GUID: QalrsbbmBc3u9t-VeqWsR3j5_lypDjzE Content-Type: text/plain; charset="utf-8" Currently WORK_STRUCT_PENDING_BIT can indicate a work_struct that is already made it to work list of a worker_pool or a work_struct that has not yet made it there because it comes from a delayed_work whose timer has not expired yet. Use WORK_STRUCT_TIMER_PENDING_BIT to distinguish between these two states of work_struct. Signed-off-by: Imran Khan --- I have kept the patch as RFC, because this change is not fixing a bug. It makes WORK_STRUCT_PENDING_BIT less ambiguous and helps in debugging, by indicating where one should look for this pending work. include/linux/workqueue.h | 1 + kernel/workqueue.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index b0dc957c3e560..2d327d9e9b53a 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -27,6 +27,7 @@ enum work_bits { WORK_STRUCT_INACTIVE_BIT, /* work item is inactive */ WORK_STRUCT_PWQ_BIT, /* data points to pwq */ WORK_STRUCT_LINKED_BIT, /* next work is linked to this one */ + WORK_STRUCT_TIMER_PENDING_BIT, /* timer pending for delayed work */ #ifdef CONFIG_DEBUG_OBJECTS_WORK WORK_STRUCT_STATIC_BIT, /* static initializer (debugobjects) */ #endif diff --git a/kernel/workqueue.c b/kernel/workqueue.c index eb71e3d9d16dd..454382a9a1585 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -2481,6 +2481,7 @@ void delayed_work_timer_fn(struct timer_list *t) { struct delayed_work *dwork =3D from_timer(dwork, t, timer); =20 + clear_bit(WORK_STRUCT_TIMER_PENDING_BIT, work_data_bits(&dwork->work)); /* should have been called from irqsafe timer with irq already off */ __queue_work(dwork->cpu, dwork->wq, &dwork->work); } @@ -2511,6 +2512,7 @@ static void __queue_delayed_work(int cpu, struct work= queue_struct *wq, dwork->wq =3D wq; dwork->cpu =3D cpu; timer->expires =3D jiffies + delay; + set_bit(WORK_STRUCT_TIMER_PENDING_BIT, work_data_bits(work)); =20 if (housekeeping_enabled(HK_TYPE_TIMER)) { /* If the current cpu is a housekeeping cpu, use it. */ base-commit: 8155b4ef3466f0e289e8fcc9e6e62f3f4dceeac2 --=20 2.34.1