From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (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 9E0DC3D3D14 for ; Fri, 27 Feb 2026 19:19:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772220003; cv=none; b=j8HIDA0xLcWu882+yAdhnBgC/SmpyDVfvBRlKLNtD1bBPAUEuSarxLoiIgnfq1CVygWHwKAojgyzYNiijdryrMwTWTyiRZjQ/lzQ6CZFKkK+kVQGS1t7XHFPpsjmkJaoISkFU1enrReRwmSFvR459R2+/9zsTXlotQpn+WGc0cA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772220003; c=relaxed/simple; bh=L8FJABVHFHSCFveVLUCxW+JYK5AyBjBR4VFqAhgVR9I=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=iNR47lObuPP/VoCM26o/RpLE9dkFhPcEzrBKkcirvfHXTjJHBhnu+7LGDMOR3xQMisHdIuq+297X0wjEe7PnXNQnBFTxggeEDRYXUanNrYZQFNZSxeSo5VupWYEQl+DDi4BHSlCGrYFBehWJHKvCrL/Dkc85R0g+s3BoTEJ3pTI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Cl7d0obZ; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Cl7d0obZ" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4836b7c302fso24015095e9.1 for ; Fri, 27 Feb 2026 11:19:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772219998; x=1772824798; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WBgwzx0zzY1/PqSKldnWCeFUNyWLZOQM8NUJjdzdoSI=; b=Cl7d0obZjC+dnlEIxVUSlNuNlspjAbPahotYuolNpPMY6pDbh7/lWFcprc0eWp/r8u /Dkosoiz9/Mfk6qX6nhW+1wJITTpY1zTu1phiCH5XIs8An+Q4aM13jpBYr8/kj6HS6pa xZz1hF3Q1eEtF+7I4hmPG6f0TZ5XGVxdCUck5OCkDS03yTNJCzXQG3dtf20ATm6Kaqkz +zXuWHe5i701/RF8BU2ANKTPw9SnfjiLDClHu7KiPGOmV7hz9AR71H7fLdBUqcvMmHT7 n37mNe9BD+b2kadx5onopL+R6lFlEsKhWYMRCm9o1M7tt+/XIlQ8+dK3OjHorzxSaBIJ UGjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772219998; x=1772824798; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WBgwzx0zzY1/PqSKldnWCeFUNyWLZOQM8NUJjdzdoSI=; b=vSmXlvS6EjrrXf04L530ytnfdW3tSJSgEMJ3eqGBtYyQ7S3ActeK3AYngc2Qnlw+AV HYdX6nBVEgIh++Rfd+dmJ9s3Lf9EQDp5quK+8RUlqf/ogYCYITFHP7QfTrxA1lZfNZnq sMwv6PmTwmpjCJN7U3uZIkAjPSv/rjOq+C6bD0lGe0K6t0gF81H/wldbM9S+Cj8JB2eR 8RgmXpLSm4rgCSsdAsw3isqz60yIEuCAZbcErbK79GJbFIrphswy3qt9VE2+T89rXs29 My/oYO1f82H2iiEI8bKHeYSlOydhCIoTGN9w5BlTtGdQ++dbWVh899q4t02SxtJ4ytF7 IqKQ== X-Forwarded-Encrypted: i=1; AJvYcCWuoe+voOeZoBGBhLYJb0dK8x4KIfN/L70gwY9gdTQxE+FFIx47b0c0rNJOGY3COV0gslazWHp2mYdQEFA=@vger.kernel.org X-Gm-Message-State: AOJu0Ywfkz0kIZEg0gcnz8Vb6jvp2pvu6CfmNdYeIIRiDqon4f4U7w2I xX0P6axpHh4oqDo+7p4edFAKPhXRqVaQvIcO2HH8o+/OFKTCPW8n8su5IzZrYI52n6cKAIWNfSa YSRT+8zKYVnsoC13KXQ== X-Received: from wmqd21.prod.google.com ([2002:a05:600c:34d5:b0:480:4a03:7b64]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1d0e:b0:480:3bba:1cac with SMTP id 5b1f17b1804b1-483c9bc55c0mr59327825e9.6.1772219997631; Fri, 27 Feb 2026 11:19:57 -0800 (PST) Date: Fri, 27 Feb 2026 19:19:56 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260227-create-workqueue-v3-0-87de133f7849@google.com> <20260227-create-workqueue-v3-1-87de133f7849@google.com> Message-ID: Subject: Re: [PATCH v3 1/2] rust: workqueue: restrict delayed work to global wqs From: Alice Ryhl To: Tejun Heo Cc: Miguel Ojeda , Lai Jiangshan , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Daniel Almeida , John Hubbard , Philipp Stanner , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Boqun Feng , Benno Lossin , Tamir Duberstein , stable@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Fri, Feb 27, 2026 at 09:08:55AM -1000, Tejun Heo wrote: > On Fri, Feb 27, 2026 at 07:01:18PM +0000, Alice Ryhl wrote: > > On Fri, Feb 27, 2026 at 07:09:07AM -1000, Tejun Heo wrote: > > > On Fri, Feb 27, 2026 at 02:53:20PM +0000, Alice Ryhl wrote: > > > > When a workqueue is shut down, delayed work that is pending but not > > > > scheduled does not get properly cleaned up, so it's not safe to use > > > > `enqueue_delayed` on a workqueue that might be destroyed. To fix this, > > > > restricted `enqueue_delayed` to static queues. > > > > > > C being C, we've been just chalking this up as "user error", but please feel > > > free to add per-workqueue percpu ref for pending delayed work items if > > > that'd help. That shouldn't be noticeably expensive and should help > > > straighten this out for rust hopefully. > > > > I had been thinking I would pick up this patch again: > > https://lore.kernel.org/all/20250423-destroy-workqueue-flush-v1-1-3d74820780a5@google.com/ > > > > but it sounds like you're suggesting a different solution? > > I'm not remembering much context at this point, but if it *could* work, > percpu refcnt counting the number of delayed work items would be cheaper. > Again, I could easily be forgetting why we didn't do that in the first > place. I guess the question is, what does destroy_workqueue() do? - Does it wait for the timers to finish? - Does it immediately run the delayed works? - Does it exit without waiting for timers? It sounds like the refcount approach is the last solution, where destroy_workqueue() just exits without waiting for timers, but then keeping the workqueue alive until the timers elapse. The main concern I can see is that this means that delayed work can run after destroy_workqueue() is called. That may be a problem if destroy_workqueue() is used to guard module unload (or device unbind). Alice