Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4969034rdb; Fri, 15 Sep 2023 19:47:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTOtWkKOjlGA5P3k+ZnW0mWvhHsUuMAjxbIGNOsTCxv44SIcNTkarA9nLXDnYrJupciV8D X-Received: by 2002:a17:90a:7483:b0:273:e4a7:ce72 with SMTP id p3-20020a17090a748300b00273e4a7ce72mr2971801pjk.3.1694832449654; Fri, 15 Sep 2023 19:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694832449; cv=none; d=google.com; s=arc-20160816; b=abS2HaJsVMAAgOxqkZcDEARLgp83iTcpNt8IDgxrG8NLo7iCcmnEucHDAxXewcMcOf nJl9e2+ycfE70DL17lOkk4oXGNP/+uhiPeOwvoEvBH7tJrI6X3GbMcIawrRO8iL2lnXb 5OrTcnxylffCCEARYLoAT8VwZSnqSBLIm4znQEw3ERupxumyPfOoH15BElKLF4NPuMNE l60j5lU7fRegq9F9CIhjnmN7yRE8nEdsfIFi3XRD/8Yh9hK5vauuVm44R72o2OX82YEp Hz+zSJvoRtXPX1EnlXWdZ/yA6IxahNcU+edSErjaagRHS59yb10t7xTC76+pvVPjJfhC u/pA== 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=M/1H/23B2pkin+rn0KDXQiysBhZl0AsbvPleWos4qKQ=; fh=WZm5FIwGteWwMu2FxC70OasHBljMKC5DV64VGPj6Alo=; b=NcPU5TZ3rH3g7YtsByQ4IR1m8Z9EacT+YdajsOP+qpmMP7SaU1xjOlWkUx/jom8DVN /IHzlIq/m09dRCEJZgzRdsUAolW6nSzaSuY7QLRKTn2mERRxWhywQNb5yn3YV+Bi/1mI JcFrokEvKh9bWDOWT3qk+z52OToeHgRcFj0Q0uCnyA+PFyR2g9Wv00pwn9E5LTsyPvEk 63WY8pN6vyY1dk6ZMreeIxzvWRQeh9O1mBiRfmGo7ldengoZeE8mP9xuTkQM9AvCPGDk W190lAszCbomGjAyiJDwEyh8ZhIIdo0TuNVcme/yE9FBBE9rDCF/Puww/q2hnZtlfTc/ ztDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=I1skia3i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id l7-20020a17090a850700b00268307ac3cfsi6247783pjn.185.2023.09.15.19.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 19:47:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=I1skia3i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id F1B93858CA37; Fri, 15 Sep 2023 14:52:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237838AbjIOVvn (ORCPT + 99 others); Fri, 15 Sep 2023 17:51:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237798AbjIOVvQ (ORCPT ); Fri, 15 Sep 2023 17:51:16 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1910610E for ; Fri, 15 Sep 2023 14:51:08 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-9ad8bf9bfabso330414166b.3 for ; Fri, 15 Sep 2023 14:51:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1694814666; x=1695419466; 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=M/1H/23B2pkin+rn0KDXQiysBhZl0AsbvPleWos4qKQ=; b=I1skia3iXZPN5fOujj4G0hpY/pFPaeK9a3BZfbe7r53ycatMMpo3wkbmz4bvQfKTm7 XMDtm+lJS4LJT/psmmPZ2hEmMLQb5RO73JfRgun/DJ0ORr6WwPh5vV7439V4oZkbXu63 rqa6qvVqD49H05Fr+DvDzrmokZNFSM+EmX+Qg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694814666; x=1695419466; 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=M/1H/23B2pkin+rn0KDXQiysBhZl0AsbvPleWos4qKQ=; b=XX6iS8u12VT6olWZS6OZB+BbeHEeoU5BIALy6w5CESxklrXW+A/gtFDjNmLv1Nn7i6 bsE+w4qY3I0II4osVEqAhaB1jAQOXz3PQkK6sfRSzQEe5P/0HwY4oJAELQmDw3aFUgEP eyXY6DGx6S7kHBNmuJkwRBdehNe4Jfu0e3HJRknUTi5dAK73JSgafBhjvdTFqngqLe3t yjJhJZXxPtTBbSoqbIaZzhiObA8MN8JZHD/wWR/gzPVI5Yc7WvQ32i1WliDsL8cdhB+h QZJodEs6UVCFRu7KbcX8h8e2zsOnxbItv5IXGc/JP4ZEbRADi7fYsQO/Uv4Xf1cTvDUJ IebA== X-Gm-Message-State: AOJu0YxZmaGZQtqQ7sy6YRHbAf/j5EIcoJNOVprkoBTNaUqdP8mUOnXb ARzeV4/09o6ofIffJQlbkhUTmrwHvRP7EvKsLYzWT6g5 X-Received: by 2002:a17:906:844a:b0:9a2:225a:8d01 with SMTP id e10-20020a170906844a00b009a2225a8d01mr2686503ejy.7.1694814666290; Fri, 15 Sep 2023 14:51:06 -0700 (PDT) Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com. [209.85.218.48]) by smtp.gmail.com with ESMTPSA id s22-20020a1709066c9600b00993a9a951fasm2955715ejr.11.2023.09.15.14.51.05 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Sep 2023 14:51:05 -0700 (PDT) Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-99c3c8adb27so331997366b.1 for ; Fri, 15 Sep 2023 14:51:05 -0700 (PDT) X-Received: by 2002:a17:906:3146:b0:9a1:cbe4:d033 with SMTP id e6-20020a170906314600b009a1cbe4d033mr2412770eje.53.1694814665221; Fri, 15 Sep 2023 14:51:05 -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: <20230915213231.GB23174@noisy.programming.kicks-ass.net> From: Linus Torvalds Date: Fri, 15 Sep 2023 14:50:48 -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=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=no 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 15 Sep 2023 14:52:32 -0700 (PDT) On Fri, 15 Sept 2023 at 14:32, Peter Zijlstra wrote: > > > It also got me thinking about named_guard() for the myriad of > conditional locks we have. > > named_guard(try_mutex, foo_guard)(&foo->lock); > if (foo_guard) { > // we got the lock, do our thing > } Hmm. It looks ugly to me. I really hate the "named_guard" thing. One of the reasons I liked the guard/scoped_guard() macros was because how it created _anonymous_ guards, and made it completely unnecessary to make up a pointless name. If trylock ends up being a common pattern, I think we should strive to make it a lot easier to use. Can we make it act like "scoped_guard()", except the lock function is fundamentally conditional? Call it "cond_guard()", and make the syntax otherwise be the same as "scoped_guard()", iow, using a unique ID for the guard name. So cond_guard(try_mutex)(&foo->lock) { .. this is the "we got the lock" region .. } would I think be a much better syntax. Could we live with that? Linus