Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3363004lqp; Tue, 26 Mar 2024 07:18:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWAkEhGUogqs5PPDD4hOulPZPF7yLQWR0cO8UQNCqexn6a5OAvTuzOJ1sJJ+RPkCNVhVlVhIB5xo9YBGFTc2NcJhURU0/yCJ/Qa0VntSQ== X-Google-Smtp-Source: AGHT+IGuSfu4oA3dMO2GNtbNwYhywvs60SRzdxaZiWHGVSe+RVMzAEPjctawIg+XELg0bKytHk8i X-Received: by 2002:a05:6a20:be15:b0:1a1:8c28:c4a0 with SMTP id ge21-20020a056a20be1500b001a18c28c4a0mr9547006pzb.30.1711462739015; Tue, 26 Mar 2024 07:18:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711462739; cv=pass; d=google.com; s=arc-20160816; b=ioyunPgTL8qpdSrtqyImTH1EEQihDdD6dqgExhn20vB2LYLmNDig4nYdw3hX3sxME2 sltJNU0C2bSqbNBAWmFUyHFp7GmR6hxY75Q1872TfeDaUY6cKt1RGxk/76F0+ccgq/QP wzNKSk8q/djxs/gSqiJ+lTIJL3RRWqcF67uX48frBpW4/10tFcQXtC/J2I6kk2rCb6dF jkqCjX4br9dVQk0lSYv1EgRQkQ1QErLMLwZF0U70U2WNCr09CWtADg/ilSKlScTfYEDg fOCi1Eoi7ZvkQ93yGY0gQGgduS2rMuIqKbJlxjyoqzfvm+O64cxa1wHnuAKAQGsTpWmB UKlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:feedback-id:references :in-reply-to:message-id:subject:cc:from:to:date:dkim-signature; bh=ygtCkVMY1u+TmO6tCQeJusdDZZEhvhbXgk+XZTvcwDA=; fh=A/Ua4Q351kuGQC3NJfXQlutNC8uk5uNbUXW4Yyk8Cas=; b=lPzjArMrSzEkRjRRI+HSjR4P/gWu5+9cVuZDlTBLxjH/dhm1kRcihtBZaMYV5+d9ki PoP7MDmLgyTG7f7JeRPC6cD/LFXDtIq1K5B75F04/RFHVF3ONefw+1dcdycrDdzbl7Uw H7LZmD1pzHMlDoS+QrYON3W49O+5RXQKDKPApYoe3ju97K32r9OkW9ysDxYq93dfG3hT S3AEuCVJIQLzMLidc2GaPGuj93bNzImeev9iiU2uDwIVfMprmGNdm8tJNMz6iR9LHnKq p8GUgju1OqsHW5lnGnzPcxIOUQ3kkQPB0GdhXBMqNIIwPF6PmZbLTIhevGQttUFs+ECg x+gg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=N6Adbbgg; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-119140-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119140-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id r130-20020a632b88000000b005dc4e366f46si9549337pgr.127.2024.03.26.07.18.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 07:18:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119140-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=N6Adbbgg; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-119140-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119140-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 565303066CB for ; Tue, 26 Mar 2024 14:12:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1921F12BE93; Tue, 26 Mar 2024 14:08:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="N6Adbbgg" Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BB8112B17E for ; Tue, 26 Mar 2024 14:08:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.40.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711462103; cv=none; b=RXDAhRw2x7cv4drnZUYWvO528R9Kyw90y1E9ejjuMog0x6yxJNcRzlDKwCovdvYWirP65DqLPFGmMoZjQSIbSssq0XOVP16xpd7BQJ88s3SmfZMK9V2AeAwe72lfhKzWpQrW9f7WcubKErfPgu8ZtGwsjhzcJZEqNAmiLQTsy+c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711462103; c=relaxed/simple; bh=nXoAUhc7XKG3E9m4AJ3lF49JqT9r8jaxsr9VCcXGEiU=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OG3Og3/UOppBw6mGbAEtdp+r9R/LJxJEct+0pZ9X4ZX3lEyZuCctJA4ym8HGqJnnrZmH133dK9UykTxDpMRi4C6ASgTA7uudxFOIgiDfwpC9bgFz7Ah5uGyeVs+ElCIpYvlkwXqZ0EqtZrGmLQdcK8oiCdqD5Qh870xcXtWtwpA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=N6Adbbgg; arc=none smtp.client-ip=185.70.40.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1711462099; x=1711721299; bh=ygtCkVMY1u+TmO6tCQeJusdDZZEhvhbXgk+XZTvcwDA=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=N6AdbbggLgumVhxke7MmXSZKAMa/y/7nIj0WqHxG8PAgIXF3s87P7fTpf9rPcpZR+ 2frHZ22MGhZOaMcGxm1/v0y9HD+sWktcOrUYvjtQ+YCk1K2O0JOe1HlL9mx0QXRr3w Vly60E1DZQQbaEsBqKCjmDm2A1f65aEEV4Yjp4om6bv5kXBFVpAAKYoY2s/ntPeNjQ mp9u8J4Ln5sOz9aynHG5xjq80/ii4JfnW5LIeBO8G5sRRFncZpbIU886ezAhqGtcpS kxxOiuin9cRSZZDjEA9LiLn2vxlBDh+B+//hQZkPCp5NzUh+zKAtgLLKlaXLcWTaot Gt0oHf1SW7o0w== Date: Tue, 26 Mar 2024 14:08:10 +0000 To: Wedson Almeida Filho From: 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 Subject: Re: [PATCH 09/10] rust: init: update `init` module to take allocation flags Message-ID: In-Reply-To: <20240325195418.166013-10-wedsonaf@gmail.com> References: <20240325195418.166013-1-wedsonaf@gmail.com> <20240325195418.166013-10-wedsonaf@gmail.com> Feedback-ID: 71780778:user:proton Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 25.03.24 20:54, Wedson Almeida Filho wrote: > From: Wedson Almeida Filho >=20 > This is the last component in the conversion for allocators to take > allocation flags as parameters. >=20 > 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 { > } >=20 > /// Tries to allocate a new [`UniqueArc`] instance whose contents a= re 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 =3D Box::try_init::(try_init!(ArcInner { > + let inner =3D Box::try_init::( > + try_init!(ArcInner { > // SAFETY: There are no safety requirements for this FFI ca= ll. > 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 =3D Box::try_init::( try_init!(ArcInner { // SAFETY: There are no safety requirements for this FFI ca= ll. refcount: Opaque::new(unsafe { bindings::REFCOUNT_INIT(1) }= ), data <- init::uninit::(), }? AllocError), flags, )?; --=20 Cheers, Benno > Ok(UniqueArc { > // INVARIANT: The newly-created object has a refcount of 1. > // SAFETY: The pointer from the `Box` is valid.