From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) (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 371402D0616 for ; Fri, 19 Dec 2025 19:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.66 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766171532; cv=none; b=eqKtIEXRzHccJzlQVJbrCEfJepzwN7Cet49WDUnmyMGM4DbWkTbBpjCxIjezN2N++/jbdIMQQAapXsbEft3Dn0PK15q+0gqf+LcN9PjTK1BvKeWRdYt7QMZxCrRwcNM+/Rp/iaoqEC2JtYlEAUZb2sbvVuAPwDWghgoVpVeRpfU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766171532; c=relaxed/simple; bh=UocQTd03vlm/TCD4q+onIixekG5jfPJUbAZfFLkbKEE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=u5k93sG+l11q8nXcm8o7h6dppFrFfSNIaHFIIGO2HXqEWvzvQ5jLn3ITMK3c78sR7ikPkkMegNyS4nSbyggSVigiTfobvdxf+9X0aTRKxN55i/rvjT1FhDTrBrjuxRvmlCJvkfuI+tgZ7+JaYPEp+byj3Co0pFEd0LrzhMXvQnU= 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=ahqGziDC; arc=none smtp.client-ip=209.85.128.66 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="ahqGziDC" Received: by mail-wm1-f66.google.com with SMTP id 5b1f17b1804b1-477ba2c1ca2so21152835e9.2 for ; Fri, 19 Dec 2025 11:12:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1766171527; x=1766776327; 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=xBMt69sCffmrONEUk9HcTp6E3Zeeun0qAoojziALA+o=; b=ahqGziDC3myGZk6tugmwclXX1yxrNy14VTeaJXwYwhVJ2ZF0Hq5XfdUOFojeh0nq9G MJ48oY1tuSmGMMRj9c79E3aETH9HxmgZUvT+bTbCQDaVX+ZZcE5oSA2amD6PhlTLlTNh nzekfvFZ2OX+zXZLOZtvQz8n9DrgAjMqO8RvPlFgzlftfHI5Ofps/ax5wO3HNr3j6PJX orSNHO1qfj+xYyv7tS2zVdmvE8Hr16hI2gLeDKosV+NVy+OwYKseEVGqN7PcL3MZSh1l qIw1AanlNH9wUK4ood1oOkTTSwzYC03tJl4G37nrXDKAcxKIG+NEHrdj6AUM2q1iYNu5 kHuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766171527; x=1766776327; 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=xBMt69sCffmrONEUk9HcTp6E3Zeeun0qAoojziALA+o=; b=IuvcFXhNkLBi4mC1kCmc545iHPeKTY34uH8IqmGu3OXzlqY+pXEIObkVS1QfeVXM3P JxjJex6mHKyjgvBMsN01I69S1YbzaAuCD+uzLRPBoOoblW9PaSg/fOT6p0opxu9eR9wA TZGha/FLpPaO4VDimFdnKTxtpD5Qw7BSn18Dxqin6MtJTBIz9wpk58om0da7lCVJ4yUB HeEMlVYwrAoyG21VVW1mNFsnYF0b9WB4Bfw7sAeYkBnkUhZIdWRdFCgd3NShyrgtk9nj bEy+m85ow2YCC9Jcnb/xVxqyFYzqNWGaDnBCVuHKQohCweZazU/R44upwKzwI5gQeW3W 2H5w== X-Forwarded-Encrypted: i=1; AJvYcCWlpKVvkCyh38hLPrHJowwQU3vH8u66NMJr7Xt5Lk9fVDAPR3FuHL9VaXl5SJet5kWRWVHpk7d36Hc=@vger.kernel.org X-Gm-Message-State: AOJu0YyKg4KiPuPPBBqBlNwbUgFvovdcDBaWdmUlCI7WkTGGVd0HBeJc l7UgUf/XUp0BJWSvVsnvZvCeh02YS5EkDSbMEVmHJotwSIkQYetywgzG5oHC9SaShw== X-Gm-Gg: AY/fxX7rvmcy/MwkkW6kwz9YdEIrBHDW9HNw4sc/yHxqgCPr9lsSQ9DHvDR33Kh0EC+ NBKhdFtz+37xEG24IlYOMg3M2ILtP3A7ht3zPBg2LcX5SJbBGKIsrw1v6aR3GjoFrNTV05kX8w2 yB8HlLpFcBlSBa0Q9MkVZFk4LkHN0glaJhyWiDtLYwFE41Tf7tdGZvUpzTPBPQ4qhRAaKirYxy2 DID9bqRvi4iezH320fJZQiEB0PsyK/YTtkuOJ9WA5xp7QwADsllZv/Fn8zKmbD1l/L6kerMj/B8 3LB0HLE6FhcjMlZ4b/SReOGehjGpOxdkKLz5wOo0vW9ZzpH5fQBABOjW7S1lo1mtokrAyR8WedA 53SChazMgZmVWCcCDk1VUY+Y84c/AMQTIfQgpyJpr0tQ+p7bj86nVmF5OP8U2iO1U+jeOHzuc7t 6jO+i3z9Pyzu1JccmO5IkCMiNwcR5gSiikhEJWSSK7dYAw6x10gWVBwUoyMzA= X-Google-Smtp-Source: AGHT+IH9HIskBRHlFIQr/Osyy9yIUKVMwuoBBZxTrb8MCYHFqdOsUtEusA5GjiNqRLtoiyidJxfWVw== X-Received: by 2002:a05:600c:3506:b0:477:a246:8398 with SMTP id 5b1f17b1804b1-47d1953b774mr34567195e9.2.1766171527309; Fri, 19 Dec 2025 11:12:07 -0800 (PST) Received: from elver.google.com ([2a00:79e0:2834:9:f7c5:1bb4:fb06:fd5e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4324eaa2bdfsm6628486f8f.32.2025.12.19.11.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Dec 2025 11:12:06 -0800 (PST) Date: Fri, 19 Dec 2025 20:11:59 +0100 From: Marco Elver To: Bart Van Assche Cc: Peter Zijlstra , Boqun Feng , Ingo Molnar , Will Deacon , "David S. Miller" , Luc Van Oostenryck , Chris Li , "Paul E. McKenney" , Alexander Potapenko , Arnd Bergmann , 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 Subject: Re: [PATCH v5 02/36] compiler-context-analysis: Add infrastructure for Context Analysis with Clang Message-ID: References: <20251219154418.3592607-1-elver@google.com> <20251219154418.3592607-3-elver@google.com> <97e832b7-04a9-49cb-973a-bf9870c21c2f@acm.org> <2f0c27eb-eca5-4a7f-8035-71c6b0c84e30@acm.org> Precedence: bulk X-Mailing-List: linux-doc@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: <2f0c27eb-eca5-4a7f-8035-71c6b0c84e30@acm.org> User-Agent: Mutt/2.2.13 (2024-03-09) On Fri, Dec 19, 2025 at 11:04AM -0800, 'Bart Van Assche' via kasan-dev wrote: > On 12/19/25 10:59 AM, Marco Elver wrote: > > On Fri, 19 Dec 2025 at 19:39, 'Bart Van Assche' via kasan-dev > > wrote: > > > I'm concerned that the context_lock_struct() macro will make code harder > > > to read. Anyone who encounters the context_lock_struct() macro will have > > > to look up its definition to learn what it does. I propose to split this > > > macro into two macros: > > > * One macro that expands into "__ctx_lock_type(name)". > > > * A second macro that expands into the rest of the above macro. > > > > > > In other words, instead of having to write > > > context_lock_struct(struct_name, { ... }); developers will have to write > > > > > > struct context_lock_type struct_name { > > > ...; > > > }; > > > context_struct_helper_functions(struct_name); > > > > This doesn't necessarily help with not having to look up its > > definition to learn what it does. > > > > If this is the common pattern, it will blindly be repeated, and this > > adds 1 more line and makes this a bit more verbose. Maybe the helper > > functions aren't always needed, but I also think that context lock > > types should remain relatively few. For all synchronization > > primitives that were enabled in this series, the helpers are required. > > > > The current usage is simply: > > > > context_lock_struct(name) { > > ... struct goes here ... > > }; // note no awkward ) brace > > > > I don't know which way the current kernel style is leaning towards, > > but if we take as an example, a simple programming > > model / API is actually preferred. > Many kernel developers are used to look up the definition of a data > structure either by using ctags, etags or a similar tool or by using > grep and a pattern like "${struct_name} {\$". Breaking the tools kernel > developer use today to look up data structure definitions might cause > considerable frustration and hence shouldn't be done lightly. Fair point. In fact, it's as simple as e.g. (just tested with mutex) as this: diff --git a/include/linux/mutex_types.h b/include/linux/mutex_types.h index 80975935ec48..63ab9e65bb48 100644 --- a/include/linux/mutex_types.h +++ b/include/linux/mutex_types.h @@ -38,7 +38,8 @@ * - detects multi-task circular deadlocks and prints out all affected * locks and tasks (and only those tasks) */ -context_lock_struct(mutex) { +context_lock_struct(mutex); +struct mutex { atomic_long_t owner; raw_spinlock_t wait_lock; #ifdef CONFIG_MUTEX_SPIN_ON_OWNER @@ -59,7 +60,8 @@ context_lock_struct(mutex) { */ #include -context_lock_struct(mutex) { +context_lock_struct(mutex); +struct mutex { struct rt_mutex_base rtmutex; #ifdef CONFIG_DEBUG_LOCK_ALLOC struct lockdep_map dep_map; So the existing macro does support both use-cases as-is. I suppose we could force the above use pattern. The reason it works, is because it forward-declares the struct anyway to define the helper functions.