From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 06857351C2C for ; Sat, 14 Mar 2026 10:30:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773484216; cv=none; b=FLm7+sHW13a2kH/v9ViLCQtXCAEHEPs0QycIDdAXYS3BIseY2ftxGf1HUsA80dIZV/Q8Q+c0FMCw7oKSvYvR0nWflFiE9xaQw79O9ybz3ccirtdDbNkcXDTQcVqy/fmmKclUh1XgGRq9cAa0uMzmAmU3/fSf44z0UBq78HaC8k4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773484216; c=relaxed/simple; bh=8DtpPy2fbrgtP41hYwzlKoJDUNpXQ3ebnMBUKZf7vCc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=plDO4ZMOzeaeVusXyhedL+yFIdnVTPRK4zyBiOFd5ishHejzHk/CQBikw/0v65d7fV10iJYCGHr29vq8Xw+YI5Uwx0nxm4QN/e4KrSmxnz09KNXguTEr2lDZtTVTfo8bBaRE3LTWoqkN398OdEvofev4dKvjhuIZwoOARglsFjU= 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=JzsqZi6c; arc=none smtp.client-ip=209.85.128.73 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="JzsqZi6c" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4836abfc742so20572465e9.0 for ; Sat, 14 Mar 2026 03:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773484213; x=1774089013; 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=+aMSG1gcK9FHZhc0qN6MOUQSRC1xXIxb6LZWIpdkT2o=; b=JzsqZi6cdoLs7qcbYMgR0Yk5pGx1JKCqYJAtc7P/MRtNWG1J0jAUQ/D7qgSQY7ZVnt I33wNflfO6U6Akz0k85S+QY0ObT6GsPpVWf7PfSmEBV83m+l7VKndJOhXMHJihc3lMCw kOPK3wu2auABM3QtBY2Hd1PnEJEigpOWGCKTUCpaw4/IhVme8nLgGD+TJyyfXr4S5uGg 9Ab6HaI3T3ml+xfEasHHv8A/sKlsNnVK5310kDhRV1iSLhw68CtyNCLtInaqqw6OnvBp dMSCxXrjkbLFO78kzAnQtRq8lKZJIICQqsVksQP4BU/arHMWqZ29lj2vS9qjtSkpEIq1 2vSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773484213; x=1774089013; 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=+aMSG1gcK9FHZhc0qN6MOUQSRC1xXIxb6LZWIpdkT2o=; b=OtR2wQrVTBaXBRIPDhlgcfVgZ6g3xTPHVTSEXn2O3I9prS4xr2jK59Q+mVAwbz0iVm 29S+pbMqB/TN2mhM5PXnVF5dEghIjSBUvsxFPDPfrCoogK/7HIywC451F4rHG+P43L4b wRRkvAusjUTKk6C9EDyzwxBftP4sH3P9HGe3PI72jC1Bcj1M5TN5uD1SzFZeav+nxPB2 BQXjX1KJaIuMMhal+9eBjpccEeSqom5H3AMg9RGEqOssCgiV16VJo4XLqVhlmzljl52Z JtzE9BBooM1AKr50taBKf8V163iqbgMwWoszNkb5yfyew46Oh3hs02/hLDF2MRe65uM1 K3ZQ== X-Forwarded-Encrypted: i=1; AJvYcCXsSzuWUDKUX+blsnUr0yinJr9gYbGmXamnDj8dB+UmEgDxQbZpoXBy9pIEER5BVmSV0tfpZmmy/9Dv7ac=@vger.kernel.org X-Gm-Message-State: AOJu0YwnVyUFumJF2TDLD0GBHtEuIswDDaLjD+YV4DgPuopk71s9ECuA jAHXzwtYBEvertR6vr0Yj9MiJk4Af4LKnzc8SqAXB9gv7JGr6cwO1X6MMGUEjR5lbrlG44snFjn OzBJJc9ZBeLyBAsg0hQ== X-Received: from wmwz15-n2.prod.google.com ([2002:a05:600d:640f:20b0:483:b1c6:5b34]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:8b45:b0:485:39d1:b4dd with SMTP id 5b1f17b1804b1-485566d1ff7mr100520715e9.10.1773484213001; Sat, 14 Mar 2026 03:30:13 -0700 (PDT) Date: Sat, 14 Mar 2026 10:30:09 +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: <20260312-create-workqueue-v4-0-ea39c351c38f@google.com> <20260312-create-workqueue-v4-3-ea39c351c38f@google.com> Message-ID: Subject: Re: [PATCH v4 3/3] rust: workqueue: add creation of workqueues From: Alice Ryhl To: Danilo Krummrich Cc: Tejun Heo , Miguel Ojeda , Lai Jiangshan , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Andreas Hindborg , Trevor Gross , Daniel Almeida , John Hubbard , Philipp Stanner , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Boqun Feng , Benno Lossin , Tamir Duberstein Content-Type: text/plain; charset="utf-8" On Thu, Mar 12, 2026 at 06:59:31PM +0100, Danilo Krummrich wrote: > On Thu Mar 12, 2026 at 10:23 AM CET, Alice Ryhl wrote: > > +impl Queue { > > + /// Build a workqueue whose work may execute on any cpu. > > + /// > > + /// # Examples > > + /// > > + /// ``` > > + /// use kernel::workqueue::Queue; > > + /// > > + /// let wq = Queue::new_unbound().build(c"my-wq")?; > > + /// wq.try_spawn(GFP_KERNEL, || pr_info!("Hello from unbound wq"))?; > > + /// # Ok::<(), Error>(()) > > + /// ``` > > + #[inline] > > + #[doc(alias = "WQ_UNBOUND")] > > + pub fn new_unbound() -> Builder { > > Wouldn't it be more straight forward if those where constructors of Builder? > > let wq = wq::Builder::new_unbound().build(c"my-wq")?; Crates out there do both, but I actually like this pattern quite a lot. After all, given 'wq::Builder::new_unbound()' and 'Queue::new_unbound()' I think the latter is the one that makes it more clear that you are building a 'Queue'. Also, it avoids an extra import. > Queue::new_unbound() suggests that it returns a new Queue object, but instead it > returns a new Builder object. I'm only really concerned about confusion if it falls into one of these categories: * You write the wrong code, it compiles, and silently does the wrong thing. * You read the code, and misunderstand what it does. I don't think this falls into either of those cases. If you forget the .build() call, all you get is a compiler error, and it's not hard to figure out what to do when you see the error. Alice