Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp52655lqe; Tue, 26 Mar 2024 20:24:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVNSiumoWqJwp0sKx2zvh0hxkVUE9HuTWAtVAl6zjHnxFsO63pSyZgdHPr/xISl9qTqR+CLbvM65U2ScoyOR+ZxFWtOOYAGpdgRs1RweA== X-Google-Smtp-Source: AGHT+IHtFTNJClBKjQf9qrb5GwiFsLyk1g4QIMAzhbq5AKJB9hxr9I3ESI/N88AepGBN7wiYLTkZ X-Received: by 2002:a17:906:39c5:b0:a46:c11d:dd01 with SMTP id i5-20020a17090639c500b00a46c11ddd01mr2921217eje.50.1711509843404; Tue, 26 Mar 2024 20:24:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711509843; cv=pass; d=google.com; s=arc-20160816; b=VtmelC9462PY54fgUrXVlkHdOiQU7wWsIl9vRVg1Uq4xuWZb+0/Cz2+XHzBsV3G1iY sion9M2ePEm54ram3x/QLnhlIP5kW1czYh45W4+Idc8YLdyMeHrFFPcUyD+U1JIzaDXa paGgw2EHQHscwoP8Aeru5SQNZxjR6TqXSdeSqwfJG/H5GU0IgbXg4gKc5qpT2+q5nWSv n7rFCeAUEMNAec9y78IAC+bLtwLOO9k4vgC7i9gsVCnhvv9WjkTq3Jav4mWWLfGb/g0I g4zmgIREhVyJC2AI2q3ZvDu5rR+nkoBA7ecmAOoumPRoZ8omQKrIPzeCJZwwsetxSb59 xQ1g== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=quchINbY6RElSjO1aqPi5tTjS1pbZmgP1zzsUpD/qO0=; fh=E/iu5AexLRnTX1wJNSUSj3UWrWe66JGmBvbHpvtZm3s=; b=JR9M9woDOZEdDkdJjldNuqSrDdNniLVMTP86DEfvIru2huu4aeiROc+wvlbhZSPYd+ fYRJCyj4pGTXztkXQwG2FRC1EJLFm1Gy3AwbH7SqOD4RDfyFJCXjc8flzmewmhrXVPbn hVnHDIwq6Fygkvk3dhrbWNmHF/RXkjSmXzIsMcs2xYEhCRdKCA41eu3dNmcrn3IJXiEO 6h6HUk50HG5CGrvE/KRo8ey4azOSfr4pF+XKRhFguD838FIPCNxgTx/ri/EVmrYt60zH dwRPFkRxoPQq0Z7g8m3eZSJzw86BLnnwhFZC+P08qjt5kt+DwAlbKYo3Kn44GUDBloO/ 6axQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=i5hCh7BI; 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-120255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120255-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bt7-20020a170906b14700b00a46caa13e60si3977621ejb.476.2024.03.26.20.24.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 20:24:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=i5hCh7BI; 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-120255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120255-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1B0BA1F26715 for ; Wed, 27 Mar 2024 03:24:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63449225D9; Wed, 27 Mar 2024 03:23:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i5hCh7BI" Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 40E5217545; Wed, 27 Mar 2024 03:23:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711509833; cv=none; b=GiI560JTOhroPUa0Yqgo8nWdGDAXJcLKuMEc7ZIla/5IlfAD8MJFYfWh0M9pKxTv2pakYTp9bgsU/9XjqOekmp5bTjXJcsxpOQ4qvKvGUvP1hiHqqcFJC3gu7eE1MI5XxQG9tit0/xuy/Zu7odgKvDTkjWU7ho1seYtXjVHybKg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711509833; c=relaxed/simple; bh=qM6iGV5jNuZ8RxUHGK1v73pIuVWWgfp6DGOZSTMzbnE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=BkMKjkQh9NPprnpB9WXODaz1GP6wPBN1ZpDRyzK1VxyuQ1kI8fz8JsCF2bQofciSpwtdc8NXEdVNGB15P5QOCdzGMyN7dRHL5xSGYD15Jgh9nm81UZRkMVUF1vt02AXLn06W0dDODtjpEXJrnGR0/HIF6W8UgQNhhmE8+jBUYWs= 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=i5hCh7BI; arc=none smtp.client-ip=209.85.214.179 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-pl1-f179.google.com with SMTP id d9443c01a7336-1df01161b39so51163805ad.3; Tue, 26 Mar 2024 20:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711509831; x=1712114631; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=quchINbY6RElSjO1aqPi5tTjS1pbZmgP1zzsUpD/qO0=; b=i5hCh7BIVFVwrMDBnyLNvh7x+qVe56x3cu7Ac+KSpO2kVBT5IBuypW5F1SmblNMHVR oD9+c5pG6JL1hUVWe8n3Bk3UJ09X2cLGeTs4syyvDhH4Ym0hE7RArIjr8g/pHWG8oaoi w08w8RP0CTLbWloqWytR2emupFjVR+uCd1zsUSWZTzK7TN1C1JX7vXdspXvNCnxsG7Pl 9nyqA+E4RcQlm23yrOpW3eMLs+ZuxJ6s4lpZIwLnc7koCpSD/trEVetkLrAoEpFHxXBV rPUua5N18N723v6q7l23Aq4Cic0xiKoeIPSykaly2AIiXKcOOV/+XJ3nnjbemGw9tSX7 aqxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711509831; x=1712114631; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=quchINbY6RElSjO1aqPi5tTjS1pbZmgP1zzsUpD/qO0=; b=DDH129cjLpRDSi8mJuPxs6z7FVfCn0SgdxHA8OUEJ4N75AoMIyIfCpcNJkUQz5qfI0 uz57ic+5oJtQObUjGFU82RcHB0jrV17eiSkz8pCqSoJ5+eQ/kSa5w4kSLL0Wmdxl5+6R enSOTtfG0eY9S6r76bwQJFdlDak9eJFPS6E4GrjZpLCQ4HP8e2ZQxpQmeMhQ0FY5rJF/ eKna8netLDzhjz3Arw21tCX5ps6wa5iGtCdOSRWNzfk7UhVWu7mzOWm/scXBq5HbUSnE 1gfe9/6stIHPUJs+tcv+fJoA9qcoDN4+AouDjSe4e8OZkHhZZs4rsC/4dVw6ap4PG104 Y0cA== X-Forwarded-Encrypted: i=1; AJvYcCWYVqdOEAnEwhWjB1x96TNGsPYBh7FZwHjAJY66KJ4VMhTUpyzdnr0lioQAjaDxUvvAuNZs9tpgkgTCD1RI75iHVqhBucCPd4q7GWVu X-Gm-Message-State: AOJu0YwG2x5m5hYlHgVCo/3zHWqkgWKppZz4ctza2icitIcCbnoZ9WMS 58H4EGzQvF5brTS8m9tUxCpzLF3tyKNDUCL9lsqd5gw2ITu2ymV2iMTePtL+ X-Received: by 2002:a17:902:e748:b0:1e0:ab21:4e9a with SMTP id p8-20020a170902e74800b001e0ab214e9amr1795982plf.21.1711509831515; Tue, 26 Mar 2024 20:23:51 -0700 (PDT) Received: from wedsonaf-dev.home.lan ([189.124.190.154]) by smtp.googlemail.com with ESMTPSA id y1-20020a17090322c100b001e043df262dsm7729090plg.33.2024.03.26.20.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 20:23:51 -0700 (PDT) From: Wedson Almeida Filho To: rust-for-linux@vger.kernel.org Cc: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , linux-kernel@vger.kernel.org, Wedson Almeida Filho Subject: [PATCH 0/2] In-place module initialisation Date: Wed, 27 Mar 2024 00:23:35 -0300 Message-Id: <20240327032337.188938-1-wedsonaf@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Wedson Almeida Filho Introduce `InPlaceModule`, which allows modules to be initialised inplace, as opposed to the current state where modules must return an instance which is moved to its final memory location. This allows us to have modules whose state hold objects that must be initialised inplace like locks. It also allows us to implement registrations (e.g., driver registration) inplace and have them similar to their C counterparts where no new allocations are needed. This is built on top of the allocation APIs because the sample module is a modified version of rust_minimal, which would be incompatible with the allocation API series because it uses vectors. Wedson Almeida Filho (2): rust: introduce `InPlaceModule` samples: rust: add in-place initialisation sample rust/kernel/lib.rs | 25 ++++++++++++++++++++- rust/macros/module.rs | 18 ++++++---------- samples/rust/Kconfig | 11 ++++++++++ samples/rust/Makefile | 1 + samples/rust/rust_inplace.rs | 42 ++++++++++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+), 13 deletions(-) create mode 100644 samples/rust/rust_inplace.rs base-commit: e0ff891dbadea6226042574a0cbfc24df0318b13 -- 2.34.1