Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp97222lqo; Wed, 27 Mar 2024 07:56:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV32xdQvV4a0nEM3pBWaNYGf1oDoUcPNGpKceY4GFWMEmBJd6f6E8h1M46psOC2TXKKaSZJ0n65Nqp+sHmN4GdRdtYnfs6EwVP0LyDK3w== X-Google-Smtp-Source: AGHT+IHRKuVWzF+a53MkVxzIJRRlyncksx1LCsymJg7CA6l9s97jfhUAHINtkaWIzkAp+eCg8qpR X-Received: by 2002:a17:906:a996:b0:a46:d5b9:c2ae with SMTP id jr22-20020a170906a99600b00a46d5b9c2aemr2052401ejb.32.1711551361744; Wed, 27 Mar 2024 07:56:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711551361; cv=pass; d=google.com; s=arc-20160816; b=yqkrnIGFtGcGvUgBPlL/POl5RLyUHAwVLHSXdlmjlPnj9sEFSC1ckOJYjq4a3kDkUg Smn4x8ALaGw59tXLoX/5oEicMSTo4LzD8gLvn9n5XYK0eCIi6NbEie/z6+BXSI2OF0wO rDbo5EDS+1Eop0oXNA41ZGarsjXNO++pVKxsq4WK/ENFQHnDkQSL+mPuC4NcEl/G+i+T O7BZK/gHBCkM+q2WZJTfVZe3VWdm0jxNz+3sMr4JcOLcNhfA6cALYl/FKPIHJtL+YQne bsTZjBXidazlUBP4hK0SsNJh9C2ZlARIax4KQIqI5//jV3aWOD0+sRZzjmmZ9NYWj3pi 9bVQ== 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=/KrGQPoa4XBEU6DDwx50UKASQ/ZJLt8f1jEe0AMQoto=; fh=A/Ua4Q351kuGQC3NJfXQlutNC8uk5uNbUXW4Yyk8Cas=; b=dvvXja3xFfEfc3b5qDl/GTMJc6Kql3fj3IRs/R5kOBTVa72wBCDczbSG1cG/c4n0lz 7SDlNZ5qO4i7MM3emGc+5DYgSSqMnFfINac2Snl/Is5Wv3QC7RGFJjhSrtc2/4aD8Ctn o7MBSCcqY64Urz9z2t17dQeclDKkSjMZJLZF5A3WvrivWHoxhrtjaAhf0XkXqmMJHWPa fAze9t1UjhbT85aDDFEmElg/ATivo/QCGo4iiyd4My0IY6rcOvJ0mecShanG/kDt32MX U/FzT25Wcuxvqrvsd0/On2r4lp47JkAPWqguZTs1SFW6hCivk1Q8jO/tM4xI2RhDc2WE Yn5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@proton.me header.s=qk3erv7bpnda7fik5nay6uxary.protonmail header.b=grTOPeG+; 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-121394-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121394-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c18-20020a1709060fd200b00a46c39976ffsi4683187ejk.500.2024.03.27.07.56.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 07:56:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121394-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=qk3erv7bpnda7fik5nay6uxary.protonmail header.b=grTOPeG+; 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-121394-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121394-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7C61D1F319CA for ; Wed, 27 Mar 2024 14:56:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E65D31411D6; Wed, 27 Mar 2024 13:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=proton.me header.i=@proton.me header.b="grTOPeG+" 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 6AA3F15DBC5; Wed, 27 Mar 2024 13:53:52 +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=1711547634; cv=none; b=RIJM9NUBEQKFqGJjm/cu/Z41wWTxN+RYUeGuFHzBxSXaC1i4nhhcIbGj176GEYFbbabMxJ25qL0x9xcH3rD0PW340ZTJyxRcRXSkH5jsLSmJcYuiWCTUtUQdS7TzQ3rNiUo6kqXl2Sx3qEvh/U6SllR4DnAUm2b+GQvGBJORVeY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711547634; c=relaxed/simple; bh=PYKcrln81x8z3Qo4vIUuoUg+0Pyz3VOd7xpWYi5tU+M=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GY+pBBBoG1BJXCBfItFf/6uJGrBobDpIByYAKEsypbErresS+Nz7SEh/RvLDcy0r53qBt8oFjymUqkNS1386xIcQ7zpgCzBI7EdU74cEAjb9rI0ZzcdTZABnU1ULgwRddQ8+80mlEUky0qVJnOI47shTQaJ0o/GxlweWrBzxpSY= 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=grTOPeG+; 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=qk3erv7bpnda7fik5nay6uxary.protonmail; t=1711547630; x=1711806830; bh=/KrGQPoa4XBEU6DDwx50UKASQ/ZJLt8f1jEe0AMQoto=; 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=grTOPeG+dT+t1VUrin8lKlmqwqEh2CM2cMGUNXFKyoPDxAuUvQXnRIELS5cWaW5ZL 7xzwXPbq553XTsmrbIqVbQ1wasodBvZvUdIwflXHcOEJl/SgTarU0Gi1m1c/UHpyO1 Pf2BZ9DJcDM5Mqr5KUNbWstdoGhZaBfqP8Nnb2AcD1z3C7wFjreX5Wc+eih5aMtNXE eSqAjNsaZDvmIKI/8vzJCGhgwbox1nm2C3YPvNE9EUM2kbBvUBYu6cvFu20gvFOlSB souYPudMxHxIe/gvfGegN0IJKEyADxSdXoYb3w4fx9i82mzwCnMLzCKLbLk6koEoqx OIbQsdAgyb9sA== Date: Wed, 27 Mar 2024 13:53:33 +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 2/2] samples: rust: add in-place initialisation sample Message-ID: In-Reply-To: <20240327032337.188938-3-wedsonaf@gmail.com> References: <20240327032337.188938-1-wedsonaf@gmail.com> <20240327032337.188938-3-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 27.03.24 04:23, Wedson Almeida Filho wrote: > diff --git a/samples/rust/rust_inplace.rs b/samples/rust/rust_inplace.rs > new file mode 100644 > index 000000000000..ba8d051cac56 > --- /dev/null > +++ b/samples/rust/rust_inplace.rs > @@ -0,0 +1,42 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +//! Rust minimal in-place sample. > + > +use kernel::prelude::*; > + > +module! { > + type: RustInPlace, > + name: "rust_inplace", > + author: "Rust for Linux Contributors", > + description: "Rust minimal in-place sample", > + license: "GPL", > +} > + > +#[pin_data(PinnedDrop)] > +struct RustInPlace { > + numbers: Vec, > +} > + > +impl kernel::InPlaceModule for RustInPlace { > + fn init(_module: &'static ThisModule) -> impl PinInit { > + pr_info!("Rust minimal sample (init)\n"); This text needs updating. > + pr_info!("Am I built-in? {}\n", !cfg!(MODULE)); > + try_pin_init!(Self { > + numbers: { > + let mut numbers =3D Vec::new(); > + numbers.push(72, GFP_KERNEL)?; > + numbers.push(108, GFP_KERNEL)?; > + numbers.push(200, GFP_KERNEL)?; > + numbers > + }, > + }) I think it might be useful to also have a field that needs pin-init, eg a `Mutex` or similar. What about placing the `Vec` inside of a mutex? --=20 Cheers, Benno > + } > +} > + > +#[pinned_drop] > +impl PinnedDrop for RustInPlace { > + fn drop(self: Pin<&mut Self>) { > + pr_info!("My numbers are {:?}\n", self.numbers); > + pr_info!("Rust minimal inplace sample (exit)\n"); > + } > +} > -- > 2.34.1 >=20