Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3410788lqp; Tue, 26 Mar 2024 08:27:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWEt8Rh8dsblafC3By2OncOlZ96Y0MLiRgiQ2H2jdSb0ysF4m3jJoImGYS+qFvJGXAKCDn6h5ovwEXOMkxlAu5T+YQ8ecDWgdb9ggWvQg== X-Google-Smtp-Source: AGHT+IEbLN233rhFSRITTz99dvDleMUq/w3iSmi2GQI3vnwHf8ZY7BvRy3CD5vjQnfVZofwaJ7e/ X-Received: by 2002:a05:6214:501e:b0:696:4621:9da6 with SMTP id jo30-20020a056214501e00b0069646219da6mr11128099qvb.3.1711466864639; Tue, 26 Mar 2024 08:27:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711466864; cv=pass; d=google.com; s=arc-20160816; b=si2OWACUM9eeE32qbIkjR9Ou65YvhimbFYTJeHvEvg9bQeqIcOZMAxpeka0UKDxF5E 4wwqsL2GyUdLVHgkE/E+QhGeJVv3HNs2cej6ZKIV0AT9N/I2s6MpzyVftRT59/2QJaa0 aYl4BfoJ8gfLkybBcnrwighi8eNeqP8bzpWk3r9385AmB7R6Ta8mjZi1D0cmZCffm/+C 1j1PWAtDIeZYxo/xJODRAWnHb7E9UlWDPPDxo9C6tHZTC3f2G+LAYESRw9sOaBvDAiZj nRbbrjfJSAxwxvCMTzoQICCeuMgy72pkc2CnyvJX9LJbLzWqKHDNId3EDo1Ppa3lTDmR 1bqQ== 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=VkNrGer7rVWeExc2E5LbUsoDSwgiynWRPlczlazpxoo=; fh=A/Ua4Q351kuGQC3NJfXQlutNC8uk5uNbUXW4Yyk8Cas=; b=GaNg++vhx/5f6Ax+q6E371QWz4mUdtB7RLjHfUt9S+VIyxyCwvP/X+p5cyjy2BWNwq iRJqbmjb6pFjV8zuY3QOhpcYPcTr/FXLzeE5D5vvsy8k3TUuZur5kf0gTu0k7QLjVH9Y qES3EEobFQM5C+fTzbq6GGdDiZizPMTrljL2/id6T8NevD/VFBVF3bowVIfetT4sgS0s KFRmKVgqAMiILA3jcOLLHhOfbNSCPDHXT82nqWh67hrwK1TIZh7dUBClnmApMOu1YJS+ EfqqRjx6wZOpn2nT6rizSkBDWiSOQFT8BcSLs+E+iYL/Ux0H8oJzQkFNpE/FNjgcW79V Ugbg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=H+bHkuwk; 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-119305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119305-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gv12-20020a056214262c00b006968585d117si5914453qvb.446.2024.03.26.08.27.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 08:27:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119305-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=@proton.me header.s=protonmail header.b=H+bHkuwk; 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-119305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119305-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3B7C01C3E3C8 for ; Tue, 26 Mar 2024 15:27:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B33D313C8E2; Tue, 26 Mar 2024 15:27:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="H+bHkuwk" Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) (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 A5B5313AD03; Tue, 26 Mar 2024 15:27:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711466854; cv=none; b=ftsvJKqj3oTkzk55jTB2Pgl7prwwgx16/GarFUtYDOexmgsu5Nz7rtkesJ3QkjfPPc3dOV4hOSziA3Q+ZefOY7aM91rF7s5XM0guo2qCWImJm+XbyWGfoHF9E8rpbGZ3EK/2SBlxdnyYDe+k9CrIJq0Olj13oc7oAtznm/a6LB4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711466854; c=relaxed/simple; bh=gtc56Pzxa3zd+Gz4XQo7A+Xwpso4wNo6AuhvzHHOn40=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M+YWkx3yg7hlhwwjML7ailQZk5lv/LWMDudczFpIz1uBkidVFkPGYxrT2zR38g7wjAG/vJhxK7QqdUvXYHXJk678KIRRBqw5BHMxxWFEO5TihoewPr0TQnhufDudSXE+AbCtWk56CEsy2ExF5XpXm+hGApegIVQKT49T9ib17ik= 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=H+bHkuwk; arc=none smtp.client-ip=185.70.43.16 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=1711466843; x=1711726043; bh=VkNrGer7rVWeExc2E5LbUsoDSwgiynWRPlczlazpxoo=; 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=H+bHkuwkkSJypF0R8vtRs48GgmMDJ/eH2Pn0W1qQucESJPqZt5dm3wwfQ15nWkg9D HC4ggxZOIdiyflP8qNcYv2V57EXKrkgE06Gp6m/Yof0MMcOt/BusW7qXu/nGKb81zQ lWGr0vHsGosqvDgStJnPz5GDQd6gmsqVhwBtDlmE2CRuxgLKE2v8wzl95AiikwY5j2 5H7qelFswlaEoiQpJyPsQTqfb/z71J1Ic7p2gbyFyjzsn+xHrSSBpFlcYyP3bOz8T+ +IRCivbm2Y+E8ZHmZfiGUU6mA+a3D1Poq5L54uqaBcybEmTcVLtdk8p01OMQXlIBzP /zi48WmL1eOtQ== Date: Tue, 26 Mar 2024 15:27:18 +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 10/10] rust: kernel: remove usage of `allocator_api` unstable feature Message-ID: <0LNSiT6NSGVXUXFMn80Z2GCSdjCmJfd1idFp6dTgEf4hfDyjNHq59jLZD9U6BcWVCo1QVvRvHb5Pjr7DOUlqnHabGeOAhmLguV0kGcruqS4=@proton.me> In-Reply-To: <20240325195418.166013-11-wedsonaf@gmail.com> References: <20240325195418.166013-1-wedsonaf@gmail.com> <20240325195418.166013-11-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 > With the adoption of `BoxExt` and `VecExt`, we don't need the functions > provided by this feature (namely the methods prefixed with `try_` and > different allocator per collection instance). >=20 > We do need `AllocError`, but we define our own as it is a trivial empty > struct. >=20 > Signed-off-by: Wedson Almeida Filho > --- > rust/kernel/alloc.rs | 3 +++ > rust/kernel/alloc/boxext.rs | 3 +-- > rust/kernel/alloc/vecext.rs | 4 ++-- > rust/kernel/error.rs | 13 ++----------- > rust/kernel/init.rs | 3 +-- > rust/kernel/lib.rs | 1 - > rust/kernel/str.rs | 3 +-- > rust/kernel/sync/arc.rs | 4 ++-- > rust/kernel/workqueue.rs | 3 +-- > 9 files changed, 13 insertions(+), 24 deletions(-) >=20 > diff --git a/rust/kernel/alloc.rs b/rust/kernel/alloc.rs > index 5712c81b1308..f17f48130f13 100644 > --- a/rust/kernel/alloc.rs > +++ b/rust/kernel/alloc.rs > @@ -8,6 +8,9 @@ > pub mod boxext; > pub mod vecext; >=20 > +/// Indicates an allocation error. > +pub struct AllocError; I think it would be sensible to add this now: #[derive(Copy, Clone, PartialEq, Eq, Debug)] > + > /// Flags to be used when allocating memory. > /// > /// They can be combined with the operators `|`, `&`, and `!`. > diff --git a/rust/kernel/alloc/boxext.rs b/rust/kernel/alloc/boxext.rs > index 26a918df7acf..3cdda0f635a3 100644 > --- a/rust/kernel/alloc/boxext.rs > +++ b/rust/kernel/alloc/boxext.rs > @@ -2,9 +2,8 @@ >=20 > //! Extensions to [`Box`] for fallible allocations. >=20 > -use super::Flags; > +use super::{AllocError, Flags}; > use alloc::boxed::Box; > -use core::alloc::AllocError; > use core::mem::MaybeUninit; > use core::result::Result; >=20 > diff --git a/rust/kernel/alloc/vecext.rs b/rust/kernel/alloc/vecext.rs > index 1d4d51b45a49..85ca6a6db6de 100644 > --- a/rust/kernel/alloc/vecext.rs > +++ b/rust/kernel/alloc/vecext.rs > @@ -2,8 +2,8 @@ >=20 > //! Extensions to [`Vec`] for fallible allocations. >=20 > -use super::Flags; > -use alloc::{alloc::AllocError, vec::Vec}; > +use super::{AllocError, Flags}; > +use alloc::vec::Vec; > use core::{mem::ManuallyDrop, result::Result}; >=20 > /// Extensions to [`Vec`]. > diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs > index 4786d3ee1e92..fc986bc24c6d 100644 > --- a/rust/kernel/error.rs > +++ b/rust/kernel/error.rs > @@ -4,12 +4,9 @@ > //! > //! C header: [`include/uapi/asm-generic/errno-base.h`](srctree/include/= uapi/asm-generic/errno-base.h) >=20 > -use crate::str::CStr; > +use crate::{alloc::AllocError, str::CStr}; >=20 > -use alloc::{ > - alloc::{AllocError, LayoutError}, > - collections::TryReserveError, > -}; > +use alloc::alloc::LayoutError; >=20 > use core::convert::From; > use core::fmt; > @@ -192,12 +189,6 @@ fn from(_: Utf8Error) -> Error { > } > } >=20 > -impl From for Error { > - fn from(_: TryReserveError) -> Error { > - code::ENOMEM > - } > -} > - Why are you removing this? --=20 Cheers, Benno > impl From for Error { > fn from(_: LayoutError) -> Error { > code::ENOMEM > diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs > index 1a8b0464db0c..1f7a6b5892ac 100644 > --- a/rust/kernel/init.rs > +++ b/rust/kernel/init.rs > @@ -211,14 +211,13 @@ > //! [`pin_init!`]: crate::pin_init! >=20 > use crate::{ > - alloc::{boxext::BoxExt, Flags}, > + alloc::{boxext::BoxExt, AllocError, Flags}, > error::{self, Error}, > sync::UniqueArc, > types::{Opaque, ScopeGuard}, > }; > use alloc::boxed::Box; > use core::{ > - alloc::AllocError, > cell::UnsafeCell, > convert::Infallible, > marker::PhantomData, > diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs > index 51f30e55bd00..5c641233e26d 100644 > --- a/rust/kernel/lib.rs > +++ b/rust/kernel/lib.rs > @@ -12,7 +12,6 @@ > //! do so first instead of bypassing this crate. >=20 > #![no_std] > -#![feature(allocator_api)] > #![feature(coerce_unsized)] > #![feature(dispatch_from_dyn)] > #![feature(new_uninit)] > diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs > index 34dbc85b5220..5206b18f882b 100644 > --- a/rust/kernel/str.rs > +++ b/rust/kernel/str.rs > @@ -2,8 +2,7 @@ >=20 > //! String representations. >=20 > -use crate::alloc::{flags::*, vecext::VecExt}; > -use alloc::alloc::AllocError; > +use crate::alloc::{flags::*, vecext::VecExt, AllocError}; > use alloc::vec::Vec; > use core::fmt::{self, Write}; > use core::ops::{self, Deref, Index}; > diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs > index af539c5eb4bc..8db25f73b37f 100644 > --- a/rust/kernel/sync/arc.rs > +++ b/rust/kernel/sync/arc.rs > @@ -16,7 +16,7 @@ > //! [`Arc`]: https://doc.rust-lang.org/std/sync/struct.Arc.html >=20 > use crate::{ > - alloc::{boxext::BoxExt, Flags}, > + alloc::{boxext::BoxExt, AllocError, Flags}, > bindings, > error::{self, Error}, > init::{self, InPlaceInit, Init, PinInit}, > @@ -25,7 +25,7 @@ > }; > use alloc::boxed::Box; > use core::{ > - alloc::{AllocError, Layout}, > + alloc::Layout, > fmt, > marker::{PhantomData, Unsize}, > mem::{ManuallyDrop, MaybeUninit}, > diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs > index 09a0f158ff1b..50837e56efc7 100644 > --- a/rust/kernel/workqueue.rs > +++ b/rust/kernel/workqueue.rs > @@ -132,9 +132,8 @@ > //! > //! C header: [`include/linux/workqueue.h`](srctree/include/linux/workqu= eue.h) >=20 > -use crate::alloc::Flags; > +use crate::alloc::{AllocError, Flags}; > use crate::{bindings, prelude::*, sync::Arc, sync::LockClassKey, types::= Opaque}; > -use alloc::alloc::AllocError; > use alloc::boxed::Box; > use core::marker::PhantomData; > use core::pin::Pin; > -- > 2.34.1 >