Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1570136rdb; Mon, 19 Feb 2024 23:22:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWFJEmnzbdtpLdboFIZ4DjNg1Z9UFC3ixtavNcHMWocDPo07z5GKm/0arXvMB53z6wkS1wfW5u3dpXUfwb/26S9LnxEW9ui9msFw1VDpw== X-Google-Smtp-Source: AGHT+IHpxGTiXhswVipwg1JDyAE0yVylaLPJIUfPN+OQQTOktYVqWwnXG9HTyISerFgX0dU9tYbV X-Received: by 2002:a05:6a00:d51:b0:6e3:6d4b:118e with SMTP id n17-20020a056a000d5100b006e36d4b118emr5468351pfv.3.1708413768126; Mon, 19 Feb 2024 23:22:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708413768; cv=pass; d=google.com; s=arc-20160816; b=Ub2gNiJ8pp4CYCwWtCk/eKNmXKAOS/Ieyw+qAv/rx6ZKuEFWm89266CzDSk41O8srm aoxRwHHvDkEgrN8FUCWPysfodi8OK2XN8azQGQs9h5mPeVDax6c5Bwy2y5pI0xI/0sSL tJAI8yoAG31t1s1sxccmf8/KRv5ZSrUpGPcGiABXQQGsu2Lce1PeloVvkmiY+bDLYwvD 6k3em9WMRTZA7QrCJ9UZDXZKz0KiMgfx6A+G3DiCrdYVFvsmKUvMtgomyuiTkmzZB2n1 7tqHcp3bwpU4lDEj7qeRiO3Fmj48i4fz0e9+mQU3w/h6uF2+/VNwpxEgcaTI6v7XcyON 0SyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Wxod4qrRSfYk+sPpZkKiGMAWRb398s7OUCfWg5ArY5k=; fh=LBsnBmC14036mVwFlaYKzn8DQUGPl9OzqBZGvMvHMyY=; b=xPqdCLegPYSHNw9a99Id634P4w5Iu+WYbE3vd0LS3aUqj/fDKowPnDJ41UsKkJn8zu boZWxl3i0X/DWsufKOEPeHZ94W2HnhhXZPcmpuIT1iJvJCAt8WjFu/LOSvFIzjNh67Bp Xiq2M84bWmjH2lWm5aY6GIYfGWj1P+4OYya1jHSjPC8t/W4ZSEEiT+ULwiLuq0axadTU KmWrcjUnpvdYLmOvo+SQnD3kp3RBAbQK0FY9poO4Fv+RmsHXOSReUGJjZythF5iAOXFL lEKYG0SYTDBRMCU3jRb5Bo07Vc5ho8SH5lqbjoa6IW6ASUq6h5HF3eVCIXblqg428Fb+ Yf0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SLmjuL5s; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-72464-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72464-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e26-20020a63745a000000b005d8c1b5a3bdsi5741992pgn.216.2024.02.19.23.22.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 23:22:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72464-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SLmjuL5s; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-72464-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72464-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D23AE28393B for ; Tue, 20 Feb 2024 07:22:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A47265A4D5; Tue, 20 Feb 2024 07:22:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SLmjuL5s" Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85FD41E484 for ; Tue, 20 Feb 2024 07:22:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708413759; cv=none; b=njBUow1AslFhDk8yqvCpPjkxD93FePz4nrPQ5syHBB2jxY/DedNhtsamQVv4mMKGC1cNY8/tcj3nZLz/sghUElKElRoiIku/djXn++ANir/p2RS0/Y02R+xK0bp+qbWQm1HYh2gHGnqtvgkobkXdnykVCPLwHEeZ4CCF33lqrtQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708413759; c=relaxed/simple; bh=b222vclvkob3NRCk9QxpOicxtpPvY4cxVAORXbafAEg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=QtWNDAmAXbRcgaj3KqBAvrzvnGsg30PXCKvhpo6XQfEfjAhNZBGClbdAguo4H5E0wRWUuzd5KMnyV6uEfhIS7toCzdjBqemDTG18XaemFDj6Nuyp3neAMxj/IZ+O8in9HdzWycttROwpGUqBWV/ekw9r8lXG0xiznDcOjp0khzQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SLmjuL5s; arc=none smtp.client-ip=209.85.215.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-5ce2aada130so4557232a12.1 for ; Mon, 19 Feb 2024 23:22:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708413758; x=1709018558; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Wxod4qrRSfYk+sPpZkKiGMAWRb398s7OUCfWg5ArY5k=; b=SLmjuL5s4aUgrq66gwjJDH/zfi6Rs3yjoU0XbfnOxoaE+KsQnT9Uh589yDPG+2pHbV 7J3mwm+c0KkjWv41a6krON5NrCa2FLMMNXHDyNpvSqkhMNxYmxMH/BcI0jCX/XsL8E/w OHQISKWJTHaBw0W46hwVjs1p5zgQkk4sQGqqE7pclo0XFBNLaFTMLUoqB1rIo/6KrzCL 9WuM5W7wlRYeZIto09LdY3aaSNJxyZs44A3ftdiytTrq9u+Tpe7ayeFtZTvNU3KFMo8G iroUZ+XsTbHRBN3rvSvHi0m/5u0OJ38/BXpuE5egFfJTrUz5l0r6Z6AH4e84bE0D5/hj FoDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708413758; x=1709018558; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wxod4qrRSfYk+sPpZkKiGMAWRb398s7OUCfWg5ArY5k=; b=B3LPWU3iOdbGIQxTq6k1IQfMtBBt5g1PFgcVzPoQMM6PkLafjqTHNpphsXirOcyHaX II62MbTDsrBP5qKr0C8BgR50y2YHz5oBXoUP7RTH2eEagEB1FA893Y8gugOGt+7tA8Fg 95EYrNNADB/GmGFR25B/hP5IutrgNxpEuwWaa4F8xLlgc4gVx6/fVuY2G8aIAVD9HEbU zKBLKIlCi+5bH6N7ju0tDtmxxFGtcfPJrIGEm1QqSfy5CU61xE1wx7WacHD3VuWGf2FV 9ZKzlWMY+h8zVdRrY+PBHIAWVK5ZWjPg/Bnoaqylk5GoC33rNW76FKuGe4HSrYADCSqV KZqw== X-Forwarded-Encrypted: i=1; AJvYcCXYnLmhuTvYGa7Vsb14TwzElloiPQFmWMyz51HWLfE4KPweG7HpCyxJEbnhFwfGOR2wKds+nQdKofBDCj2RcwcduBGYHmEfWMcViwgR X-Gm-Message-State: AOJu0YwJAR6RYQFxcZQ/AOZ/mASnqAC57vHpEdnsyzegKF9MoW/wjyOv DJVQgXmK950xzA+d3p6zdGyuWFmKq1ovWpjd1qlm6L/sFIcKbKl13/uarhzsgRDyUnKMCr2QTJA XJq7V0TWUPVm47FHM9df8utCVSg4= X-Received: by 2002:a05:6a20:9f43:b0:1a0:a61d:1230 with SMTP id ml3-20020a056a209f4300b001a0a61d1230mr5005465pzb.23.1708413757633; Mon, 19 Feb 2024 23:22:37 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240216180559.208276-1-tj@kernel.org> <20240216180559.208276-13-tj@kernel.org> In-Reply-To: <20240216180559.208276-13-tj@kernel.org> From: Lai Jiangshan Date: Tue, 20 Feb 2024 15:22:26 +0800 Message-ID: Subject: Re: [PATCH 12/17] workqueue: Implement disable/enable for (delayed) work items To: Tejun Heo Cc: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, allen.lkml@gmail.com, kernel-team@meta.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, Tejun On Sat, Feb 17, 2024 at 2:06=E2=80=AFAM Tejun Heo wrote: > - A work item carries 10bit disable count in work->data while not queued. > The access to the count is synchronized by the PENDING bit like all oth= er > parts of work->data. It is 16bit disable count in the code. > @@ -2417,7 +2437,8 @@ bool queue_work_on(int cpu, struct workqueue_struct= *wq, > > local_irq_save(irq_flags); > > - if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(wor= k))) { > + if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(wor= k)) && > + !clear_pending_if_disabled(work)) { > __queue_work(cpu, wq, work); > ret =3D true; > } > @@ -2577,7 +2598,8 @@ bool queue_delayed_work_on(int cpu, struct workqueu= e_struct *wq, > /* read the comment in __queue_work() */ > local_irq_save(irq_flags); > > - if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(wor= k))) { > + if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(wor= k)) && > + !clear_pending_if_disabled(work)) { > __queue_delayed_work(cpu, wq, dwork, delay); > ret =3D true; > } It misses the same handling at queue_work_node() and queue_rcu_work(). But it is bad idea to cancel or disable rcu work since it can be possibly in the rcu's waiting list. > @@ -4173,20 +4195,46 @@ bool flush_rcu_work(struct rcu_work *rwork) > } > EXPORT_SYMBOL(flush_rcu_work); > Thanks Lai