Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp771809rdb; Sun, 18 Feb 2024 10:58:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXYlxaA/kU0bcyFzn49sHRp+gJiwgJxFW+CFDVUxETPWK3EYbUH+1/AScsCJMhQxlCvL1n0yV3aCxcN7Ose+Bqq8krYlRk6OUX+iB43ug== X-Google-Smtp-Source: AGHT+IECmBy2l7g9UC3LEgXYtbEt4XDeaij1/imLJrH5rDIj2QbEM6uqVn/VlKmRCGadVO0In0V6 X-Received: by 2002:a05:6a20:9f05:b0:1a0:60b2:45e with SMTP id mk5-20020a056a209f0500b001a060b2045emr11296334pzb.9.1708282689429; Sun, 18 Feb 2024 10:58:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708282689; cv=pass; d=google.com; s=arc-20160816; b=D45R8vQsiHi9OxhrI3/CMpFFmWOIQWoI/cBQF/pOC0MoqkMH0aJRIkzoJM23cvIWqj 49AkId+NFS6x3xJ1ZzcO7pob4IIfTWPrnSNZQ7UDbwvvc7rEob/Qdghl79OmVrZ0ONIO X8UKB/NWZjEgitjpcF268JUYoMK2gbXAu781t2qDatH4FEtbAiM1tGvmBMHjD6j691v6 UH5XhyuXNSV46DxVH3lr8Sr8/s9lLUFP67LEf1haGXnWeyijp1sJ/UZnXQOdH0tnyMAz ujwFGcBAMYNFDf9qkQQqnwA52UdGcVBkbdtGot1YRcS6jLeyncGmU/KDtUyzSLRsr3k4 95Jw== 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=rhiYAxJ52E/enQP4Ayf/MIif8Xm2i96p2VSKi7x6/pk=; fh=PbMLUItzKPZoRBvHUI9C5cxQAQuKFUSvllEZTNwnglo=; b=FAiIjIpWMlKJ0qlPSbsFXKAd9CKJ1h+aqXNPrwuQjn96Y+0dfTLHon79hXSVUcsTtx +w6xAaqRJyZ1twxWeGdJn4OqTT8/5zgwR8mqmHuT6yWIv8CxUyPQ5cJ+Kn0SvygSjnIJ y2PNBdIbm5uHvp8fgkPk1zdDEEqJGHPNAAMfG8iV1QOujkG6qBO10KlMLBpw16VjJPE5 jlsiWNZr4UzD7cpD3UlLwJNddISf0oZpOPNnFayjrM0w3wAzYLMARl8yX3vHtZCYx8hf tLaIlpgxftCZ5mmC82oM1cusRu58XLg2VYgoWt7a1H8pvBk2+qj4tYkoNw0YfWtJ/HTI 4bog==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Z/8tYXT2"; 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-70501-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70501-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m127-20020a633f85000000b005d8b8c6f94csi3190485pga.565.2024.02.18.10.58.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 10:58:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70501-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Z/8tYXT2"; 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-70501-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70501-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 242D22819BF for ; Sun, 18 Feb 2024 18:58:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4F5F6F528; Sun, 18 Feb 2024 18:57:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Z/8tYXT2"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="i9pMn/EB" 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 867256F09A for ; Sun, 18 Feb 2024 18:57:52 +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=1708282674; cv=none; b=i17QdP1VY/RTZXJDka9/mDBWz5zavUzQZZ+rs1x6oSy/3UnayIQLh8RkVriMG6LfYg2SeWVeDAts1/qiT+eyS+mRSHqCBTesZ0OOYx2EQ1gLj+pkQImwHhSr5aDnJX3XkJ9KrbDPqYO82m926+lkZMDsNYAp/fJbfJPF9iF5gSs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708282674; c=relaxed/simple; bh=QUm3HonFr4bI9kdM8sLrYXTcDYUW2kypDJWENyu683c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WjCMBKPat0XMtGHi0sO76J4FnPHFGwYZ3L7KbJRzLJYMKyeN1PI+eE86YXrSaMlVEVcr0Ovcjj7uxugMK8AvnsjaJCGtXCdJ4K/pscVYgPp9gAzz4KawjsgGTXxJ5ZsAKRPL08YiMbxFaQFW0X5VCqZHCfsIuybl0ofOv4Uex8c= 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=Z/8tYXT2; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=i9pMn/EB; 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=1708282670; 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=rhiYAxJ52E/enQP4Ayf/MIif8Xm2i96p2VSKi7x6/pk=; b=Z/8tYXT2WSDAy/oWuJCJWbFDqgYvMv1StysN1afFGWiaizrs1Sey8dbHymursqMg64AOxu 8y3QmJDsjKSQsXAg9Xq7OL35hf0l20OSbsFDRS1bpet71gqBMKUzO23Nft/f2TZkFaCQQJ 1VTKQ4aEuBfNEMI3CmjUMOzSEDx7WFjsaU8jEf4gxH+EKyJcEPpDplzpU3P9MHt2cm5/jO gg4482yTJPtLbcRrLt+gJOCyqWS3gjRtuBMfK1Jr6J3j2lS2//JhLt19l/q3Onn9y6fIzD 6uinp4xNsIoaOBEk34ufZOFS/TEUy33xfgohPM1mPd+IXv8IWmDIPngc13shyg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708282670; 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=rhiYAxJ52E/enQP4Ayf/MIif8Xm2i96p2VSKi7x6/pk=; b=i9pMn/EB1LeNHwwoyZzphndAhEQPz7vVuj1gMJibIlEhslNTv+R6kLlQ5h+5I24cS/nFdG v5uWCEVLIW/zfIBw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Sebastian Andrzej Siewior Subject: [PATCH printk v2 07/26] printk: Check printk_deferred_enter()/_exit() usage Date: Sun, 18 Feb 2024 20:03:07 +0106 Message-Id: <20240218185726.1994771-8-john.ogness@linutronix.de> In-Reply-To: <20240218185726.1994771-1-john.ogness@linutronix.de> References: <20240218185726.1994771-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 --- include/linux/printk.h | 7 +++++-- kernel/printk/printk_safe.c | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/linux/printk.h b/include/linux/printk.h index 955e31860095..8d5c5588eec9 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -159,13 +159,16 @@ __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/printk_safe.c b/kernel/printk/printk_safe.c index 6d10927a07d8..8d9408d653de 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(); + this_cpu_inc(printk_context); +} + +void __printk_deferred_exit(void) +{ + cant_migrate(); + this_cpu_dec(printk_context); +} + asmlinkage int vprintk(const char *fmt, va_list args) { #ifdef CONFIG_KGDB_KDB -- 2.39.2