Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2356640lqz; Tue, 2 Apr 2024 15:12:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWQZrDJM7Jz27a2EHzdlhUac7qhFPX9+Q0L93UU/7oAC08GIUv5Svt2buma5ZvKg2R08wl2P+0+GraXhp4Z7Ud5nvW3R/GmUH0z9cV+iw== X-Google-Smtp-Source: AGHT+IGjqmIsBoSeKVNHYlkXBM1RcgwaCTQmnaJW/WuyOwcyJWASie7UHZHAHq1+lT6zj6t8zHdV X-Received: by 2002:a05:622a:1d4:b0:432:dcf1:398b with SMTP id t20-20020a05622a01d400b00432dcf1398bmr1373026qtw.33.1712095966899; Tue, 02 Apr 2024 15:12:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712095966; cv=pass; d=google.com; s=arc-20160816; b=PptF0/y0Dzc7ou3n7JhDSSC3X1Jh4jbbYr+jEfOb1Ddx4WoJt14xzDDmBWWDcRAfnX ++Cuy26Iy1YyuMmZ4r/Xl/LhEyGAGfLINFzSzou49wjwmdphPTMnBcpze1ql5+nnUrW8 xbS80/VMcaloM4PoVPKqGEcZTP95vFEdycygNVNmG4SQ+lTVyIs7sfZGR5Mf1w07dppk 5P89KW6CunzKln81HnwcXRJRI2yRDBeAn1layZ0T8czVi2yiH0mtlX4bU+tlk3HXhZg8 uNFlDYtioo7LA5lR28Pc4evBjlTLB3dVzbJGoLQ9GxYfJVwd7eu2Z2oEYvdb0zDwRTSo 6nvw== 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=j7f10dybj3FQO66c59r1wqvQXH3mAcKwMAOFWXgWZuw=; fh=PbMLUItzKPZoRBvHUI9C5cxQAQuKFUSvllEZTNwnglo=; b=nyctH1saUin72sSnhf16yjeBUA0SsTkiogrTMICvVXs9wvOpvqnvp0kzzml7Zi5LwY 88kUwhcjqpJ8RIb0dy9V7ZxHm7OLK5iTTUFSnjnT4ZtYTOOxKvVezO+ew6kpNPV3eUks e1VQE2TQ3UDWuy+RtZ22o7+dSMo4XEBgdWpbbz48hjZ3XShVeYYMMT8dS9r6ah7pJv1u 5XK+kpx0nccnU5t6XCZecynQLUpuzNrH0x3eLxKm/j17d7fisoDrIMzqWCbdDNEIxBnB E25cww5Y4wN1le/CS1gcg8gMRj/zBaC8Fw4yJdv39UfJe7ca3LyG+HPDy6QU6G/nYD5v c+nA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JmpaqF7h; 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-128764-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128764-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f15-20020ac859cf000000b0043149b75298si12556777qtf.230.2024.04.02.15.12.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 15:12:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128764-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JmpaqF7h; 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-128764-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128764-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 9177C1C24420 for ; Tue, 2 Apr 2024 22:12:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C189D15EFC8; Tue, 2 Apr 2024 22:11:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JmpaqF7h"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="It7qU4S/" 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 1164B15ECD9 for ; Tue, 2 Apr 2024 22:11:36 +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=1712095898; cv=none; b=q250+hZ1S/60hl5ndwclzvitLdNbifQk/56BRyJ/DGcfvbgBWkZFm8vxH50Xd9k1Yd7cJHB2AZNbLwDzCghQOU1NveTjuEsAtn26C/QQvfE+OAYrDUBr0WzR5CYLTqIKGHT7z2zRVHT+Eny30Q3BKmDGrUr5zpFDMuKo4Y7MdRs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712095898; c=relaxed/simple; bh=jrBdWUk0rwcYI/oiQlw6iijdJI0T4nkboPn0QdreNXc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MwVJwpDlYnyYT8hZC1owkeKDVAobBDOGVvVuEOaMgmXgny2S7ydZPwfDJ8sfpvW2IyzLP2CHhV6cgEi+yh8/Ymdgp19KJmSkR5Nu1kThXrZhJ38pmNT+BlRpsKEErNlz4v+KaAUkue1Oe2vHxBUv70nzccH7NS6r3OJDBt5SlyU= 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=JmpaqF7h; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=It7qU4S/; 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=1712095895; 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=j7f10dybj3FQO66c59r1wqvQXH3mAcKwMAOFWXgWZuw=; b=JmpaqF7hZ4FLu5RF6TYpoK+3EfVmWLLlR1kWZ951pqeuaLSVsruuIVzTy6aaO/tC/Dxm9d hFvGW0qCA4jzr8usSgmVTikp0EqQ/j+2QhvNHf6TWoN71TDBYcqiLZb5aTnNIn95gcVe/o tPQ1jvi88p0C5VnvaBkElqTJbKX4X/ZQbHQH1C3tPgOb3uuj3Y8bg83Pj6sH4tigHzI3K5 4G+Hpcu8KxOKSNcfSeZVhnzpu/BvQVCjIqMmiAH73JUmRiUrOyWDANmc7Zf4RCoUqE+3u3 +eh7DqaBWXlJzVKJ8uMd78Mkus0+6QrmGMyBHEf4uqAiEMQYs91RjCzsrD/azQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712095895; 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=j7f10dybj3FQO66c59r1wqvQXH3mAcKwMAOFWXgWZuw=; b=It7qU4S/vnwflESxCbemUum5nBq739Y9mSUdt7m9223da5g7xjBH38haOBKxn7mA0UQIjv VnrH766dSMsTngDg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Sebastian Andrzej Siewior Subject: [PATCH printk v4 04/27] printk: Check printk_deferred_enter()/_exit() usage Date: Wed, 3 Apr 2024 00:17:06 +0206 Message-Id: <20240402221129.2613843-5-john.ogness@linutronix.de> In-Reply-To: <20240402221129.2613843-1-john.ogness@linutronix.de> References: <20240402221129.2613843-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 6c2afee5ef62..4e0edcb3c311 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