Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7812464rwd; Tue, 6 Jun 2023 17:13:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ObH1K8vEIV0Ijo70PLaWLqap9ZX4oOhU6tFN9aI4ivoukXEZG0FAI/l2lEVvVol/fYNYr X-Received: by 2002:aca:1908:0:b0:39c:464f:a55f with SMTP id l8-20020aca1908000000b0039c464fa55fmr3752544oii.24.1686096831122; Tue, 06 Jun 2023 17:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686096831; cv=none; d=google.com; s=arc-20160816; b=VH+n9/G9i5KQY1QSRSDmvBZx+hS8ZTLVSVLlYkjazfF9ZaCukLvMrchA8bQfBkb3ly LHF92sz/rs1aXkgWYoRoTjo7Cb/6IfZMOCCeEU2woxsi3m8x5h/6np51PVPkbh/sYVP/ ctaq5bjxfY/giXjuVBHcCF/JhZGqXhcoMt8ZvDnn0tL9Zx/mgYnT0YvhSz9qwSkx/WOk OW66BwA7Cg26rZB/m1YILneDtHJVB8mLh6TYHsvBbY+naW03NPAzGhKLyndhjTw9RTLD io6F6+hcAxPJFnWjD8xxCcADCr69W+gNTubXJ9Lg1TjplKE8lI1oD2q8bC8l41naXxT+ x3PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature; bh=HFhBhTIzREHG9mACtwO9tRyPWU+4u6gN6/PkdzEJpag=; b=dpytJLObf7aJWHuUZCKkHaT740fF0sZpPTDsHiilMtbmW60aDDdpxvv+J+IWux0p9X qkThSNOQLElXH7Z6AYg17lFtwt7DFuawYJXwVqlA5WgIhFHQaz1M0w1lQp/kQD/BD0vX +Y/8dWZ7IIAyI4VZK/sqbzt3Qxs2gWSg1zXTZwPRWP5ixh8IqzRA35kUoNPqlPNp7JG/ iTFq7JSHa6De+PIXYvr+1Dk5Nv7tYRwi8RTJZNW29sK8TIi66pc492Gs99n8UogfXOGq S6DpyvN6+B5d/j6Xx0r57GNz5I5wUyxnLMvr8kfbGYGxptCQMZHOU8lqTaK6jMfi2+Ae l09Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=d77x79Ns; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s19-20020a639253000000b0051f74e18927si8037207pgn.184.2023.06.06.17.13.37; Tue, 06 Jun 2023 17:13:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=d77x79Ns; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240161AbjFFXiA (ORCPT + 99 others); Tue, 6 Jun 2023 19:38:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234511AbjFFXh7 (ORCPT ); Tue, 6 Jun 2023 19:37:59 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B2621711; Tue, 6 Jun 2023 16:37:58 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-75ec7e8e826so175384985a.0; Tue, 06 Jun 2023 16:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686094677; x=1688686677; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=HFhBhTIzREHG9mACtwO9tRyPWU+4u6gN6/PkdzEJpag=; b=d77x79NsgBLTq06/VgrnLBA18mMJknfbUXrr8BhhI2XbWKK0dzqJBz6jeI7vB0upeP sKwQNSh6Ps6CqjjxsGRgsfbkakooZs+V8GFZeNf+gQZoXksuHxbOAMllHpf3iHEl2IO/ v8CqEY99D46jjyyS/1VWxIVoy6EW71uRClKKED/q7v/oQW6RYgbvP5hSfO+QbCqKArzU z0T7B4ArSaaqShjjCTPYTH/MNa07lYUkmSqhytjrsm1nCkwcuyH/u5Wd09149+JvnF94 iRrkB4GTqzmhX4P1k8KifMiD2Cg8sGLoaL3sUdX97vzG/IgtSCwGB0ZNa/MklTZaLICg EbKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686094677; x=1688686677; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HFhBhTIzREHG9mACtwO9tRyPWU+4u6gN6/PkdzEJpag=; b=EMe1Ugxs6QW16M6h26wUYQDRDR1JeHNUV7zodTo3TMcm3kjXJ3AOhH+4M7JS2vV4wL Ank3qqZJo8IQ9uthBQyGJ+3gqtfo/LHv6iWRvWYuhxssPiFr5gvHZxP+SS3uZ1dWas+J W09aKDCdAi6W5S+u0kigRRC4Y9TVfMHkE3HO9jb8Rw3tZJwDDcYCFEa5eEpT0q+gFnS2 UUFmE/AbsTG8N990AZMS9yxBjOMs7qdnXbeylTFApGa7N5q2ZG05JYbU0RlJqY75ZWvT Xk62M++B+0MX9XbZcfrL0JEDBF8CUhiH9YyBNwdGgEW8UJIHdmFQs+RjQQv88RzZc2TN YDlw== X-Gm-Message-State: AC+VfDzdfK4foN5H+lq+VeSejWM4/ySxB+hzKKid1c/jurp8f27vTfq8 qouGbR9k4CdStBxyd1mY8pI= X-Received: by 2002:a05:620a:2221:b0:75b:23a1:367f with SMTP id n1-20020a05620a222100b0075b23a1367fmr137834qkh.64.1686094677149; Tue, 06 Jun 2023 16:37:57 -0700 (PDT) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id m10-20020ae9f20a000000b0075772c756e0sm5237129qkg.101.2023.06.06.16.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 16:37:56 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailauth.nyi.internal (Postfix) with ESMTP id 1970A27C0054; Tue, 6 Jun 2023 19:37:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 06 Jun 2023 19:37:56 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgedtvddgvdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhu nhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrg htthgvrhhnpeehudfgudffffetuedtvdehueevledvhfelleeivedtgeeuhfegueeviedu ffeivdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdei gedqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfih igmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 6 Jun 2023 19:37:54 -0400 (EDT) Date: Tue, 6 Jun 2023 16:36:30 -0700 From: Boqun Feng To: Alice Ryhl Cc: rust-for-linux@vger.kernel.org, Miguel Ojeda , Wedson Almeida Filho , Tejun Heo , Lai Jiangshan , Alex Gaynor , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: Re: [PATCH v2 1/8] rust: workqueue: add low-level workqueue bindings Message-ID: References: <20230601134946.3887870-1-aliceryhl@google.com> <20230601134946.3887870-2-aliceryhl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230601134946.3887870-2-aliceryhl@google.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 01, 2023 at 01:49:39PM +0000, Alice Ryhl wrote: [...] > +/// A raw work item. > +/// > +/// This is the low-level trait that is designed for being as general as possible. > +/// > +/// The `ID` parameter to this trait exists so that a single type can provide multiple > +/// implementations of this trait. For example, if a struct has multiple `work_struct` fields, then > +/// you will implement this trait once for each field, using a different id for each field. The > +/// actual value of the id is not important as long as you use different ids for different fields > +/// of the same struct. (Fields of different structs need not use different ids.) > +/// > +/// Note that the id is used only to select the right method to call during compilation. It wont be > +/// part of the final executable. > +/// > +/// # Safety > +/// > +/// Implementers must ensure that any pointers passed to a `queue_work_on` closure by `__enqueue` > +/// remain valid for the duration specified in the documentation for `__enqueue`. ^ better to say "the #Guarantees section in the documentation for `__enqueue`"? Regards, Boqun > +pub unsafe trait RawWorkItem { > + /// The return type of [`Queue::enqueue`]. > + type EnqueueOutput; > + > + /// Enqueues this work item on a queue using the provided `queue_work_on` method. > + /// > + /// # Guarantees > + /// > + /// If this method calls the provided closure, then the raw pointer is guaranteed to point at a > + /// valid `work_struct` for the duration of the call to the closure. If the closure returns > + /// true, then it is further guaranteed that the pointer remains valid until someone calls the > + /// function pointer stored in the `work_struct`. > + /// > + /// # Safety > + /// > + /// The provided closure may only return `false` if the `work_struct` is already in a workqueue. > + /// > + /// If the work item type is annotated with any lifetimes, then you must not call the function > + /// pointer after any such lifetime expires. (Never calling the function pointer is okay.) > + /// > + /// If the work item type is not [`Send`], then the function pointer must be called on the same > + /// thread as the call to `__enqueue`. > + unsafe fn __enqueue(self, queue_work_on: F) -> Self::EnqueueOutput > + where > + F: FnOnce(*mut bindings::work_struct) -> bool; > +} > -- > 2.41.0.rc0.172.g3f132b7071-goog >