Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp31546lqe; Tue, 26 Mar 2024 19:13:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW95KyBQPyENI7yQITUonllIvUfSbUModa4+VFD7Z9647mVXzJxSma5QP46CwmTNwZZhLJNj1VTOGjAR7ip4zFiHfA9/xPU/WjgTwt3dA== X-Google-Smtp-Source: AGHT+IG5dWNLj9lpGUedAkGQVSrvhgJY4FXqNR/xwfihNv64h3ITme9FbFFiFRrtiC3d6JXrq/GU X-Received: by 2002:a05:6808:d49:b0:3c3:de07:3bdf with SMTP id w9-20020a0568080d4900b003c3de073bdfmr2133471oik.1.1711505636940; Tue, 26 Mar 2024 19:13:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711505636; cv=pass; d=google.com; s=arc-20160816; b=xFVZ+aAraOCIKxcCQzXEEdgcfx0t88ZMgVv2rgjfIYMVxpNMo25kr+daNrjEllWMFI tulhhWtWSGeolhyUcxVukNrj6XY1mw0CcXGqQliO2OTZNHV4XY+gtz2So+zLQEuiR99j 3snSTDhSoyGmtwafeYf0WKg4CpcWPBO4bk0orIPSVNhYEzCDd7yatDfsZrIU6W2X7uoN iXc6bh/CQTJRwfzRgLrwAHMHxdkd4hHzcpXI1v/NlQo7GMWtXmjpbnitcOLTtnECS1cH kzCnzmE8pXvSbSDFcievd00RDruPzSrweCZmeau5kjoonMeoTFa+NF8uk1eqhI2noqai XK/Q== 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=jlUvQiiNtk2fTE/O8KLe3aAEMKSav8q/gh3Fim9cODY=; fh=9BXwWW5G7IQBQxmRoVvcJ4dw2LnXN894ecFiRkLUTfs=; b=kAsQPGNrtpEPdc5Qtijdn0KrVo9KLwdbWcNrau5+u9pMdS8zzJmC634hcolNswuZ9d L4lKs3at90+TW+9dQ7MXDv6kepHdbVBie4UAefIcF90lVDWe/x5H0ilWCprkYwidrxZ1 luBsolGqqeGwjZ97Wtprso0K7pl0mT1SQ0JyQL3ZQ0TSaX0wEi07DfUqd3WyRCc9OKKN DioGTK93usBnIY8IbCj+BSlvIcSoYQHlQ4VfTShmeAtAKwIUuUzQe9MhoKh+0bk22ckU Fac/jNNaOIW1JgoDeWs7qD5rITJjKNDO6IiWlNZFXMzMmdfExm9H0xzdgD4TlGRRq76U uFTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jspFnXuh; 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-120208-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120208-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l185-20020a633ec2000000b005e840ae9329si11344353pga.300.2024.03.26.19.13.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 19:13:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120208-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jspFnXuh; 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-120208-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120208-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 99EA5B21589 for ; Wed, 27 Mar 2024 02:13:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B62620DC3; Wed, 27 Mar 2024 02:13:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jspFnXuh" Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (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 663B51CF92; Wed, 27 Mar 2024 02:13:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711505626; cv=none; b=thnbf2qzK+ASSkFqtVIveE5r2sxIC0HCYhyshb1iI3AEAKEXyFYsuOuXcZ7gR9VRpr/P9IJ0ySy+3Xr0OeWHn9l/ia9IjUYbZqCAC2UqNsDlncSsNG0r9VOJlPkR3w2V027HSHPNebDHn4YKbSSN4TqcZ/1Nq54sMd0jaEXwaYA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711505626; c=relaxed/simple; bh=cghJFaDJi3tVEoWnhyy48O7Q2I14v2c+PP+Czgubb8w=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=WkGEGw698lEQSv67LOqTuYYIMMIfi9yulGs8mHJrQMQOtMV9EMssuk8LgN+cehoUXRTUnMvAEzu4iOYF9DZecY35H5cR2mKEIpmnZM0fGgPH9T0xHedmo0qLsCByo2RvJ+iYDIAVv10hB0v854O1L4WUJf9X8UTKA6g808IgWcY= 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=jspFnXuh; arc=none smtp.client-ip=209.85.128.172 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-f172.google.com with SMTP id 00721157ae682-611450d7f95so29104147b3.2; Tue, 26 Mar 2024 19:13:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711505623; x=1712110423; 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=jlUvQiiNtk2fTE/O8KLe3aAEMKSav8q/gh3Fim9cODY=; b=jspFnXuhlwGm9dip/7Sl+z9jvN2h3UJgs51kkIekIDSkezhNGZfnJebBF6I6s2g85L Qy2Xpw8TI0LQd+kGaq5lss2luG9mp9O6wOqOcq14Brarjo/9dgIjYUATt2z4oZrbiLCu OXo7pWlSkUt7ZaCCueED9cSXKyuqUx2MZjZdp9zXKn0VX1S8JPjOrLgf4yYRiJ9e4Llj oz4rImZkjbqxAKIoDQzN76Vv+eSzEmL9V4usvugok0oC6nlD8eC0zMG/odnIni58YJpj tQFHyR72pjvgPT/a4ARSh/tyaPWPeZ9UYDD6Zi+78JETh5oljaB7bDsziyGIr+CfVGJ1 SAjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711505623; x=1712110423; 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=jlUvQiiNtk2fTE/O8KLe3aAEMKSav8q/gh3Fim9cODY=; b=Q/OfG2r4t+Ckimy5+l+2uVEDE7AfomxSEm5X6zVCXQmaTuBQ/Vh97hfcHMHlp4ichE Z/qDAlTbWw0hFabPq+5FwwL+GrWb2DS9H/dT6+WmFstmyHLkngxy6jclz/UqEjzWYJSB KxnAtPb1VswYNZ4tITong3gvFhct3BDMcZgb7SdM9C/oBprLEb25qVAnRW5MKpMHfChH 3WzfOR++h3kyjEPbUe2vwSTiTRVKtjdZT8R9icLuHoQC8N918tnb4JVM2u0B9yHqe5iQ gfKIFy6VYEXvdXwAhZt4hBvb1SwOL3Qb/tDdawfQoankPfWg5BTJvxqH+bumy+5LvUJe F+TA== X-Forwarded-Encrypted: i=1; AJvYcCVcyoUP8ZAGxI7gZ5MdhhNOWYtZ9YuN4ln4Xm7CW696DxuEDVooMikaqXoX0FxOplgZSuqF0BJwlIl1tQkMkmIlqGmlMNL6m8pdG0LN X-Gm-Message-State: AOJu0Yy153l4E4nCyaGzLpH7AUR46JnH/sJWaZ+n+Yn3Ux9wHIblSdg6 L7cipT3AYwDiACbHroa9OFvYQ23TFDLcTdo3G4JbjVe3uafrfkIKa4FZ/oRNLPjr9UABisqpfFK iZIsvGu/PnG15neIa56o94cpkhMY= X-Received: by 2002:a81:7385:0:b0:60a:c510:89f1 with SMTP id o127-20020a817385000000b0060ac51089f1mr2790281ywc.19.1711505623201; Tue, 26 Mar 2024 19:13:43 -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-11-wedsonaf@gmail.com> <0LNSiT6NSGVXUXFMn80Z2GCSdjCmJfd1idFp6dTgEf4hfDyjNHq59jLZD9U6BcWVCo1QVvRvHb5Pjr7DOUlqnHabGeOAhmLguV0kGcruqS4=@proton.me> In-Reply-To: <0LNSiT6NSGVXUXFMn80Z2GCSdjCmJfd1idFp6dTgEf4hfDyjNHq59jLZD9U6BcWVCo1QVvRvHb5Pjr7DOUlqnHabGeOAhmLguV0kGcruqS4=@proton.me> From: Wedson Almeida Filho Date: Tue, 26 Mar 2024 23:13:32 -0300 Message-ID: Subject: Re: [PATCH 10/10] rust: kernel: remove usage of `allocator_api` unstable feature 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 12:27, Benno Lossin wrote: > > On 25.03.24 20:54, Wedson Almeida Filho wrote: > > From: Wedson Almeida Filho > > > > 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). > > > > We do need `AllocError`, but we define our own as it is a trivial empty > > struct. > > > > 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(-) > > > > 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; > > > > +/// Indicates an allocation error. > > +pub struct AllocError; > > I think it would be sensible to add this now: > #[derive(Copy, Clone, PartialEq, Eq, Debug)] Agreed. Will add in v2. > > + > > /// 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 @@ > > > > //! Extensions to [`Box`] for fallible allocations. > > > > -use super::Flags; > > +use super::{AllocError, Flags}; > > use alloc::boxed::Box; > > -use core::alloc::AllocError; > > use core::mem::MaybeUninit; > > use core::result::Result; > > > > 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 @@ > > > > //! Extensions to [`Vec`] for fallible allocations. > > > > -use super::Flags; > > -use alloc::{alloc::AllocError, vec::Vec}; > > +use super::{AllocError, Flags}; > > +use alloc::vec::Vec; > > use core::{mem::ManuallyDrop, result::Result}; > > > > /// 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) > > > > -use crate::str::CStr; > > +use crate::{alloc::AllocError, str::CStr}; > > > > -use alloc::{ > > - alloc::{AllocError, LayoutError}, > > - collections::TryReserveError, > > -}; > > +use alloc::alloc::LayoutError; > > > > use core::convert::From; > > use core::fmt; > > @@ -192,12 +189,6 @@ fn from(_: Utf8Error) -> Error { > > } > > } > > > > -impl From for Error { > > - fn from(_: TryReserveError) -> Error { > > - code::ENOMEM > > - } > > -} > > - > > Why are you removing this? We don't use `TryReserveError` anymore. I'll move this chunk to the patch 7 in v2, which is where we remove the use of this error. > > -- > 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! > > > > 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. > > > > #![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 @@ > > > > //! String representations. > > > > -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 > > > > 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/workqueue.h) > > > > -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 > >