Message ID | 20240218185726.1994771-8-john.ogness@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-70501-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp911345dyc; Sun, 18 Feb 2024 10:58:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWdWRJJxy4feVjvJRgmV/kjQTDswG+1aK6c6GKeyL4XeUrxczYSwPuqZHZHTufuEqDfXDSgaARfRqwRnLvcsyhsjmuCxQ== X-Google-Smtp-Source: AGHT+IF9vEzoojz6+XN2h3iAdNccanvEqzq+exSK5yBxwsMm2c63Q6k6ued8NWbRZTsVys657q20 X-Received: by 2002:a05:6808:3c9a:b0:3c1:53cb:7293 with SMTP id gs26-20020a0568083c9a00b003c153cb7293mr4617446oib.34.1708282727652; Sun, 18 Feb 2024 10:58:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708282727; cv=pass; d=google.com; s=arc-20160816; b=vd2FyxJ/QcaagC/WpBoTbj1WmIlyIwc6n3rIEYpvhBG1WOTFAemz2SsDfZn93F6KEE X+PcwoDto12c9HhApWBVPLXal2qucLTqkevxN41nkopOMwfeY1xZkK8Kq8OjMw1datdJ 9wWoH45U8gmW0c0hc+Y7yQPbYp5AkCE1n/UQ+ZOsImZn8B6lHMeXpAaNEQZ9rFiQuYmc ezlI1BnIK5GGuvl72pVluYFKfeB6Y4r1ZmxComrA1exSj26PxRbXn1vD9ZE868/AxLd/ /GQ5IblS2ILg+saZbqCMN4eWeUFPP+GwxcxdPogSGAehSseeSkVtL9aP7l6hlfVUeLRj FN+A== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70501-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m9-20020ac86889000000b0042c2147b5d1si4422414qtq.474.2024.02.18.10.58.47 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 10:58:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70501-ouuuleilei=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="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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70501-ouuuleilei=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 70E921C20971 for <ouuuleilei@gmail.com>; Sun, 18 Feb 2024 18:58:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 26F3371B49; Sun, 18 Feb 2024 18:57:57 +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 <linux-kernel@vger.kernel.org>; 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 <john.ogness@linutronix.de> 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 <pmladek@suse.com> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org, Sebastian Andrzej Siewior <bigeasy@linutronix.de> 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: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791264269209352856 X-GMAIL-MSGID: 1791264269209352856 |
Series |
wire up write_atomic() printing
|
|
Commit Message
John Ogness
Feb. 18, 2024, 6:57 p.m. UTC
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Add validation that printk_deferred_enter()/_exit() are called in non-migration contexts. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: John Ogness <john.ogness@linutronix.de> --- include/linux/printk.h | 7 +++++-- kernel/printk/printk_safe.c | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-)
Comments
On Sun 2024-02-18 20:03:07, John Ogness wrote: > From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> > > Add validation that printk_deferred_enter()/_exit() are called in > non-migration contexts. > > --- 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); It seems that these two does not longer need to stay in the global linux/printk.h. The declaration can be moved to kernel/printk/internal.h (with 'extern' removed). > +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); I would prefer to call __printk_safe_enter() here to make it clear that they update printk_context the same way and have the same effect. Let's make compiler to do the inlining. > +} > + > +void __printk_deferred_exit(void) > +{ > + cant_migrate(); > + this_cpu_dec(printk_context); ditto > +} > + > asmlinkage int vprintk(const char *fmt, va_list args) > { > #ifdef CONFIG_KGDB_KDB With the two changes: Reviewed-by: Petr Mladek <pmladek@suse.com> Best Regards, Petr
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