From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1066331985D for ; Fri, 12 Dec 2025 10:16:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765534569; cv=none; b=XE5KfgBw/5NQt0HlqgySGACFO1SYPnEQ47L04s7u2ehcehL/y32KYZ6L9tp1BSFIKb6J3AeufGabyHm0MZ5hUT9FHU4Q8xebsjtcE9F640xdye9Xs8bnOzEtMRb3/61dYwnaivKo+Beyv6pSg+ixlu9qjqUx5Er+XaXaoXsTAFg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765534569; c=relaxed/simple; bh=Yy8AVUr1WzoEhC0gwViTyIIecU1pDeO+TdO72jBT6kg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=upW/oLr6nZwED4QWsWAro8eLE1Yya3YMd0tNe7RMYte3W+3CiTILWVX2ab3KiJiwQBuDrTYMEJZiBa0FM36qHsjG9WX0VMMHQJqHBnfPqcVqq56/xTyyieK5TBCZSlVnX54ZH3iyeSc9qdLG5HKEYpJC14JeAhvVwFRajeaOz3M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kbkpTIwj; arc=none smtp.client-ip=209.85.215.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kbkpTIwj" Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-bc17d39ccd2so672148a12.3 for ; Fri, 12 Dec 2025 02:16:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765534567; x=1766139367; 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=Yy8AVUr1WzoEhC0gwViTyIIecU1pDeO+TdO72jBT6kg=; b=kbkpTIwjpQS8ePNpRzQzmqynFKNs7/NxFbTXEqQxrUChBOEd0ClCuYdBQSv/22spWQ Mlau/Z1r7/t8B4xFGTNsO12c5ZTlO8IX7JmdNjWmjdVZ/Jjmk3SOeb81vSBizctBon6C b9PSWBQffnaVrZsxTpaFewgJOaV8M65WyBFjjc/d5LNfdNJtX504o4PmkXzgy9+JGpaR p+BOqszpjmfwPdF9SWGeFROnU0ow5OvvXnKcQ2WceWvfngjFOxfI5+Rs21yMoX+9CWFu 9Pv3ZqG+EuPi3/Br8MUwkjm1WFmizI4Ur371xJf7pXnmBlKHwciyx1Eiw/6wKklL/E6/ Jp7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765534567; x=1766139367; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Yy8AVUr1WzoEhC0gwViTyIIecU1pDeO+TdO72jBT6kg=; b=IpmcC9vEzIRHmd+dBqBHWMoOc4T47Y3jUyyzfQBqo8qSXKlkodu0qxzbJIPna+QvEA dNfFWpEypCvhFABekl/QVhbEVwyhJAw3PjWE3pyhMFXijIhZuCwASED67cOm6nLkDYH7 NO4TKv2ybQniSXomPYac/ivt2UNSrKPDl9b+MUpxD5XGsLduoZGPEAJBAgf1J1SGMXgI uI8j+5bgVIkYDQt/9UtOpFf8uHykJg8v+B4pRulH8Mi/0S+tHVsI8i3byWD46xFNjKxF uR3uNxSLQQeBGfQ3ywwieGH8weKicVjzY7vzzVjks1fi5pFTrhN72tsXdUBfbo0ZQf2M gCEg== X-Forwarded-Encrypted: i=1; AJvYcCVxdwxpMzEIMskGthHL0wgtLg5LhyeTPfwuEcn9L8fEcejTYSkQJauxnwbNbzGlyWOSCouIkPOPF/xfk9I=@vger.kernel.org X-Gm-Message-State: AOJu0YzaleX4jR0EZVEGl5LPqFndsAIzAH6T/JVnrfZBv9Yo2hDHao+K 1wf8L9+y/F3df7FomjZfYgUXF+JN12ZLiJmoL0NFXk37KRu6DH7Uab2Rq2yDTCxwpGgEDnKQKPL Ntm3OkX4pAvjDqu6gnJ1RGRN6NTi4J11BVL/gJMau X-Gm-Gg: AY/fxX7SB0VN8PZq1eG3zEibKxOPr3InU04xnJ57N3qtbE5eA9YXKr2j0h0pwsKinpG 7184Q8F/jzHi68ZSwFLYZTuSqjGrfFsPZg6HUALuFhCLLuKct1zDM+e3ulMHyPAe0hPlcKTcG71 ZqRYFqzNeHwhKRCXgmxRnpzhwPv1tOcGFKvQjL5IcXyxz9n0As7L94tkMNuYJKgKpPqOH7R5Z04 zcik07rJerirMATsd0o90JT11xl8qtdLP2p3mlnUuhKziWQ7uRgwzu+Cy5vYhdxuWV0qceyZkVi 8AVnkkBcO5Zdr3bG0Lry3yRD0cHDSsamMsALmw== X-Google-Smtp-Source: AGHT+IH8fq53xzz4VEeZIfjpPn2aDZft0vSRUPpE08Jgar7Bwxv93jAlmI/oD2Bc5sYJ04yKuPnrNx+rDd5kmEFlwB8= X-Received: by 2002:a05:7300:2aa5:b0:2ab:ca55:89b4 with SMTP id 5a478bee46e88-2ac303f2fbcmr872533eec.43.1765534566419; Fri, 12 Dec 2025 02:16:06 -0800 (PST) Precedence: bulk X-Mailing-List: linux-sparse@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20251120145835.3833031-2-elver@google.com> <20251120151033.3840508-7-elver@google.com> <20251211121659.GH3911114@noisy.programming.kicks-ass.net> <20251212094352.GL3911114@noisy.programming.kicks-ass.net> In-Reply-To: <20251212094352.GL3911114@noisy.programming.kicks-ass.net> From: Marco Elver Date: Fri, 12 Dec 2025 11:15:29 +0100 X-Gm-Features: AQt7F2qb9ENq_mtkRfqCrKNBJnxHOwKNFDuSBIrcF4bjbeWckbG0712gmoUp-Ao Message-ID: Subject: Re: [PATCH v4 06/35] cleanup: Basic compatibility with context analysis To: Peter Zijlstra Cc: Boqun Feng , Ingo Molnar , Will Deacon , "David S. Miller" , Luc Van Oostenryck , Chris Li , "Paul E. McKenney" , Alexander Potapenko , Arnd Bergmann , Bart Van Assche , Christoph Hellwig , Dmitry Vyukov , Eric Dumazet , Frederic Weisbecker , Greg Kroah-Hartman , Herbert Xu , Ian Rogers , Jann Horn , Joel Fernandes , Johannes Berg , Jonathan Corbet , Josh Triplett , Justin Stitt , Kees Cook , Kentaro Takeda , Lukas Bulwahn , Mark Rutland , Mathieu Desnoyers , Miguel Ojeda , Nathan Chancellor , Neeraj Upadhyay , Nick Desaulniers , Steven Rostedt , Tetsuo Handa , Thomas Gleixner , Thomas Graf , Uladzislau Rezki , Waiman Long , kasan-dev@googlegroups.com, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, linux-sparse@vger.kernel.org, linux-wireless@vger.kernel.org, llvm@lists.linux.dev, rcu@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Fri, 12 Dec 2025 at 10:43, Peter Zijlstra wrote: [..] > > Correct. We're trading false negatives over false positives at this > > point, just to get things to compile cleanly. > > Right, and this all 'works' right up to the point someone sticks a > must_not_hold somewhere. > > > > > Better support for Linux's scoped guard design could be added in > > > > future if deemed critical. > > > > > > I would think so, per the above I don't think this is 'right'. > > > > It's not sound, but we'll avoid false positives for the time being. > > Maybe we can wrangle the jigsaw of macros to let it correctly acquire > > and then release (via a 2nd cleanup function), it might be as simple > > as marking the 'constructor' with the right __acquires(..), and then > > have a 2nd __attribute__((cleanup)) variable that just does a no-op > > release via __release(..) so we get the already supported pattern > > above. > > Right, like I mentioned in my previous email; it would be lovely if at > the very least __always_inline would get a *very* early pass such that > the above could be resolved without inter-procedural bits. I really > don't consider an __always_inline as another procedure. > > Because as I already noted yesterday, cleanup is now all > __always_inline, and as such *should* all end up in the one function. > > But yes, if we can get a magical mash-up of __cleanup and __release (let > it be knows as __release_on_cleanup ?) that might also work I suppose. > But I vastly prefer __always_inline actually 'working' ;-) The truth is that __always_inline working in this way is currently infeasible. Clang and LLVM's architecture simply disallow this today: the semantic analysis that -Wthread-safety does happens over the AST, whereas always_inline is processed by early passes in the middle-end already within LLVM's pipeline, well after semantic analysis. There's a complexity budget limit for semantic analysis (type checking, warnings, assorted other errors), and path-sensitive & intra-procedural analysis over the plain AST is outside that budget. Which is why tools like clang-analyzer exist (symbolic execution), where it's possible to afford that complexity since that's not something that runs for a normal compile. I think I've pushed the current version of Clang's -Wthread-safety already far beyond what folks were thinking is possible (a variant of alias analysis), but even my healthy disregard for the impossible tells me that making path-sensitive intra-procedural analysis even if just for __always_inline functions is quite possibly a fool's errand. So either we get it to work with what we have, or give up. Thanks, -- Marco