From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 B326535CBD0 for ; Thu, 20 Nov 2025 15:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763651662; cv=none; b=CvXn8HqSs/JOlERGEXVK8ekgxT6bX1op8RKYCNl2epTqCJ+pkz3Zf5T1smbz3oeAtkQIvBx0NrDwy4zfBAlEuEzQmx3mktbzrDfjPettyCD6CFP8iVTJIqzUmChCVIEr/8lRzHHRpyevToq0lgq1Ks95ddN4987svBRdTOLHfdU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763651662; c=relaxed/simple; bh=JghkiwHvBvL6JcsywiEEh15XJk0LP4WSUGT+cTqq5kc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=N0y2Q7h+RUsUVGFEtK6WNbxZdyS0xZbiZDPAoqQjRXHP1rJ6OZsV2mS59kZkYcGytsEnOS92BM5Jx3Mo53k7pBa7Q/3arctVa9h+7IXOmu64I3Sbq4IwTTSQ4ZpMYV37mOlGYwvgXtxlAfYh/rOJbRWxeq52lFgCy4QJ2GWPLoI= 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.73 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-f73.google.com with SMTP id 5b1f17b1804b1-47496b3c1dcso10733445e9.3 for ; Thu, 20 Nov 2025 07:13:58 -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=Qqdg9wgh8EkabOfQng1d2k1syHVuaNpU2omwblrxxV0vNtq5Q1ukmQ6Fo6/gZyFG7s r3Ny3NYpojTmFQb2/7nv60e7gJushhFTp/z2ZxEGf45BTwSH7E4a3nxWCMKwuRgq3QHn Bub28LUJaFUU/DCSqb5H4xb+kOql/ip+ChL4ZvOzK+H1zmBxsM/nBhivzPfMSfv/BUn6 01tdUiHLjEq5S7YDzi1bjoaK4TYrHSo+antzluovT1Mb5wl+adumGOZkXiP5Y4zuQvMl arUy2GmNlHLr9skPHm32wCtL6C/JDI/fAgRNbjaBSfRqDGMsgkp4HxfRDtkqTaTXCXFi CmCA== X-Forwarded-Encrypted: i=1; AJvYcCVQUJC4kv5pYcfv247huuSqi+kWGvw+5UAXYbGdXI7nspIY9FiSrrn1BOu9l+GfUwQKGnvHTDJvpmtOVGQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9KHLlvJ1Gkdm2z9wEmOHcjyuHVjgBeBRN1JKdZXd1qTwZ3l27 UCAjy1R4xJZOcT5ao7PmUi/sFNlgaaNMBElmVT5PzKCcLkRGBpnktC8MfGLzjbFOz2WZQP5+NUD 5/w== 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-kernel@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