Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2626909rwd; Fri, 26 May 2023 09:00:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ48w/p8HtwTCUpSY7zEPNpxqbFd5/VVOVuEkRNglsYgWQAIjcAGNLgM9R6aL+Ubz7DSWpX3 X-Received: by 2002:a17:902:e74e:b0:1af:a349:3f0d with SMTP id p14-20020a170902e74e00b001afa3493f0dmr3878861plf.23.1685116826165; Fri, 26 May 2023 09:00:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685116826; cv=none; d=google.com; s=arc-20160816; b=E03rLWgRuW2I7e0C6uxuMJltQn0C+8K2fxDuhshkj0k5nZwnGBtW9rexQP81RRVUuc XhXoQcDU17gHuzMksZzP22lVA4zp25BuOeacPWv2MfMSny8COJ2Xd/0TAe7SKDeMemhu dAqz70iDDNYYTNfLML3V1GVFjpWHb3a9/pn/x2/ByJw/DAy0UAFvq5iTf0LegHpibvZ0 ohGEY3H/kfz2JJ7yeEmhwOowJ8vgPt2TQ/DnsGRjRqbXvvXPRB/8UjuTtmenUiAJ+Y6N Xfd0ktOARkXx1bLiIq1AlDMcPxt7NcTjG7sY5KT2+S0y40OVDtYkpBfKOrzj0wrN7TfW +LKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:user-agent:message-id :dkim-signature; bh=FzjfinT/ioSfMfRQf9Wi9HSHANyBVVOUL7KRBB5Z9sE=; b=Scw4n9u4Cf+q+PNLz9gGU7y44VwhnM2NrBjECctLx9vbX3C9Cw0OLnpja8XjZcj7kG NAOepJRm5vkzMSyMaM6k3NO1GVxggOYBAOeLIEHs1l51Ejaj2Hq4vq7YESVBiAzs2xKE bdm8v+bhU7+TFQ6l6nZUmdmYgg6GTkHWonV6z8vhYqTfL8R5+5C9j00jbUbJwAvFZlkr 6EQ6Uca4K1Sm6xfp/x382t2bFzQmx7vVPwKeZKoAggYtAkJwYVx7yUU3XKrokB7t/xKL T71VwohJZAE2pdgEbwNWF+1Lgr+OLyUreLjkf6qQ8ee6Xc6qzlZfsuQNQ4UZGchPrUSS rc8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=lneXXqHz; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n10-20020a170902d2ca00b001add1ab9cd9si4454127plc.486.2023.05.26.09.00.08; Fri, 26 May 2023 09:00:26 -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=@infradead.org header.s=desiato.20200630 header.b=lneXXqHz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244112AbjEZPXd (ORCPT + 99 others); Fri, 26 May 2023 11:23:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244098AbjEZPXW (ORCPT ); Fri, 26 May 2023 11:23:22 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B53121BF; Fri, 26 May 2023 08:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Subject:Cc:To:From:Date:Message-ID: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=FzjfinT/ioSfMfRQf9Wi9HSHANyBVVOUL7KRBB5Z9sE=; b=lneXXqHzx5OFRE2gEMPCZH+aOM gqZa67jePQ1cJkeZFqkqAtbDR80Z1z+CwfnV7aTKBMo1GwlG4JF2+IPLvGFEVxiMUD0EHu6oIwKmW ETvQh5kdFuU0PfDwXhcmTOOFUTo8KHkv0lTjJWecBDRlK5TYC9YYXQVz7onLmZiw/hrtWm/sMOKp+ dm1PPGm0+mlFmY33VGIb5QJjtiETxYabkWoTtRYMpkq3oxMfv1D0e5zTJd2pZ2DFDd+VUE2ibYZsD +stFryyLEY4S32LhZdlnX3y5qAqkVz3dxBCeemHu6O8WMCBYzZ0euzoyogsE7bKVg9c6k3FuIna1H N+STOeuw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q2ZHE-007cib-2Q; Fri, 26 May 2023 15:22:48 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 898113006B1; Fri, 26 May 2023 17:22:44 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 35F4E22163BC0; Fri, 26 May 2023 17:22:44 +0200 (CEST) Message-ID: <20230526150549.250372621@infradead.org> User-Agent: quilt/0.66 Date: Fri, 26 May 2023 17:05:49 +0200 From: Peter Zijlstra To: torvalds@linux-foundation.org, keescook@chromium.org, gregkh@linuxfoundation.org, pbonzini@redhat.com Cc: linux-kernel@vger.kernel.org, ojeda@kernel.org, ndesaulniers@google.com, peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.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, qiang1.zhang@intel.com, rcu@vger.kernel.org, tj@kernel.org, tglx@linutronix.de Subject: [RFC][PATCH 0/2] Lock and Pointer guards X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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 Hi! Yesterday I was annoyed for the lack of RAII lock guards for entirely spurious reason, but since you sometimes gotta do silly things I spend today creating some. My initial (failed) attempts tried to combine __cleanup, _Generic and __auto_type, but the compilers refused. I've also Googled around and found (among many others) the QEMU and Glib guards. However I don't like them because they end up relying on function pointers/indirect calls. Hence the current pile of CPP hackery.. no indirect calls in sight. I really like how they end up simplifying the code, but perhaps y'all hate them with a passion? I'm thinking we'll at least have a good brawl over naming, esp. the void_guard needs a better name. Compile and boot tested with x86_64-defconfig.