From patchwork Sat Jul 29 09:09:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benno Lossin X-Patchwork-Id: 12807 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp942250vqg; Sat, 29 Jul 2023 02:55:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlHKjOOnW2VfOwdCvgryYkWy5FLZ+KjPInb8zpqLBkYiSR8P7n7ArskiYU/6IEMqfEPcpEUV X-Received: by 2002:a05:6402:10c1:b0:522:36f0:f1a3 with SMTP id p1-20020a05640210c100b0052236f0f1a3mr3877433edu.10.1690624536398; Sat, 29 Jul 2023 02:55:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690624536; cv=none; d=google.com; s=arc-20160816; b=TZbdkMx12mxrr9TKRd0AFCEL77vSShgz/DZ60Xl5WYi5r+npOUYJ1o4QWoLQiChYuc XfCb01I0PoiyhfWX+/HmE8iYY/RWerX9BlSPhhXsVwQTL+SLjQblL2x6Z9hjXOiDfQHi DGI+dDkEmPvaac3J07SfI8H3sR0gaTyD/tLoOu8ZFma4QzfuWSK0p76cr8JEV7/h5dCb p0Ozj+hxfJV4CjQ2YqR47Y5sWjkoW/QLYRqJK7QdA/6b53KP8noD23LS53IdHpXtXXYD h2trCkQJaydCkZkQnl0Jpsl5FB20vMudIRfLFy8o3QD+M2mLTJ24zZv0D0YnGEYDTjqQ QhoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:message-id:subject:cc:from:to:dkim-signature:date; bh=4lDtjHwaSFsAZDEy7KtHvYhEsNR9ASqMeTkQVXtY5AU=; fh=qm1bOEYzVYZKL4fg86TgWb8D+QJA9mGpUhKFp2A6Xio=; b=EMJ/GZIQNsdLZwsLMNliP35dIw9FopiPxDiXpEmlNDwk26zoWma3OfNOWWiZ5tXWAo wKHGXyEgabh8WlSf0TbQ9oLGJWIFxI50x5eS0VodrL5MWVl0dKjms9XdDqBuh8b28JVz ePLdcaPVMQno5lVbutYiOAQLpSFVMC9BHsxLAnEfpdNBi3cAg+lKe81CVpjyRVg7cmBp i7o71rzOYK10EVFL9vzZMpLifEeklv3HIYLLrd83icmI68SPmLPGYEgeXtHLjImN07Kz N9Q/m4/szbXBql90iYYdihHl2viUKBsng2TvjfeOXpa8Cgys/lVpiTTO9aSgqSNw95ak 2pYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=SgUnpj5i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g21-20020aa7c595000000b0052259d33818si3955707edq.33.2023.07.29.02.55.12; Sat, 29 Jul 2023 02:55:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=SgUnpj5i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231477AbjG2JJe (ORCPT + 99 others); Sat, 29 Jul 2023 05:09:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231470AbjG2JJa (ORCPT ); Sat, 29 Jul 2023 05:09:30 -0400 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ADEE49EA for ; Sat, 29 Jul 2023 02:09:22 -0700 (PDT) Date: Sat, 29 Jul 2023 09:09:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1690621758; x=1690880958; bh=4lDtjHwaSFsAZDEy7KtHvYhEsNR9ASqMeTkQVXtY5AU=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=SgUnpj5i8S1wDowm+nE6f6blDsWPn7GBfTuL2KBzzkzGbkG65CTNnF7WlUwJCDszw RxM9sfFsWbGo/vb8KQZDIHHRBLxdwfkOUD4zPF6Zjv+9+6+UDcNdJ3ssIwrFdN8Q85 /Yj9X0YlyHTm8ieNu7Hadr7IWvcayaHToRb4nSDMfbHLjONc3GtcRm/8D0ILLJe2CM 8mZc4pj2DCe/7EoiBjJfhvKRlyOKSzKzXLAUoqyJLjiF0RaVjObPL3X72NgH6MqaTe qP9Y4J2+GMfdswVKd2HEWdLLCVx91LyycHqtU0A/Ne77ZripOvqj3hL9gCGCv9NEAo vJw0rHjrloBow== To: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor From: Benno Lossin Cc: Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Alice Ryhl , Andreas Hindborg , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 00/13] Quality of life improvements for pin-init Message-ID: <20230729090838.225225-1-benno.lossin@proton.me> Feedback-ID: 71780778:user:proton MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772748313988836736 X-GMAIL-MSGID: 1772748313988836736 This patch series adds several improvements to the pin-init api: - a derive macro for the `Zeroable` trait, - makes hygiene of fields in initializers behave like normal struct initializers would behave, - prevent stackoverflow without optimizations - add `..Zeroable::zeroed()` syntax to zero missing fields, - support arbitrary paths in initializer macros. It is based on the `rust-dev` branch. This is the third version of this patch series. - v2: https://lore.kernel.org/rust-for-linux/20230719141918.543938-1-benno.lossin@proton.me/ - v1: https://lore.kernel.org/rust-for-linux/20230624092330.157338-1-benno.lossin@proton.me/ Changes not present on modified commits: v2 -> v3: - make `#[pin_data]` work better with `#[cfg]` attributes on fields. v1 -> v2: - implement `Zeroable` for `Opaque`, - remove blanket impl of `PinInit` for `Init` and make it a supertrait instead, - add `{pin_}chain` functions to execute code after initialization, - update the example macro expansion. Benno Lossin (13): rust: init: consolidate init macros rust: init: make `#[pin_data]` compatible with conditional compilation of fields rust: add derive macro for `Zeroable` rust: init: make guards in the init macros hygienic rust: init: wrap type checking struct initializers in a closure rust: init: make initializer values inaccessible after initializing rust: init: add `..Zeroable::zeroed()` syntax for zeroing all missing fields rust: init: Add functions to create array initializers rust: init: add support for arbitrary paths in init macros rust: init: implement `Zeroable` for `UnsafeCell` and `Opaque` rust: init: make `PinInit` a supertrait of `Init` rust: init: add `{pin_}chain` functions to `{Pin}Init` rust: init: update expanded macro explanation rust/kernel/init.rs | 645 ++++++++++++++------------------- rust/kernel/init/__internal.rs | 39 +- rust/kernel/init/macros.rs | 519 +++++++++++++++++++++++--- rust/kernel/prelude.rs | 2 +- rust/macros/lib.rs | 20 + rust/macros/quote.rs | 6 + rust/macros/zeroable.rs | 72 ++++ 7 files changed, 850 insertions(+), 453 deletions(-) create mode 100644 rust/macros/zeroable.rs base-commit: 65fba633fcdf8c4c15ddc24a21d8e55094607e33