Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4986560rdb; Fri, 15 Sep 2023 20:47:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9ATIs+XBlbeDhQZ0EK5i7sWDmI7w3R1AGAr7ubL2fGZEtgOJn5uF6E5CKK6T6UtwmNrrr X-Received: by 2002:a17:902:d315:b0:1c0:cb4d:df7c with SMTP id b21-20020a170902d31500b001c0cb4ddf7cmr3298506plc.1.1694836028700; Fri, 15 Sep 2023 20:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694836028; cv=none; d=google.com; s=arc-20160816; b=bTxsD0kpESIblp6pvFeRQSpFZYxpf+cB2tTPXqeQM2oRu6x8VXXQQzoEqvz9B6EC99 LRwscxKY3bMOiPkxo8DLMr6jmmma5TJ/zQqqzgaNsi1nCunUPaA6/JTfaHD6P/Wv8CRu 6/QBbZkbMNLqewSAnLXESKY1VNSLXtYKJfZvl/De9UrUrbAkyDIk2HqnxgA0YK7Gd97y AEPr68w4os9wK16XE8VmNYeBq6S1+5/amJYbegIu+JnSjNoV3FMc+xyxcodW6XX6UsCt nrJp8dB+JCpJe2jJUYYIUjeHHLCLWd6mBpzsADWA1KBKHdjc+dUhorGQE+M7xVE14/DY hTpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=QzSWhVtYsIPnekLep1Vu6G/lb1VGtq/P5+5k7BGz5R8=; fh=WZm5FIwGteWwMu2FxC70OasHBljMKC5DV64VGPj6Alo=; b=GsK6m+x8etZrljxK3zvxmSi8bAa+WfWoDSda3+XeZSDxLMIEhHHo8GK4C0g9uIMpO9 6ve+sPaf52iwmK0yMLQJM+yLDX5Tom22tao19iQyfqh1j8GWnNfWyQExDfsHjjsJpRzF VENwprQXlH09Q39PoVhGNHdUy9t+UIwv0rm86NEb3+AvOV86gTveEe5Je9vt5klvg7Rc 5HTITtHX/Qg0Brqhv8AI3yftq8+kHc/dMs8+eU7jwwpi8VmIpRwBe7gDYDBfHKvLeR6Z jEc0Wmjjcnq/BMSWAlM6vpR8XRowGpeuyOdyYCihYKg7+iz/CINEW4aYh/jdGN0vvOgs TQOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=bk4JZ3gR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id w2-20020a1709026f0200b001b8419bd0f5si4225111plk.254.2023.09.15.20.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 20:47:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=bk4JZ3gR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0E723801CCDB; Fri, 15 Sep 2023 15:12:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237315AbjIOWLa (ORCPT + 99 others); Fri, 15 Sep 2023 18:11:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237617AbjIOWLT (ORCPT ); Fri, 15 Sep 2023 18:11:19 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A5041FD7 for ; Fri, 15 Sep 2023 15:11:14 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-52a49a42353so3099549a12.2 for ; Fri, 15 Sep 2023 15:11:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1694815873; x=1695420673; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=QzSWhVtYsIPnekLep1Vu6G/lb1VGtq/P5+5k7BGz5R8=; b=bk4JZ3gRoBvhm+9zchkoW6J24LihPOu1cqsd+qAZPjxlsdtEk/99qyc5MJmssIrjjj SuZ76DwlG6gKJYNfN7ZMybOFZSTwfkXPhUkDHeCQ6USP2JSjIVnvZSVvZw9Ke/EFmyxn jKYA/A9VOtAidDw5XnVWgkVP7j3XniYsPWANU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694815873; x=1695420673; h=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=QzSWhVtYsIPnekLep1Vu6G/lb1VGtq/P5+5k7BGz5R8=; b=MCg+65BN6zFzgbkiawA6uWzHjVDz6K8IWzpnyfZWhaUlvsvbk5zN5b1y0BWStCXkzS M0Vitrcs5uX+15mQDHvIjzBgOzlQk06QD7mhUScySoZ4ffnM+gLBk+aseobQR2gDYRnA IY/VZBPmYBeLJmDXntvm7y31hGb3HbnJCjUeihJsyDZagCs2kO2YH70fNaZdIDz8nzDN gXYF3hlBoxGzoGP118+knHzd+oyXx+wQO1XOYQWpvzwGMLYPBYhSKykcpKxZx31EYmS5 w/anVPtWt5cgJwZJCcv7jfJMQCJGa9wu4d5NK5hGh4YyCZSQWqQdmiBiFfEAPNT5Yvhf QoOQ== X-Gm-Message-State: AOJu0Yy5q9UNKOSpT38Lg30AEGlzmiomZZZ+m2LsD0q4K4hSafAEryiB 8Z8/ur7WzAlvac8o8pmVJoebSkYZJ9+W1ddqP5o1tKUr X-Received: by 2002:a17:906:3d29:b0:9a1:c42e:5e5e with SMTP id l9-20020a1709063d2900b009a1c42e5e5emr2311881ejf.42.1694815872904; Fri, 15 Sep 2023 15:11:12 -0700 (PDT) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com. [209.85.128.45]) by smtp.gmail.com with ESMTPSA id cf20-20020a170906b2d400b0099bd7b26639sm2957164ejb.6.2023.09.15.15.11.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Sep 2023 15:11:12 -0700 (PDT) Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-404573e6c8fso25156445e9.1 for ; Fri, 15 Sep 2023 15:11:12 -0700 (PDT) X-Received: by 2002:a5d:5a97:0:b0:31f:fa1d:898 with SMTP id bp23-20020a5d5a97000000b0031ffa1d0898mr1900059wrb.47.1694815871830; Fri, 15 Sep 2023 15:11:11 -0700 (PDT) MIME-Version: 1.0 References: <07c32bf1-6c1a-49d9-b97d-f0ae4a2b42ab@p183> <20230915210851.GA23174@noisy.programming.kicks-ass.net> <20230915213231.GB23174@noisy.programming.kicks-ass.net> In-Reply-To: From: Linus Torvalds Date: Fri, 15 Sep 2023 15:10:54 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Buggy __free(kfree) usage pattern already in tree To: Peter Zijlstra Cc: Bartosz Golaszewski , Alexey Dobriyan , linux-kernel@vger.kernel.org, Linus Walleij , akpm@linux-foundation.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 15 Sep 2023 15:12:05 -0700 (PDT) On Fri, 15 Sept 2023 at 14:50, Linus Torvalds wrote: > > Call it "cond_guard()", and make the syntax otherwise be the same as > "scoped_guard()", iow, using a unique ID for the guard name. I *think* you don't even need a new "cond_guard()" macro. This might be as simple as having our current scoped_guard() macro have the conditional "scope.lock && !done" instead of just the current "!done". Then you introduce "trylock" variants that conditionally set "lock = 1". I dunno. Maybe there's something really obvious I'm missing, but I really think that gives us the option to literally do just scoped_guard(try_mutex, ..somelock..) { ... } and all it requires is for us to declare a "try_mutex" lock guard class. Ok, so the current DEFINE_LOCK_GUARD_x() macros clearly set .lock to 1 unconditionally, so there's a small matter of extending the lock side to be conditional... "SMOP". Linus