Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1563179rwd; Tue, 13 Jun 2023 10:46:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6SzXoCOBSIMKnUXEGtQfzE7UIBM5ekWFD2AgMlSEeL6wxdNB9vs1JoJcakQN9/Dy+9Uhb5 X-Received: by 2002:a17:907:1c83:b0:982:501a:62be with SMTP id nb3-20020a1709071c8300b00982501a62bemr733708ejc.39.1686678378877; Tue, 13 Jun 2023 10:46:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686678378; cv=none; d=google.com; s=arc-20160816; b=UBRqmwJsd9Mprm9I0s+FbahOijtbDfuiJFFp6LtkA/WwBw2xS37EikmaZNnfl/tdBb 7Lg7Y+Ka0oMQj6YCC6rTBYXlk3cSPjonI1ykeAcTl2FN8Nz8Es7xeTiFhVBm5ooEyZDQ FGyNrzx+RTYy6P2p1YCVbdX5xvB97t9c2B0f9TIHNClTGeQ7HnJx87iNGeLwtlSSllYc P5EEp4luNnQBlCpr21/HgjdP/m5S5PYrWmvFN9idCquB0HGaGq/Bz8XZ0a33ifBsCHrR voFxv7SyJlvnyvsLiUgOcDdA1pJG3yfFR/dmEAzvhc29kUPOsXf97C3ANJ0a9Cak+B5l JvZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GjLD3Z65AFUlnzGeDipyFAWU3jGU3OlZnyaKrjFl94c=; b=ySFdEccbIlWqQZQOTDPhSpLo43URG+3FC56M+kkTZA1rXPDwbP3eaGmixvKliSwnDs MfZo+5d2WIh+UC+B4FAX/fOQwQSqhhVobx+lu63B2aI7xgl+ifbIeSp7szoCsAgoWrTy 1P+1t9DfAxz10McK03y25o3Mq6nOTvBTWOT0+U3UrG+Vwm6hbdSYkZxiSFZ8nZeET+Za cJOw1HXhKyGkQdBfhfOlDrnfNxiswkbnYVgttlUI2oS8A294zVfgOeKY5iP1bCYe+A5r w5ClFb92b63G9nLDIgKoSavN2ZuMcH5v6UblXl1WhWMeAPosjRnUG657etVjD/ZW5ZJl RwIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=NJTC1I0w; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q23-20020a170906941700b00978875dcc9asi7073086ejx.131.2023.06.13.10.45.53; Tue, 13 Jun 2023 10:46:18 -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=@gmail.com header.s=20221208 header.b=NJTC1I0w; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237890AbjFMRRC (ORCPT + 99 others); Tue, 13 Jun 2023 13:17:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238498AbjFMRQv (ORCPT ); Tue, 13 Jun 2023 13:16:51 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7D8819B9; Tue, 13 Jun 2023 10:16:48 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-bc4ed01b5d4so2658243276.1; Tue, 13 Jun 2023 10:16:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686676608; x=1689268608; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=GjLD3Z65AFUlnzGeDipyFAWU3jGU3OlZnyaKrjFl94c=; b=NJTC1I0w/bhJorLtWaQfWlvAtWyxNzM902NoozV2bocuew6IVQusNLYYsR92cHHh34 unbOiMyrOlD3s/F94VX5GDu2SQjvEyrkkCVvXZv0vCl4WevU6AQ6ZIdMUFLUnckMLnKh 1ggPVAdvsGV89dZLvZbdqcXLIhViqBG+eUvpfVmtpd9FUKi9KXDDsKu/A6ecBlK9bfFY U+GH0IuIyae8Z6r5rUNf6HTxjNB2s069SP7thqFKZP/qBRTz2uFWG6P8hHn/f7Y3ASQv h2+ET2Kjlc0MKvm5SWLSQbwT3w/z/0VybpT8padCUx9s5AgwciSPlOi/v4GahA52YR5P jKtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686676608; x=1689268608; h=content-transfer-encoding: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=GjLD3Z65AFUlnzGeDipyFAWU3jGU3OlZnyaKrjFl94c=; b=OOPnGeAGuQO83JzkBIkaJVhXvgdr4B5xPEmqxjqtk2u+JIO57cjDHq/1pEpxOo+G9r G4TT43m2QfT+XFZHAX/rfL11UXiJh5ONYefjkj7eS+uHu/gIz34GZh7p4MJHEnymKX4x UDNJwaNgSsRj7a8iSBcxGplTo0u7OxL/UpKPzAJJsk4Cz4Mef0ZU+OwpmF9l43Zd7gQh MyScbodXKxTtuDyGpzwtkiXbQRjWX9gjnP49E6QrLYpMMC+r4Hf12OfSpxqQMmAaOf6c 0eDZBa7FDCx3gGmEyv+7JDpXsabdGrKoZ52g3r/p4hlwx/HfauNRYBdXY+VR4x2sUVXL 8K4w== X-Gm-Message-State: AC+VfDx5Yyf1I5hqE5xKvjO7CCdjiYk1aUnLTWdpuMbcPG4atvnJpV7n P3R7yPIRgzmYBsTk9PnyAWf0RUAqnqwtXAi+HxI= X-Received: by 2002:a25:8ca:0:b0:bc8:c035:cf4 with SMTP id 193-20020a2508ca000000b00bc8c0350cf4mr1912446ybi.17.1686676607731; Tue, 13 Jun 2023 10:16:47 -0700 (PDT) MIME-Version: 1.0 References: <20230612090713.652690195@infradead.org> <20230612093537.614161713@infradead.org> In-Reply-To: <20230612093537.614161713@infradead.org> From: Miguel Ojeda Date: Tue, 13 Jun 2023 19:16:36 +0200 Message-ID: Subject: Re: [PATCH v3 03/57] locking: Introduce __cleanup() based infrastructure To: Peter Zijlstra Cc: torvalds@linux-foundation.org, keescook@chromium.org, gregkh@linuxfoundation.org, pbonzini@redhat.com, masahiroy@kernel.org, nathan@kernel.org, ndesaulniers@google.com, nicolas@fjasle.eu, catalin.marinas@arm.com, will@kernel.org, vkoul@kernel.org, trix@redhat.com, ojeda@kernel.org, mingo@redhat.com, longman@redhat.com, boqun.feng@gmail.com, dennis@kernel.org, tj@kernel.org, cl@linux.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, paulmck@kernel.org, frederic@kernel.org, quic_neeraju@quicinc.com, joel@joelfernandes.org, josh@joshtriplett.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, rientjes@google.com, vbabka@suse.cz, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, apw@canonical.com, joe@perches.com, dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com, john.johansen@canonical.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, llvm@lists.linux.dev, linux-perf-users@vger.kernel.org, rcu@vger.kernel.org, linux-security-module@vger.kernel.org, tglx@linutronix.de, ravi.bangoria@amd.com, error27@gmail.com, luc.vanoostenryck@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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 On Mon, Jun 12, 2023 at 11:39=E2=80=AFAM Peter Zijlstra wrote: > > --- a/include/linux/compiler_attributes.h > +++ b/include/linux/compiler_attributes.h > @@ -77,6 +77,12 @@ > #define __attribute_const__ __attribute__((__const__)) > > /* > + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.= html#index-cleanup-variable-attribute > + * clang: https://clang.llvm.org/docs/AttributeReference.html#cleanup > + */ > +#define __cleanup(func) __attribute__((__cleanup_= _(func))) > + > +/* > * Optional: only supported since gcc >=3D 9 > * Optional: not supported by clang > * `cleanup` goes before `const`, but apart from that, for compiler attributes= : Acked-by: Miguel Ojeda Thanks for bringing RAII/SBRM to the kernel! Rust also behaves like the `__cleanup__` attribute, e.g. iterating on a loop destroys and constructs the variables defined inside the loop. Also breaking to an outer label/scope. By the way, maybe some of the macros in `cleanup.h` read a bit better applying `clang-format` to it. Cheers, Miguel