From patchwork Fri May 26 15:05:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 9905 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp560927vqr; Fri, 26 May 2023 08:27:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6J4GAymltSX8wgQ61zzPQeRcBQa9kLEXY3qax6P6k8XeRs4NDGG2E0duJq/0B1LZu4nzOf X-Received: by 2002:a17:90a:c68e:b0:253:44e7:9446 with SMTP id n14-20020a17090ac68e00b0025344e79446mr2970700pjt.8.1685114852835; Fri, 26 May 2023 08:27:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685114852; cv=none; d=google.com; s=arc-20160816; b=eiU1QeHFlhDI8J84KBblBPvABTbiDDSK1IXVZeRBqkn5pXcufFVE+O5VUatBWFRCvi fYSr1HbLEDi+ktjTWYdnvAJ0BSviRiIbA6j4lFFh2H9PUIw8gsOykrJLC9qe5j9QRTri jl+mIRsu55EC5lh979KZE0rvoKzBdrrSn2LlCtXSUhYGaGA3PVWgXvfog+lq+98vuINc vkZeB6wVy8l0em+rOx2OoxeFcSif1dMbU2I/7o9fq63mrL2vzkPfhvyQIavZJU8HFknU xeUXusvmMCkJci+g5q7OzLr1Rtqxf042oUEFCp3XflW1xwsfGGskxv46CoYu1oWmR5mk Uw8Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bk4-20020a17090b080400b002502c10bdb4si1216388pjb.91.2023.05.26.08.27.18; Fri, 26 May 2023 08:27:32 -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 S244118AbjEZPXe (ORCPT + 99 others); Fri, 26 May 2023 11:23:34 -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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766970991644610276?= X-GMAIL-MSGID: =?utf-8?q?1766970991644610276?= 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.