From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) (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 6FCA633A71F for ; Fri, 16 Jan 2026 15:38:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768577886; cv=none; b=I2zsR9b8E1M2byuWJoxIVoJ+bloF3TyVWT38m2BLqdLM01zTxSC3OqC6c1Y+4fWP7bnIB+NbRZDNpaqHOI0GAszzVaHStY9cG2owRmjtDe3GNi3VlUQJFw+XL0B8JB8+VXDTim5r1xLJrpasSs3bPJHmYA0qeRovheLnmp+pA0w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768577886; c=relaxed/simple; bh=BOWxuALbnVsg76rC9q42aLUuxBJuctl3jLVjqz1y6Jo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=T5ToTaPDnDi7OF8DS0kU7Pv88y+R72bs7fqS+j/6D1QSfr+tLDJEuv/L5d4GzXPitaDpppOE1KcJ3VyrHiAGPgTRYDJOMFYxOhz0n1CB5kuREZMkpOw+IivYmWyKEZho/GXjgZO6WT+6RMl8Z8/6AwAPbbcpTvRBK6sD2qOSxpY= 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=Lvpy1Os5; arc=none smtp.client-ip=209.85.128.65 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="Lvpy1Os5" Received: by mail-wm1-f65.google.com with SMTP id 5b1f17b1804b1-47ee301a06aso19670535e9.0 for ; Fri, 16 Jan 2026 07:38:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768577883; x=1769182683; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=pgFxhnuAvKh4+DybKpe+A5yQM2/DqHkYrZhkViFcA54=; b=Lvpy1Os5Shr8u1VNZyPcwEcVTJpqt9ebqycvb69oMsGy7W5Bzssy0pUEUHwXUBso08 p+l7OiuyYTtlizcpTWo4z6JJuh/5CNjlYzmHk+T5U10FSbAv04MyGvYj9IB7XQRuKsMi MkMGVZhJA6HwyV73Ei3Oo0jkNhHjCy6AzS/42RkBm0NaJE/RPmvlSTRQJp70mO1+MVtd txx2jTaBvmzR3SLofbwspH4NkIS8oNgTdJvMokPTZSRoLbo0T+RuK6ClCzdr1sRDiBA8 c7nCoPmsdvMDmIgBJfxOpKFu4j0bdrHIujRP7DKvIqPXmRqgGypt09dLiBPeu1Un1DnQ bTEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768577883; x=1769182683; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pgFxhnuAvKh4+DybKpe+A5yQM2/DqHkYrZhkViFcA54=; b=ZbfnxNNVaqQBB6slfP+anKDT71INSJJ5WgyWjV3lvU2KzNdgLIexF97ZniXw1pFJ+P 3LHc4HJJ70G42gNAiJAsT3xiM7LmWxNKR9oFc4E4Dk1z1NM6oV0fWxt/WFxwDqyVsvpm o9bFTpGNL5yaTpc9HZg1Q8Mxx5i1WZhxDZOyPWKkRRtj/UTVVOpZQKnyqd9X5kPzYiBY p5aM9nFCu4MnmJdIoZcxmGZVd3CH7H9WDSIHQKYJJED0EYrhfOCmd/g/Jz2XVf+EguoI vs+fBgMILof7rvO+VYvckCQTLEakH5Ty472AW/iaPcguV+Q+GFq3Kaz28ghL0Qp1SaVt tiuA== X-Forwarded-Encrypted: i=1; AJvYcCU+mEABuoO6fhKOyfTx9U6ZKcxm2uHyPRam8ubE1blvQZ50OOTTk4NX48AW37eEUvOzye8OhIEQXDhrZJQ=@vger.kernel.org X-Gm-Message-State: AOJu0Ywsun1cVxzgaEydGqlapxcAcfDsPw/Y6PM5CVzSow7d/NBWsetr AGMI3FkfPS/N4547lvkTwOF+HDdkpJm6UIdF/9SSTAmvcPVgmsRzssjGO6UhTRdJzQ== X-Gm-Gg: AY/fxX5CrpWiXoCEwzu9R5v8RROh2xFcmYwz0yZzXt1l+9yYM+n9LjNCiEIm+3zd6QV RvXmOu+ESKrk1nbio/p+/u9uA65xC75c8HsTttdCg8/hOMKOUrFkjnPyxSkrmedILKvyIOc9mAJ WTt0gs8TK8WL3btJz8CktuXOfC1ZhcBftx0s/I20oYi4xSdekHdxIROlss/uaAPvZiPqDYm0Ea+ 2ATAIHQGrvCrqTAwif2ef51ihQ0zeEOY6NSBCMke4/eiXeu9EmauqKfXr8XYjCZOyhFmCyLRIlK IGeLmcVdzhmg64UrUlDfx8pMNMHJ5/EKF00b0RQSp0sfWoRXKUXC0TcGK07JmiBRwGuLMnuzX5h KQ5lMXn5T/CHbd49nli7wqKMQ6djvOvRk7bzksBiapXVhvFTOE6/K3U+fgQgURwIM5/mzHbznON Y6GaHcA9cqYgO4ihCQN1/NYcMdr7+zaCQQ8HFcGWDPm/8v5VkA X-Received: by 2002:a05:600c:e41a:b0:46e:4b79:551 with SMTP id 5b1f17b1804b1-48024b8a77bmr18132835e9.31.1768577882473; Fri, 16 Jan 2026 07:38:02 -0800 (PST) Received: from elver.google.com ([2a00:79e0:2834:9:b36e:71f6:fb51:66e3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4356992681esm5892119f8f.11.2026.01.16.07.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jan 2026 07:38:01 -0800 (PST) Date: Fri, 16 Jan 2026 16:37:55 +0100 From: Marco Elver To: Christoph Hellwig Cc: Peter Zijlstra , Steven Rostedt , Ingo Molnar , Thomas Gleixner , Will Deacon , Boqun Feng , Waiman Long , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Bart Van Assche Subject: Re: [PATCH tip/locking/core] compiler-context-analysis: Support immediate acquisition after initialization Message-ID: References: <20260115005231.1211866-1-elver@google.com> <20260115213311.GG830755@noisy.programming.kicks-ass.net> <20260116150750.GG831050@noisy.programming.kicks-ass.net> <20260116151043.GA18805@lst.de> <20260116152016.GI831050@noisy.programming.kicks-ass.net> <20260116152741.GA19823@lst.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260116152741.GA19823@lst.de> User-Agent: Mutt/2.2.13 (2024-03-09) On Fri, Jan 16, 2026 at 04:27PM +0100, Christoph Hellwig wrote: > On Fri, Jan 16, 2026 at 04:20:16PM +0100, Peter Zijlstra wrote: > > is *much* clearer than something like: > > > > spinlock_init(&obj->lock); > > // init > > spinlock_deinit(&obj->lock); > > > > Exactly because it has explicit scope. (also my deinit naming might not > > be optimal, it is ambiguous at best, probably confusing). > > WTF is spinlock_deinit even supposed to be? > > I though this is about: > > spin_lock_init(&obj->lock); > spin_lock(&obj->lock); > > > Not to mention that the scope things are far more robust vs error paths. > > They are just a really hacked up clumsy way to provide what a very > limited version of what the capability analys provides, while messing > up the code. There might be more design options we're missing, but thus far I think it's this patch (using the "reentrant promotion" approach) vs. scoped init guards. * Scoped init guards [1]: Sound, requires explicit guard(type_init) (or scoped_guard) for guarded member initialization. * Reentrant init (this patch): Less intrusive, foo_init() just works. Misses double-locks immediately after init. [1] https://git.kernel.org/pub/scm/linux/kernel/git/melver/linux.git/log/?h=ctx-analysis/init-guards FWIW, on the C++ side, Clang's Thread Safety Analysis just completely disables itself in constructors to allow guarded member init. So we're already doing better than that. :-) As for why this simpler patch, I stand by my points from [2]; trading false positives against false negatives so that things "just work" does have merit, too. [2] https://lore.kernel.org/all/CANpmjNPm5861mmHYMHoC9ErRfbLxmTy=MYwfsGC-YTpgP+z-Bw@mail.gmail.com/ I'm more or less indifferent, though would slightly favor the simpler patch (this one), but can live with either. I can send out [1] for reference, and you can choose. Thanks, -- Marco