From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (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 D6AD435B126 for ; Thu, 20 Nov 2025 15:14:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763651711; cv=none; b=MkwYaKlQFj+EP/TKZXSidwmzviwtWW6Y1Kb5gVqNOXvOxzLESe2I3E8Y0Nrm+6XBwih05Pr6De8JUjeec7xIDdlOL7rkJ/20FArKTKzJzQpZGSVDUh5Mi8ruswGkHQGyVVf541wXOQ1fGTvV+PqhoSeU96Lema5LaFMEK2noQ9M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763651711; c=relaxed/simple; bh=JghkiwHvBvL6JcsywiEEh15XJk0LP4WSUGT+cTqq5kc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=PHb+HJAqkgJXtTUPROOgWtfNBr5vWAzrRIUnWKLCQgLw29JAdLYKOaH85I9gRO0Lcei+/E0oxIDIV6JOAAySNJuoiIc54B1Ch5tJhbVEvvgsr/m/gKOIDc0d7xZ31MvJyBeHX25IoNRvgaqJTfUBd27E6QljVSa3rzxxeBnrBaI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--elver.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=CJHAYRpj; arc=none smtp.client-ip=209.85.128.74 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=flex--elver.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CJHAYRpj" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-477a1e2b372so8553925e9.2 for ; Thu, 20 Nov 2025 07:13:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763651635; x=1764256435; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Im5hsj1DltxV90KwIidFCTn0DS8FZncDFP7kTqaMpC0=; b=CJHAYRpj8OdyNZb9AA1JEkkGxogTxd4rLTjbLE2ImVrpUNP7iruS7fNrJbcEcbFDmR S4R0OuQRmnqP1zeN+epjN/RUXQcciANAC/S+LWnHaii0RAyiiT02phA5POdjnHUaMeDw wp1XhYYHnkB8BWvNIwB9MM2D7GO0wERdk6U53yuEk2HVRbKTSQ3dE4PBA47tye4tNUBc G6QqCwUs0XGMY53xRTBVYJnFcYzzcUZe1DsVIDWkTe5jl0Q21Nug0wQyG9AMTsGHD4P5 p3HwB23RqXXJD9VgamMqIW4abFlWzPcir+ji95zxTIsUttAENUCrTRjy0LI6SxOEQ7Ig qejg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763651635; x=1764256435; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Im5hsj1DltxV90KwIidFCTn0DS8FZncDFP7kTqaMpC0=; b=DfjuvQjrfhZTWZoLfotd53NjZMj4TBnWaYQhqCCmWHQ/PQu6gWOmPJfGjjrw7jOB5D n4cZjXrHuyJUdv36J9kCFH1kUogcIStQv7xXBnYH7syIMWXVLntWUom7gN7lX00udBMd gt1jwzZiOrHtj+VjCZ3cyXw9X2Boq/Fl7++WTXPG/y8uzgkVKKwyYusiOh//Y+2aSHgU 7i26g12pNe6tPmaZKZA0+qqDMyC7sVRmlHCNsjz41Z5BUiLWG3w/BRv11mFgocHp3YSz 7QyPNdmQ37ca4qWRa5agJSoQycKK80IYqJj4yAl/etlVVQAQMZLmRIURdjJskEC/h38Q UXcw== X-Forwarded-Encrypted: i=1; AJvYcCUkBmliJgOPGyfCm7O3QTahRY/FNCTQ9m32qSGTtNsTd26CJjteVCNVlrJpcp1NX8OQo7ZGyP/RnKJaRZU=@vger.kernel.org X-Gm-Message-State: AOJu0YwDw7eCD3EDaCeOSSXo06i8W94l3mL/+IgN4N4e0ZPYQCPQqQ9k 85hJ7e1yV2vLQN3/dv+voPTxBZQ6BRjJlRXWgfGEK1pFmMmTqNMsKXYAoaOkjPwFxtYD89dkSl5 gAA== X-Google-Smtp-Source: AGHT+IE0txFyfqWr7t8p06ZvcBdzNhQeJVfQ06tB7yPqhvYYx4yW0lw4v6t9Cn2mD+Uk9FOLbPP2gAnnVA== X-Received: from wmd10.prod.google.com ([2002:a05:600c:604a:b0:477:9c68:bd6]) (user=elver job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1c1b:b0:471:c72:c7f8 with SMTP id 5b1f17b1804b1-477b9e1cbfbmr31262875e9.21.1763651635197; Thu, 20 Nov 2025 07:13:55 -0800 (PST) Date: Thu, 20 Nov 2025 16:09:57 +0100 In-Reply-To: <20251120151033.3840508-7-elver@google.com> Precedence: bulk X-Mailing-List: linux-kbuild@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> X-Mailer: git-send-email 2.52.0.rc1.455.g30608eb744-goog Message-ID: <20251120151033.3840508-33-elver@google.com> Subject: [PATCH v4 32/35] printk: Move locking annotation to printk.c From: Marco Elver To: elver@google.com, Peter Zijlstra , Boqun Feng , Ingo Molnar , Will Deacon Cc: "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" With Sparse support gone, Clang is a bit more strict and warns: ./include/linux/console.h:492:50: error: use of undeclared identifier 'console_mutex' 492 | extern void console_list_unlock(void) __releases(console_mutex); Since it does not make sense to make console_mutex itself global, move the annotation to printk.c. Context analysis remains disabled for printk.c. This is needed to enable context analysis for modules that include . Signed-off-by: Marco Elver --- v2: * New patch. --- include/linux/console.h | 4 ++-- kernel/printk/printk.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/console.h b/include/linux/console.h index 031a58dc2b91..1eb3c9d9d6ae 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -488,8 +488,8 @@ static inline bool console_srcu_read_lock_is_held(void) extern int console_srcu_read_lock(void); extern void console_srcu_read_unlock(int cookie); -extern void console_list_lock(void) __acquires(console_mutex); -extern void console_list_unlock(void) __releases(console_mutex); +extern void console_list_lock(void); +extern void console_list_unlock(void); extern struct hlist_head console_list; diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 5aee9ffb16b9..7646952a92f1 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -245,6 +245,7 @@ int devkmsg_sysctl_set_loglvl(const struct ctl_table *table, int write, * For console list or console->flags updates */ void console_list_lock(void) + __acquires(&console_mutex) { /* * In unregister_console() and console_force_preferred_locked(), @@ -269,6 +270,7 @@ EXPORT_SYMBOL(console_list_lock); * Counterpart to console_list_lock() */ void console_list_unlock(void) + __releases(&console_mutex) { mutex_unlock(&console_mutex); } -- 2.52.0.rc1.455.g30608eb744-goog