Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1876216lqb; Sun, 26 May 2024 23:38:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUXLqn5fHdVsPaotSPXkMCXfJJmFL1dAtdXI2E2Ki4CtsaIqgf81o2JJAU+uzX6jnCi0Ggy8zFNSPBTPGdz8cQf8sSUdVKNPhd1LXOAgg== X-Google-Smtp-Source: AGHT+IFroomKZv81v+k+5lqMl8fh3VA0JuLUc51W/8jfJwYb4jTT0YqRtqozoZgYGWZY91xWfFSJ X-Received: by 2002:a05:6122:168e:b0:4d1:34a1:c892 with SMTP id 71dfb90a1353d-4e4f02e44c5mr8678952e0c.13.1716791921467; Sun, 26 May 2024 23:38:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716791921; cv=pass; d=google.com; s=arc-20160816; b=wVsF8vHT8LbhgRPoKDkedvsyegXU4BmWYzM91z88Rwqrv0mV4u6wpnljiBw14Ka+Rj tgrs6vnx+WoJKgfRJi7uelUgnHIyFO/Y7MPfdgvR+HL5N3WamY/6A1GmyOucvWFP9E/5 T82JxDJhyzQwyzHnXYLkVbDPuGlo51BWMFzyCXeiowCMEXBicV9O4c6+79n/zIyYI9Rb xOrAkzIfwG0tBF+x/FYX5nd4kIFhngkPWX/8uxthbQV7IZkfND4ltXa7POQ31Ce3m8S9 gTqaMq8DCjIov+Z7DOyOgSQTBKfxA80TGOmezUh/eRXBesRsJ3buyqgrAP9EQOknYSHv YEDQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:dkim-signature:dkim-signature:from; bh=VsgKp/Om0/JiwS4Uevm5ldbUKWaIwX/fMexuAWRWLGk=; fh=PbMLUItzKPZoRBvHUI9C5cxQAQuKFUSvllEZTNwnglo=; b=paSAQsAcsEfZwjrMSt3MFfjj/fp8Ss0SdSG8KwNcQ9UVclTOYyboejNmll5UKC7V3e mqx2z981jwmtlFNXIzMy9snF+IAjptV4zDDLJe/dZ02st21y9ZO1cRoeKHm1di9ffNbb lGNgQ0W+GFXhy+C8/aYlXmUQNLRKmMtqKT6n9GPEOQUmDDHFKbmNfzrTJOO/rSydxt/d EUWgkARjGCwldA2BwlrRnLKqlp5rM/T6gDRWFGmu8Mnq/sXocQ6YvR6FA3Kk6CpprIEn LKgXXeK/wXd1D0fxLK26FaytSd634sGPvi1Mm+/2K0cW6JubQSGKIgO8ZdR7fZDIwkq8 0EoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="fnA+IPe/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-190077-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190077-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794abd5fbd5si815345285a.723.2024.05.26.23.38.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 23:38:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190077-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="fnA+IPe/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-190077-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190077-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 285111C20B03 for ; Mon, 27 May 2024 06:38:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9BA81B95B; Mon, 27 May 2024 06:38:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fnA+IPe/"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="vr52uL51" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 948B620DC5 for ; Mon, 27 May 2024 06:38:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716791901; cv=none; b=jJFLUIgm8tvYX0PdEEfOMCzJllYTrqlaHZ+hbpAzvJIsZZljly8mgRFlP0daBT+hC5K/O/4VQkCaBIWuDyRKc4o+RZirlFcbatdt3zxHxMdkJjbTqQnp5NpYexjDoFS1Tr1qZjVOEASWCSJu7U8TZ7c0xUNZK681DEyCsbbdv3o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716791901; c=relaxed/simple; bh=F5yMd/Q52Xd1F+9PcUxxTx8TRVI/tWIKRAO76Ya7FwA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bztvnmqSxNSpobZoxdjk7XTbSXewT/GQ+PxVQ+AE7OW+IEQwvydtJiWordbcSYrYk3kcUL54yF6avjkJzfkHIHu+dSicXBpMJQ83WSDT9CerpSVebD36nZ5o5vq3zEdGByOH6S1Px3iCIKgv3I4VrDblfVSCwZg62t+BPb7Sp6w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=fnA+IPe/; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=vr52uL51; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1716791898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VsgKp/Om0/JiwS4Uevm5ldbUKWaIwX/fMexuAWRWLGk=; b=fnA+IPe/lpYa287E7ZsW7l10DvrTTXSfg+TWp7ojrCR2athlPwGKd2hzt1Xhk/WzQ3VoMo Ll15ZgMmOmDjPC9RTAm/4quZCq2T9nB4hmnrVqyn4mf129auIcrCktr7+KawmSkJfQZ6kO KnDT1embVlmIvGt1i0hPAW1dFczHV5dX2NqcUa2FhpwmYDun678uXAD68iuLrDauUhR605 BMAQV0aJYrpfGuho/eVvdVq2oRh9C1GSlb5CgWxfDyGKapPAs434Fg+rHSEJ/jlnwn5YQQ lYINC5XSrQSUqxGw9GS4WjbJ70CTTcQPb34q4OLIbAq5/ZLNPuhGnw9bWdGxaQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1716791898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VsgKp/Om0/JiwS4Uevm5ldbUKWaIwX/fMexuAWRWLGk=; b=vr52uL51GA4DNZfZpMUSY6Qb/GQiQ8FL9v0Qat5w1oWY6pje7KAy/A8hEeMi+6XgwUutes aRbddOa3hXL3XRAA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Sebastian Andrzej Siewior Subject: [PATCH printk v6 04/30] printk: Check printk_deferred_enter()/_exit() usage Date: Mon, 27 May 2024 08:43:23 +0206 Message-Id: <20240527063749.391035-5-john.ogness@linutronix.de> In-Reply-To: <20240527063749.391035-1-john.ogness@linutronix.de> References: <20240527063749.391035-1-john.ogness@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Sebastian Andrzej Siewior Add validation that printk_deferred_enter()/_exit() are called in non-migration contexts. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- include/linux/printk.h | 9 +++++---- kernel/printk/internal.h | 3 +++ kernel/printk/printk_safe.c | 12 ++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/linux/printk.h b/include/linux/printk.h index dbbd202b1cb3..6e1f055afef6 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -157,15 +157,16 @@ int _printk(const char *fmt, ...); */ __printf(1, 2) __cold int _printk_deferred(const char *fmt, ...); -extern void __printk_safe_enter(void); -extern void __printk_safe_exit(void); +extern void __printk_deferred_enter(void); +extern void __printk_deferred_exit(void); + /* * The printk_deferred_enter/exit macros are available only as a hack for * some code paths that need to defer all printk console printing. Interrupts * must be disabled for the deferred duration. */ -#define printk_deferred_enter __printk_safe_enter -#define printk_deferred_exit __printk_safe_exit +#define printk_deferred_enter() __printk_deferred_enter() +#define printk_deferred_exit() __printk_deferred_exit() /* * Please don't use printk_ratelimit(), because it shares ratelimiting state diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h index 739b82adc383..831f95f26d48 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -53,6 +53,9 @@ int vprintk_store(int facility, int level, __printf(1, 0) int vprintk_default(const char *fmt, va_list args); __printf(1, 0) int vprintk_deferred(const char *fmt, va_list args); +void __printk_safe_enter(void); +void __printk_safe_exit(void); + bool printk_percpu_data_ready(void); #define printk_safe_enter_irqsave(flags) \ diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c index 6d10927a07d8..4421ccac3113 100644 --- a/kernel/printk/printk_safe.c +++ b/kernel/printk/printk_safe.c @@ -26,6 +26,18 @@ void __printk_safe_exit(void) this_cpu_dec(printk_context); } +void __printk_deferred_enter(void) +{ + cant_migrate(); + __printk_safe_enter(); +} + +void __printk_deferred_exit(void) +{ + cant_migrate(); + __printk_safe_exit(); +} + asmlinkage int vprintk(const char *fmt, va_list args) { #ifdef CONFIG_KGDB_KDB -- 2.39.2