Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp32699lqe; Tue, 26 Mar 2024 19:17:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9Yl5qk5tSD6InAgMFpKyqoKjxoBMjO6Cmvw1SUwmFPVbupXIlNTxzhPS3RPCodd/5oU1iUJqrrM84n+b6YsJMwmwV2aLW96aQaCOAOQ== X-Google-Smtp-Source: AGHT+IE+C0d+wk2W4+BtRkMnPFpMBTRXsiG/iOuFwV+LKFKlDOpjVeV7dAdBKzbSejbgKFx9EUtW X-Received: by 2002:a25:a009:0:b0:dcf:2cfe:c82e with SMTP id x9-20020a25a009000000b00dcf2cfec82emr4159477ybh.55.1711505873201; Tue, 26 Mar 2024 19:17:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711505873; cv=pass; d=google.com; s=arc-20160816; b=wPq0BItYu1yEWb4ZWH4pPoqXvQZXJlvuN8sl1dILFqGxYPttldltOoq5TWr8EQex1F Y1TVIl10/PpeehWWakAt1Xaf9D87cDj/DXkk5bYOndwx+qLXx9oi1WHKWJgKE42NN8op 7ZTaMh63BTmOPTjRGuJi5OZkoHtxFVN4jOcWwUlZMpY7sZAoa3Fo0KcQbr/7lfsHCN8u Z51T1mx6Jf7jex189Mh0HcDG7XC3Vgw8iCmR/9/HSqVYwHOhs3xx7DApenF7xdt9dWdo Xx7fb7WCWObwKm1c3wF4gQr9bKjqBAc43wt0vryZ55oEsBz68Cn5mEcbqMKMuJK5StBt VQMQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=e/ONsFU9nxQvS8X3SSqcN2WZie/AcsRGqQejcrWJvLg=; fh=3R8nAphtJHD6oLGtpTI93hWygRyO+JI9dONLCthZxQg=; b=y6iyUIxjhcNL2X8ATnjhHNA/EAZU7asbRW+sFSRVdkP7T+BOin/2Dzmq0hjRbhONlU i9ItEhCbfh0qiFduqRz8S8tG/okQjDZtXC/Mn57i+00L1kQbLNlfpXy7opoL+wtGa+DF OP/DLaUEQuKwv2u7ptyWIFKL8DKactxHDSI47aDzkYSjc4ziTlnp69Uo8U2OjGGspqJ8 6qPVBdbsSQl06V2TEo9MubVRPgDbpeyTg2B71I1RmyjcCxxh8bpJmmOplLsJtQCmzuKW zjQHE3pDrs0SYuFE47JHuTz5bw/xMWKyVVp6TeaT+GtAhC7K4SJPBPwraHZXEmY3DTNY NI2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S7lyagN9; 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-120209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120209-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a11-20020a0562140c2b00b006968ee0bfd8si5536104qvd.131.2024.03.26.19.17.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 19:17:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S7lyagN9; 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-120209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120209-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id DB3151C23EF0 for ; Wed, 27 Mar 2024 02:17:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74A9920B0E; Wed, 27 Mar 2024 02:17:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S7lyagN9" Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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 1088A21350; Wed, 27 Mar 2024 02:17:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711505864; cv=none; b=Td7ND/kQFEWvilQLgflFqz0MofqViYko8Fk28Y0ECAYOgniyAr7M1CO9fzPxAa8YMnjz6zne/wyDyWqKbFK188USnnZF3xD3qTInRpFRg2F38xT7jCJMTMm2zECYtmHP0qwZvU5+M4Nsp0o7/sUU3KkGp7QyaQnu4fuAX1hjlY4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711505864; c=relaxed/simple; bh=iaw4baeHrINu60FiqZnVfwkVeJ/VbHfr6pS5CI6bXfw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=AlQbL/YQLWYdlGn8UWcRrU30fl5PGkqGRRZhMJrvOSVcOqaIgLCxl4VMqctsX3mppuIQfXadmhRJ85BFm7tsEPwsLtmHRawmaa5UNFLxi+mOphsCT4cN6JDhExINyGL7o2N4aQYQXIEL98cvWjUdb2QUvtrt4FuJbGo5i6350ts= 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=S7lyagN9; arc=none smtp.client-ip=209.85.128.179 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-yw1-f179.google.com with SMTP id 00721157ae682-60a104601dcso69612897b3.2; Tue, 26 Mar 2024 19:17:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711505862; x=1712110662; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=e/ONsFU9nxQvS8X3SSqcN2WZie/AcsRGqQejcrWJvLg=; b=S7lyagN9vUalAei0exvpQCugWtSHj9K8kFZtLrX5BmAktEy6imPCPVPGLVhw0Y/xAW yWRE/Ng1dMrqx8eIrCFmLbwPrjaZCqQ5kUOEsby2UFRICvp0oiP5CqaTZPFiWcvlm0VR h5TYAQsz7iXbdMZJGoM4WvXW3Neoe+tjwhnQec5e85Aj8fyO4BJ832tlVD0fda+krvVr m0rzIxS53mquCwkz5oI/Qk+P21bve9a1SNtvjrXI13C9JxQuhOOkZ9b0deQM6FXuPSu7 3nIivIOVcDhRFBQQbtxOttsd84pAdcY+pSBj/7uAj8r1FolMKxehXqWe6WdvBkygJpxN yV0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711505862; x=1712110662; h=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=e/ONsFU9nxQvS8X3SSqcN2WZie/AcsRGqQejcrWJvLg=; b=nDo/MFrppTcb9nG/7k9u0TbRYTaQvEeh1h/NkL1ier7q7ktPPfIHo1XHoatSpZt9ba AD1VddQAOGJ/b7Yep5M4P59L4vYwZU8v9+uZOJ6WoLQVOpwZnx02DbdAujvnBtwn8kko +3OcYcyE1Bbt8E8kGMufWdsNE3LjHbe3GGrgE32ogNPU2axL0EH+h7jwV+yETBGsDM0b m+slrJOKbC07Gvl8frT5LxU3RRSX7Tx5wCCkkiubkMVZTRY82OlMu0OjNyymMzBtnL1U PZeGQU7qhm0TVrc4dNzDXMB9eTqJXXxWIj3or9vDGgiRnv6dX/8uDDCYelbOKkwrR/PW 9Ciw== X-Forwarded-Encrypted: i=1; AJvYcCWiIHIabLGti/9kNf4H+3I23IA/gqFfq8R1GahjS2EN0mo2de1fOocPehPGLBsOhci0pE9tYYZMtbNICq3hyv4JJz3LpChmXjSZcpl2 X-Gm-Message-State: AOJu0Yz2nW6A7VtNFSCP3XujE2UssCwg9hHooc4PA5iUm2UfTHu0KE92 6sTLqf2bg9ry9xBU7muuAohuWEda9NA5+roqOw5OmquqpnlK4d1Rv1usCroVglZMnIaHaZInwag 8AmDmNBLpmXBCyYnsIZHecF6AX68= X-Received: by 2002:a0d:f006:0:b0:611:242e:4116 with SMTP id z6-20020a0df006000000b00611242e4116mr4418566ywe.34.1711505861969; Tue, 26 Mar 2024 19:17:41 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240325195418.166013-1-wedsonaf@gmail.com> <20240325195418.166013-10-wedsonaf@gmail.com> In-Reply-To: From: Wedson Almeida Filho Date: Tue, 26 Mar 2024 23:17:31 -0300 Message-ID: Subject: Re: [PATCH 09/10] rust: init: update `init` module to take allocation flags To: Benno Lossin Cc: rust-for-linux@vger.kernel.org, Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , linux-kernel@vger.kernel.org, Wedson Almeida Filho Content-Type: text/plain; charset="UTF-8" On Tue, 26 Mar 2024 at 11:08, Benno Lossin wrote: > > On 25.03.24 20:54, Wedson Almeida Filho wrote: > > From: Wedson Almeida Filho > > > > This is the last component in the conversion for allocators to take > > allocation flags as parameters. > > > > Signed-off-by: Wedson Almeida Filho > > --- > > rust/kernel/init.rs | 49 ++++++++++++++++--------------- > > rust/kernel/sync/arc.rs | 17 ++++++----- > > rust/kernel/sync/condvar.rs | 2 +- > > rust/kernel/sync/lock/mutex.rs | 2 +- > > rust/kernel/sync/lock/spinlock.rs | 2 +- > > rust/kernel/workqueue.rs | 13 +++++--- > > 6 files changed, 47 insertions(+), 38 deletions(-) > > One formatting issue below, with that fixed: > > Reviewed-by: Benno Lossin > > > diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs > > index 077200f5350b..af539c5eb4bc 100644 > > --- a/rust/kernel/sync/arc.rs > > +++ b/rust/kernel/sync/arc.rs > > @@ -565,13 +565,16 @@ pub fn new(value: T, flags: Flags) -> Result { > > } > > > > /// Tries to allocate a new [`UniqueArc`] instance whose contents are not initialised yet. > > - pub fn new_uninit(_flags: Flags) -> Result>, AllocError> { > > + pub fn new_uninit(flags: Flags) -> Result>, AllocError> { > > // INVARIANT: The refcount is initialised to a non-zero value. > > - let inner = Box::try_init::(try_init!(ArcInner { > > + let inner = Box::try_init::( > > + try_init!(ArcInner { > > // SAFETY: There are no safety requirements for this FFI call. > > refcount: Opaque::new(unsafe { bindings::REFCOUNT_INIT(1) }), > > data <- init::uninit::(), > > - }? AllocError))?; > > + }? AllocError), > > + flags, > > + )?; > > The indentation looks wrong, rustfmt sadly cannot handle the pin-init > macros. This looks better to me: > > let inner = Box::try_init::( > try_init!(ArcInner { > // SAFETY: There are no safety requirements for this FFI call. > refcount: Opaque::new(unsafe { bindings::REFCOUNT_INIT(1) }), > data <- init::uninit::(), > }? AllocError), > flags, > )?; I remember trying to rearrange this and `rustfmtcheck` not liking it but it seems to be happy with your suggestion. Applying it in v2. > -- > Cheers, > Benno > > > Ok(UniqueArc { > > // INVARIANT: The newly-created object has a refcount of 1. > > // SAFETY: The pointer from the `Box` is valid.