Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1424788lqm; Thu, 2 May 2024 14:39:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXpMc1DIZ9vfXEJFs9V6nnt9bjycyOr6MqgJEJ/FdQm6oLwjOlnrRl7h1wZ/zKry0UhBJV/RoOzPTbmuq+0YanXda1VGwQuRFi7FxgaEQ== X-Google-Smtp-Source: AGHT+IHo+ikLISGCgDb5sVanhiHANup+5zdppu/FlxhMnIYJgT0qJAgmuJVIcUn9YEwo+MgT9/+S X-Received: by 2002:a05:6122:c81:b0:4ca:615e:1b61 with SMTP id ba1-20020a0561220c8100b004ca615e1b61mr1094018vkb.10.1714685954660; Thu, 02 May 2024 14:39:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714685954; cv=pass; d=google.com; s=arc-20160816; b=sQn0qO/Txo2FgxpyOE7S8so27INaFHPmskcfj1DKf9kI3jv1XJL+K2wTx4UuFljY7w Vod3uDI8lweVn9vmUCz0SHe9phNEIbl9ZPa9+osCfiLC0yAMoqNwfmvaEBbPTRW5rCVX Yqos97cXNov6+aTIWsWMAMif9kAPkaihythfZ4nJwHaDTNu8CGSja6hBsGa4fYh0CSiX SznoNFbDdKrpFPA7sJ0k15vSSwoXEDcC6wMCM11yz5WefvRoTdm/TS+rGqWxjn4MjSW8 BGbQbyohZG1L443C39voOZkvobuNMuXWe2fMaEfT5pEX+8pXpTrWI3eK2Cu3ZP0JlbgK 2iIA== 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=iGNvVJcsNgc3jll4nDoPF6g4hs94SRVjeR/SV60Zi28=; fh=PbMLUItzKPZoRBvHUI9C5cxQAQuKFUSvllEZTNwnglo=; b=dLGviJVDpUmkmUgXrW2UeZl53OoJ+QDB/gAf0DQ/tW/3t/o2fWhsRKyv19qAYlt2bC 1jYGTdSEzriroav915e8c7XzPCUgM5VdStLwO+lUt+XSC8ehsVfM4txR+nboICEjllix 46q8oWf39HpiHH6inXx0Ap/l92OfcQvTd6hiXWPo2JegCOgmcR6TwJNGBYxDgp+r+bGT aArk1n0ctVK8wX6BI1JkJhBWFFU+QHqb5WuVwpRGTh0f5i4C94730JjHPM7X7NJiLeNv 0X/NDpJL5Uuy85E31WzBExEb8jweZ3mwRFyv42d+XFOD2OlG5dFcA26grb9ZYxyYPxo2 g+kw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mHVEbyNa; 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-166955-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166955-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 r4-20020a05622a034400b0043abcd7af21si1990415qtw.200.2024.05.02.14.39.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 14:39:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166955-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=mHVEbyNa; 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-166955-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166955-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 643211C21BB8 for ; Thu, 2 May 2024 21:39:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7AD6219DF7C; Thu, 2 May 2024 21:38:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="mHVEbyNa"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tdV4BBLA" 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 2A03518132D for ; Thu, 2 May 2024 21:38:46 +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=1714685928; cv=none; b=gdlDkKh/jmWcX2PEOGwiH3mFqrnaNetNriQiSqb1Cw8q0O7tAX9G99KHu2U3Clk/HssKv1mDtheV59qPJ97gN2Br9/98+AkLaDnbS7owVK78dwax1eoS0IMrP5BsY3fE1MjVTxt51W6VrJBD5RSE3mMF+Lcyz0HEl6J08A9lxMI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714685928; c=relaxed/simple; bh=NbX9KqSu+VKC9sOzIh/s7S68iv2vejeD4ejGhNdGI1Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XXGa/37Jjtmypn5BKtF3/dpksK0AvJIGezqwokHPVsQxCidsQ7jbLHnrTSRHcJ71PNnotX+W2mc2OWwrAnjgHVHt3gtkaW6kWW3CVg6MWOVF4w+Qoao1+xJlklA/HZXVSBGeJ/HFsRhePyV1v4O/iXA/vbS4eEmshFnFe0bnLfM= 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=mHVEbyNa; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=tdV4BBLA; 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=1714685925; 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=iGNvVJcsNgc3jll4nDoPF6g4hs94SRVjeR/SV60Zi28=; b=mHVEbyNadP/y1Aos7cR+kyTwG2WXBYdr8zim+Ij95yqUPwx6QXNQxyleYFc2zrkmmGhdVW vOmnUG0r/5prUSrKhwh3UIfggbBnjvJtw7vRaYUuaDKRonp+K/a6bFHyRk6O0YfOcFrDkL 59VqfLSWbH9DIb/62uQ9s+PGFiSgU7avdjgtVQxgJ0ILBCehAPCBgEWI0rAS2ycnjLY0Q6 tEB1j/WqhJ81rPRc1e+aAYmjP/7aTCQRKLrZLwKheHQdluicbuEQpF7IakMWUU6G4ji4TR Sphs4L3GeGiL33C8Eso/uXs5xPjF9wsasW8pZ4F8+b6VlDu856phRvMto2O40w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1714685925; 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=iGNvVJcsNgc3jll4nDoPF6g4hs94SRVjeR/SV60Zi28=; b=tdV4BBLA7zeb6GnBsc/iksSNwSqxn2/A5A0Hj8cJEN8Qlx3pEaJZejdQjtpdTBvFTCfMLr s4uskHnUNj9VDQCw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Sebastian Andrzej Siewior Subject: [PATCH printk v5 04/30] printk: Check printk_deferred_enter()/_exit() usage Date: Thu, 2 May 2024 23:44:13 +0206 Message-Id: <20240502213839.376636-5-john.ogness@linutronix.de> In-Reply-To: <20240502213839.376636-1-john.ogness@linutronix.de> References: <20240502213839.376636-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 2fde40cc9677..d8b3f51d9e98 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