Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp303083pxj; Thu, 17 Jun 2021 03:08:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiadrGmA+CXpRPOWRj+1DxmDBOcY6InGHbmWwP5bEb5v/hq/gibRGUn5nQP1Zcis2DAB7N X-Received: by 2002:a05:6602:2bfa:: with SMTP id d26mr3170689ioy.13.1623924509066; Thu, 17 Jun 2021 03:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623924509; cv=none; d=google.com; s=arc-20160816; b=cQ+bi4q8YTuNIEkAG6N2p3X88X/kafCK/2qYaMohpV4FzGaRz4J/qhygwD0KVUHxeX WkQ/x8WFF3Y+uMJc2SINs+sWDx0OJEpaRcLQ4OGpAQF9DdYx+GkiBgnnKbYmpAuy8OW+ yy/sy4blLBo4By2evwFJgEGoB0tA4Ohlnqnsl9GK4cITFEnD8QQU5nhSCLcIctWVC2ZB Ld8DRpv5cydv/zN0UYPrgstzjEROLJMklUQvhHbE8daFfDf79WXmD+GTC+zgPIeYVTTZ LiCl3pKY/ot+wFNFLE6IA43rIsx3KG7P0Eh5Iz1cyGYyvkyNFmXa4PqXFTCMlMGo90XR 3gRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:dkim-signature:from; bh=WTnw3zMyd8z+pIa0tw6p23b8itwiBN3kbhbrx5ETz5o=; b=nWRSeERI6MrooC7nJvLLBPEZJJe238lTUricXVjyN8Fs18fu8GKJx+6g/a+KGCbvwE LfjgFe3e/e+3zpG8N9o32tnvn+/aWSG/lghU8iIyxlrRUMj643Y/N+WX+W96RtMGXpWs Mw3rrjr+Qx5t2Zb+OkbprOuRJYmdI/w1YhxXxE2z/szdSiXzQYod4Gq89hDopJ9Y2cOU YadXdt/vfGJ2FQonsi6r5G3xhp3O5EG31VzxPhJr78/PWzJA78m/99HPT5J5l5qfxMvz QHHw52z5+v4wlsvvkO99Ei6JmpU2iwdKspIXmkkVd7Qh5eVdN8RyxG+dCI1aynoHUOIH WhaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="fvujx/l7"; dkim=neutral (no key) header.i=@linutronix.de header.b=XuWDgIqP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n5si6125037ilj.6.2021.06.17.03.08.16; Thu, 17 Jun 2021 03:08:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="fvujx/l7"; dkim=neutral (no key) header.i=@linutronix.de header.b=XuWDgIqP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231521AbhFQJxC (ORCPT + 99 others); Thu, 17 Jun 2021 05:53:02 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:47682 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231873AbhFQJxB (ORCPT ); Thu, 17 Jun 2021 05:53:01 -0400 From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1623923452; 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; bh=WTnw3zMyd8z+pIa0tw6p23b8itwiBN3kbhbrx5ETz5o=; b=fvujx/l7221PjikdVNLT0v4IE80gasws/MTw1YEq23CeKQh9mPERZ5fyEtzc8X+Rrnm7JE 3RFoezoJDT0xd9fuCfMQXGOyoZUn1vnGjHLCFy5A/WAuhmXPUtpLA61fT7RbjZy19IWDEu gsItRcgY06azwCY0CnIJ43K6s4QO1SgMkPHoVvcCy5zF/hIV6oLhMeYmiWXPncIzevHve5 MzhwDjAOy9QcaEmQh7m1gzUgm2IIcOQGZu59hhalKfQnwE0ztVtuALubY1AVogd1HQuI4R g8fGTnfYoYX2sWKvpDBaWi+gUK8ncI6Pa1et5MGHasjmyncpmvIakYaLvMOvGQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1623923452; 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; bh=WTnw3zMyd8z+pIa0tw6p23b8itwiBN3kbhbrx5ETz5o=; b=XuWDgIqPLvk4AmbkJeJAajGOjiOkd3dg5tmrAwoJu3W+ouoRqe+Hkj22KSTpjESb8gPsri 96yCp9Av3LiNtFDQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Stephen Rothwell , Andrew Morton , Peter Zijlstra , Daniel Bristot de Oliveira , Stephen Boyd , Alexander Potapenko , "Paul E. McKenney" Subject: [PATCH next v4 0/2] introduce printk cpu lock Date: Thu, 17 Jun 2021 11:56:49 +0206 Message-Id: <20210617095051.4808-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, While working on removing the safe buffers for printk [0] we stumbled on a cpu-reentrant spinning lock used by dump_stack(). This type of lock (dubbed a cpu lock) will cause deadlock risks once we introduce atomic consoles because atomic consoles also need such a lock. Although we are not yet ready to introduce atomic consoles, this is an appropriate time to provide an official cpu lock to be used for all things relating to printk (including the atomic consoles, once they are introduced). An example of cpu lock usage for atomic consoles can be found in the PREEMPT_RT tree, such as the serial8250 implementation [1] of an atomic console. (In PREEMPT_RT the printk cpu lock function was named console_atomic_lock/_unlock.) This series is against next-20210616. v3 can be found here [2]. Changes since v3: - Change @printk_cpulock_nested from a boolean to an atomic counter in order to track multiple levels of nesting. - Correctly move over the original dump_stack() semantics by using atomic_set() to unlock. - Move commit message note about disabling interrupts to the first patch. John Ogness [0] https://lore.kernel.org/lkml/YGW63%2FelFr%2FgYW1u@alley [1] https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git/commit/drivers/tty/serial?h=v5.12-rc3-rt3&id=1aaca59df62710647243a3574fc27d93c2bd0e6c [2] https://lore.kernel.org/lkml/20210615174947.32057-1-john.ogness@linutronix.de John Ogness (2): lib/dump_stack: move cpu lock to printk.c printk: fix cpu lock ordering include/linux/printk.h | 41 +++++++++++++++ kernel/printk/printk.c | 116 +++++++++++++++++++++++++++++++++++++++++ lib/dump_stack.c | 38 +------------- 3 files changed, 159 insertions(+), 36 deletions(-) -- 2.20.1