Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp406136lqh; Thu, 28 Mar 2024 05:58:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXNPy7gotf0G8/sNl/8Z27uv5NYcHLxZGZ31MztyGEdRQ6eHVKTUrIfzEhErDyhbKifsVc15m125RYZvcWSaGzt5tsRmDh31IsjG1uIWQ== X-Google-Smtp-Source: AGHT+IECMvHkS7VgRgp8W8hn2XBB6m6BcTSrZfntpigQKlGLS/zualqNq8sXQIwHW7k+2qZd4dfh X-Received: by 2002:a05:6358:419f:b0:17f:56c9:95e4 with SMTP id w31-20020a056358419f00b0017f56c995e4mr2796246rwc.7.1711630695066; Thu, 28 Mar 2024 05:58:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711630695; cv=pass; d=google.com; s=arc-20160816; b=pM1KJVuMqe45GHNwaR4zeLaAYKIT6l/9miYvuU0kaeHK/lqllfDoPWUmx0IsJH8Y/R C7GEYnB+Cj/w17OL5elAgQEdKcneT/lFNZDTWz9QOz136ovpkNvrgRh5eKalk3bTLXId h0O32WkVf5wKDrDVMwoUeCkU8fcMca6O/Yzyfk6W2IDLXb5eAbYD0/4ttu7GIAFlbAFx foRpaj6dwf3DT3UvYqWyvqpf8QP2rGbFm8UByW6CtKrRs/lA9IyzDEUX6gAGQcDttykg FPYoVa2mn3hbLnJS49X/K9k9t51mbIAfB8v5NV4zLBJPc9WiMQptPRRP3N58N8KsUD2G dyqw== 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=OlSNbbIVZdwNlWbGRGrNqpMFsqc6WZwwh4eW2yeG850=; fh=TD4HeZ1n6iqXAkGzKUk3uKLE60W1SLWz8hzaV4S1TJo=; b=SMh9Gtb+UCzasJrGDYmxm5VxFkNT9C+SyjshpUfGmoxjQnZbISHF3Qsu6VXbBm/oG0 sivL9HemTePkWhTinh97sOvqCrusLGeZ8a4MZ9caFphUnZfXGlRCO/esMGBFFzyDq/1U E3fBVbUWXiYazj64oOngJiX3bQ3qXYqSD+8AKKIlw5y7wQWUB5VOs1NJ4ygLVpv9q2u5 OVZlGLKGJ+s8e8m3/4H2xzev3yBGtvgEz4qOeddEZopKbRCS7aOh9nLzRmQynR/7ZanU 7KbjjzU+JFNPIST9qWqeL+xicCwZbdgMcXLcSc4q4bAkSMdUPb2jVyvf26dBNXY4LvDf V3Tw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Y6qtWtdy; 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-122933-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122933-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t32-20020a634620000000b005dc071d13c7si1383209pga.273.2024.03.28.05.58.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 05:58:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122933-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=@gmail.com header.s=20230601 header.b=Y6qtWtdy; 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-122933-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122933-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9D14D2917D8 for ; Thu, 28 Mar 2024 12:58:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64E125FB99; Thu, 28 Mar 2024 12:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y6qtWtdy" 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 F07AF224D0; Thu, 28 Mar 2024 12:58:03 +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=1711630686; cv=none; b=irNWE9PkSA7kwcAjUPDolwkdLiT8wXBfvQIGuse+22KqutYLpySN/GR78IHykl5oWMWMHndt7VSLQa9e8319PmrNeLdTn8mEPfubd83uXJpi/ETvABttTAtwhBLkgqtSIpVq8I1VE8oAApJBzYb1FwjtwcmFNFuFps/59Gdm/u0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711630686; c=relaxed/simple; bh=HAGqj7QpufjusPZt09mGu+og4GXNDKDPRj5hMiJXApU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=QrefuvLQIejBhIpR9IW3ZV7mED6l6WPOrGvBvbSyVI312j/m4IAGu5Wz7gz6q5BDmPeSn9kr48CMqIzHYX2t0Utjah7/6UFIuNt1bhDE2zjE6i/kbIPiH5NZUqU/jnaiKfozdPcp/w3C/g7KI7DBtixWhJyxIRMYsJOpB1CPsmI= 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=Y6qtWtdy; 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-609eb3e5a56so9734307b3.1; Thu, 28 Mar 2024 05:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711630683; x=1712235483; 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=OlSNbbIVZdwNlWbGRGrNqpMFsqc6WZwwh4eW2yeG850=; b=Y6qtWtdyV5qnzSc18mnU3yOCoOD5491Sc70GvIWFes8Nxwhm2E48JOmTNJMpzySe/H uv2Exx6s02E+e62FJTQqeg4kbUTm3u3JBwY6AaC+yThyqyeEVBWZFjxIj/LDJKpzYOxx yyq54Rrmqn9KF/yKQLSM2ZcHq2/wu38N6mrR5T00IZHJANyMw4xceeeZs5yBxwBpoNv8 OwCRNrUC83awADViLwxIP/7SHo2Ej+uV3GQr+jdtaBz6LFBtyvDED8+BZKr1h1pZh0BC Y7HwFbPqI81NsMrYsOD00fhC+4BTUsPOiGi8emYJCNrGKaOBxvB1WcRKTPyrUmW6JHwK F2Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711630683; x=1712235483; 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=OlSNbbIVZdwNlWbGRGrNqpMFsqc6WZwwh4eW2yeG850=; b=UtHoUvZuzo1wLgwwECLmgBdRuGGxsOhxnIfFjyK0Gjf/9Luk7wUha5SeW9+PSqR6Eg U5ieIIwFjvUCV+gL3agChQ9dvDv5++ffniF+66c6VunSN/2JiBlNsf8kYwtZrdhQ29sX c1sJ0MLSnJPtja67jmtYrXcitXtDQ+8QPiLxQZPsDteiMGZwrn3vgS8D3cL1ZsQ6r8Od R7ExyrISKRxOFg3W4HAvCmOFo3kR1L5zd0yKWeiTCq59kQlzCzfk4r/DvtQN98bvRbnj EmaeXpduMOoZc9HN0TXMARzUYMJiTlpH5/jJNjxvmhx7S1KtuA0mnJKICQTPbXtYDvke 48Yw== X-Forwarded-Encrypted: i=1; AJvYcCV1F+xUyZ8x3Jtp76ICsQymXbwa9f5j9hz1nX0aGvGEyZpbRSz3ShQY2hdt22BlQ4cVNF7NBVySr3bKaKT7Jfo5EL+38TdXlss+a/oFr+d0ObWHdBLeiro/mLh+4TJQgPW6A6dbtTNDRkK0UlQ= X-Gm-Message-State: AOJu0YyLyj6gNUxvpipSughWWWHnIKkz1xLyb9/dnahPwR85BRuOWtwC pc038R8iK2lVrddjCizh8N/rSEJyDPQT+VU9XkFKEiSnrSmmWFx1dtOG+bmyBbzAnzN1MqLYuIv uWDx/FLZTpED4afo+p2e71P6JtNo= X-Received: by 2002:a81:7b86:0:b0:607:f09a:d298 with SMTP id w128-20020a817b86000000b00607f09ad298mr2540381ywc.42.1711630682873; Thu, 28 Mar 2024 05:58:02 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240327032337.188938-2-wedsonaf@gmail.com> <20240327081317.45574-1-kernel@valentinobst.de> In-Reply-To: From: Wedson Almeida Filho Date: Thu, 28 Mar 2024 09:57:52 -0300 Message-ID: Subject: Re: [PATCH 1/2] rust: introduce `InPlaceModule` To: Benno Lossin Cc: Valentin Obst , a.hindborg@samsung.com, alex.gaynor@gmail.com, aliceryhl@google.com, bjorn3_gh@protonmail.com, boqun.feng@gmail.com, gary@garyguo.net, linux-kernel@vger.kernel.org, ojeda@kernel.org, rust-for-linux@vger.kernel.org, walmeida@microsoft.com, Trevor Gross , FUJITA Tomonori Content-Type: text/plain; charset="UTF-8" On Wed, 27 Mar 2024 at 12:56, Benno Lossin wrote: > > On 27.03.24 15:23, Wedson Almeida Filho wrote: > > On Wed, 27 Mar 2024 at 05:13, Valentin Obst wrote: > >> > >>> This allows modules to be initialised in-place in pinned memory, which > >>> enables the usage of pinned types (e.g., mutexes, spinlocks, driver > >>> registrations, etc.) in modules without any extra allocations. > >>> > >>> Drivers that don't need this may continue to implement `Module` without > >>> any changes. > >>> > >>> Signed-off-by: Wedson Almeida Filho > >>> --- > >>> rust/kernel/lib.rs | 25 ++++++++++++++++++++++++- > >>> rust/macros/module.rs | 18 ++++++------------ > >>> 2 files changed, 30 insertions(+), 13 deletions(-) > >>> > >>> diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs > >>> index 5c641233e26d..64aee4fbc53b 100644 > >>> --- a/rust/kernel/lib.rs > >>> +++ b/rust/kernel/lib.rs > >>> @@ -62,7 +62,7 @@ > >>> /// The top level entrypoint to implementing a kernel module. > >>> /// > >>> /// For any teardown or cleanup operations, your type may implement [`Drop`]. > >>> -pub trait Module: Sized + Sync { > >>> +pub trait Module: Sized + Sync + Send { > >> > >> This does not compile with `CONFIG_AX88796B_RUST_PHY=y || m` (or the > >> phylib abstractions' doctests) since the module `Registration` is not > >> `Send`. > > > > Thanks for the heads up. I thought I had enabled all rust code but > > indeed I was missing this. I will fix it in v2. > > > >> I remember Trevor raising the question whether we want to require modules > >> to be `Send`. I am not aware of any examples of `!Send` modules but I guess > >> it would be possible to write code that is only correct under the > >> assumption that it is loaded/unloaded in the same context. > > > > It might be possible in the future, but I don't believe it is now > > because all rust modules support unloading. And there is no guarantee > > that the thread unloading (and therefore calling module_exit) is the > > same that loaded (and called module_init), so a module must be Send to > > properly handle drop being called from a different thread. > > > > Not requiring Send on the original Module trait was an oversight that > > I don't want to repeat in InPlaceModule. > > I think that this change should go to the stable tree, can you split it > into its own patch? Sure, I split it off in v2. Note that you'll also need the [new] patch to `rust/kernel/net/phy.rs`. > -- > Cheers, > Benno > > > > >> > >> @Trevor: Are you aware of any modules with that requirement? > >> > >> I have been using this patch for quite a while with my TCP CCAs now > >> (without the `Send` bound) and did not experience any other issues; thus > >> offering: > >> Tested-by: Valentin Obst > > > > Thanks! > > > >> > >> - Best Valentin > >> >