From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.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 61C73306B3D for ; Fri, 14 Nov 2025 09:45:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763113502; cv=none; b=EKi8WYZCV5JJ7LOZchTbAREwNzxT1+PaOXKbG4Mq+POsLmZFtW7b1Kll3iFa/5BKpEAzje+f4C1Afbbqy+qefWRH4WefS83m81CxmGSgAsGbDUi148RHhXF1T7TpOoQV33w/NBabGpJFSlmnr9DZ3zYhrfQQaxIZ8nrljgQnJX0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763113502; c=relaxed/simple; bh=MhYK7Fuz8aLrEJJ0z/jtlvxFHm7ZZ8CTilRTglRw6P8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=JAU4KyPsKzgT2evn1r/Q33Naew0xdm+Oo+Vp0nTVQ1KNiRBiB8Uzom9+yZdGcW7VkBWQtweLkYNKUUIyVHVmlorptGvI380+lk8S7s5H/LmR7sGuywNJZX8yHO38/kbInCwHHeDQ5Oh74fRgdVXVhVXbp2U6rXB+SqamqPrbwYg= 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=N9k/K66o; arc=none smtp.client-ip=209.85.218.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="N9k/K66o" Received: by mail-ej1-f74.google.com with SMTP id a640c23a62f3a-b72a8546d73so194453566b.2 for ; Fri, 14 Nov 2025 01:45:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763113499; x=1763718299; 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=pRD00tHeY5cdf7KxqF2jFSxDwoUN5Uum1eEhmcMbeuQ=; b=N9k/K66o9ZcyUiNw00ole+6xoSPKqaV8OIWAna4qT2kZvSiywR3MVDUR91TklagDfb X1pxRhLQ4lPhXv7Lc8uiRKGNgTkHOfVNpCCJdCJvdv5jp6BtAMxWiFH13pk7iL456PUX SGlZ8vAs2NFLUuHg/pVn7KplTcsHm54wTevjWi2GB5gHCJi1DH6NjnAdBl8uRLH0lT6o W2tRBmfc/mSH52F19vcWNsJzKN2iKr8qBiyZZVL5ONb/zh8W8LpmrCEE/PZKTx/T4xW2 V8W+XfRqaJzZkP8kqCiNgiGxj8x0BZFpGtEWUShKa42ZjzG2XF61KvZiuXDyJsjdU9ZP dMCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763113499; x=1763718299; 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=pRD00tHeY5cdf7KxqF2jFSxDwoUN5Uum1eEhmcMbeuQ=; b=S1CAHAXc3JxN9GZ3CE73Y9PRHRpQ/jCRK14Zmw6t3OXw2KT4NzuSO+X76/GEfocvMV lXabpuYEaQwACY5Xj95+YSNd7IBC7y2XfuwH9dOM5Q1NN9WdRppFu/hSesToRxn4ipHj lVS6mnU8m236Xq+wTGvnMHfmW8YP3Zcv4oOibsIQmFl+aARBiCv0h0cIcBnw2QpnTNLf B06ZtzCsjVeXsV7xlFtNCvM6HkZqqbyJsNhreK5ntwKAX2VPuLSVn/1QhuqK3eNeTURI L7ORWIWKH2DzJkwy8Z1EIehrNneJ1oyJoggfMVIdqu1iWzGWRijtEMeIlbuKsuNHTDPE sGvA== X-Forwarded-Encrypted: i=1; AJvYcCUOvn5OS73EuOXxUjLNnk0H/IYt09EvhYrWx7qB+1MmFU+tJuDwTmzq3/Be7xq+P0Hz4j9zh+nXFq7Ba9w=@vger.kernel.org X-Gm-Message-State: AOJu0YxBsIOz6brCBsNA9wg8WrtDxEqKuczTk+mLf/LZgpLxLEWkMFnM E2bqtY9L68al8P62VOScDUTcfd0LraRSrxb35N06NSMPAypXnBFkZ/QxG55zJPh1yEEq4bKbxkU gfhzZL3lNQqO5GItAaA== X-Google-Smtp-Source: AGHT+IEm8jwzq/nQACHWX8CpZkS7ky+thx5qIyqMsvn0Ki/rLJllXcmU6Vivtx+WwowP4czjWd+5pLWgDIUZ7Ts= X-Received: from ejcwe12.prod.google.com ([2002:a17:907:d64c:b0:b73:3b0d:754d]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:3e24:b0:b6d:5840:4b43 with SMTP id a640c23a62f3a-b73678969aamr250627866b.22.1763113497809; Fri, 14 Nov 2025 01:44:57 -0800 (PST) Date: Fri, 14 Nov 2025 09:44: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: <20251113-create-workqueue-v2-0-8b45277119bc@google.com> <20251113-create-workqueue-v2-2-8b45277119bc@google.com> Message-ID: Subject: Re: [PATCH v2 2/2] rust: workqueue: add creation of workqueues From: Alice Ryhl To: Boqun Feng Cc: Tejun Heo , Miguel Ojeda , Lai Jiangshan , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Daniel Almeida , John Hubbard , Philipp Stanner , Tamir Duberstein , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Benno Lossin Content-Type: text/plain; charset="utf-8" On Thu, Nov 13, 2025 at 11:52:17AM -0800, Boqun Feng wrote: > On Thu, Nov 13, 2025 at 10:01:07AM +0000, Alice Ryhl wrote: > > Creating workqueues is needed by various GPU drivers. Not only does it > > give you better control over execution, it also allows devices to ensure > > that all tasks have exited before the device is unbound (or similar) by > > running the workqueue destructor. > > > > A wrapper type Flags is provided for workqueue flags. It allows you to > > build any valid flag combination, while using a type-level marker for > > whether WQ_BH is used to prevent invalid flag combinations. The Flags wrapper > > also forces you to explicitly pick one of percpu, unbound, or bh. > > > > Signed-off-by: Alice Ryhl > [...] > > +/// An owned kernel work queue. > > +/// > > +/// Dropping a workqueue blocks on all pending work. > > +/// > > +/// # Invariants > > +/// > > +/// `queue` points at a valid workqueue that is owned by this `OwnedQueue`. > > +pub struct OwnedQueue { > > + queue: NonNull, > > I hope Owned/Ownable can make it just a Owned here ;-) And > that'll make Owned automatically Send + Sync. I think it's not a > rare ask for `OwnedQueue` to be Send + Sync. Oh yeah it should be Send/Sync. And hopefully we get Owned eventually. > > +} > > + > > +#[expect(clippy::manual_c_str_literals)] > > +impl OwnedQueue { > > + /// Allocates a new workqueue. > > + /// > > + /// The provided name is used verbatim as the workqueue name. > > + /// > > + /// # Examples > > + /// > > + /// ``` > > + /// use kernel::c_str; > > + /// use kernel::workqueue::{OwnedQueue, Flags}; > > + /// > > + /// let wq = OwnedQueue::new(c_str!("my-wq"), Flags::unbound().sysfs(), 0)?; > > + /// wq.try_spawn( > > + /// GFP_KERNEL, > > + /// || pr_warn!("Printing from my-wq"), > > + /// )?; > > + /// # Ok::<(), Error>(()) > > + /// ``` > > + #[inline] > > + pub fn new( > > + name: &CStr, > > + flags: Flags, > > + max_active: usize, > > Do we need to support `max_active` as `usize` when the underlying C > code only support i32? Negative values don't really make sense. But maybe it's a good idea, yeah. Alice