From patchwork Mon Mar 4 17:20:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 159559 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4010190jad; Mon, 4 Mar 2019 09:21:02 -0800 (PST) X-Google-Smtp-Source: APXvYqzkyrBXIO4wjBLEWoWRYBzOFg7tgZNIE+PVorCSckqarOpe/gcV/fV6AnHNv3tZPlmO2HkP X-Received: by 2002:a63:3648:: with SMTP id d69mr19534856pga.314.1551720062274; Mon, 04 Mar 2019 09:21:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551720062; cv=none; d=google.com; s=arc-20160816; b=xquSI6YdLJg/hd6+haHYGr3OIv/nJ0Xlw34wXl9tSJtPMWIxFhqROZ3jTtQFTIMQ3z 9q7Gkubid6Ebh7zjYArJu5T77RnkXMOuhZN8GerEi+HRUlg5f0T9EOsYdTZwc+9Swv0w FeHrPxVq9eGI1bxwYNh7IE0m8sI2xgAQI9gm54ivFBo5l3bTJjZSM/YtyQ64qednxRB2 u/RObLTQgme70rAl+/otRTsN/VN0hTOXc/6vvDbMyS/Q4uZAMbUXHHmF3oPkoXv36YhJ zXUewpR+hJxGFjSWWE5LbsqS2XkcOh5HZhbl4ZmIK3de/XJUVMkQtnlJS2pozgCBDzUq vjkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=eEmCkH6sBGIlggk/s9DcLLWAU6oGaYIvNKvWbf7zcmM=; b=q+6YYDRgVccWrCcvmhweBmDn6L5gqkg6tKDXAdf4Adr/EEMbbBPT/iVgql2xW2lNJ+ mmHjTcr/xLI1XuJECiw1ByhxIN1dhzz++NW30IqB5yUH0JDxMFJJUUlt6QzqCst0zVqV qR4XdL5maPNz2VWORmcmt4X3wa3ggLBF4+OHB28mbjueYP5KhV7ynY8iqQbTiyn/UoXs ykRMUT1pVAkU0ejmm+ZwHFErS1cF098yPOG/EB+COgU9dsVJU6aWm6mn9/6KdQyvCW83 yvFrBHXR1eRxNzDmzOVc+0CdC3k+aLc/4pVzxRxY2q6H10kaCLS8yi4Y4qW/RmEvT3zd Wh1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q65si5631938pfi.185.2019.03.04.09.21.01; Mon, 04 Mar 2019 09:21:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727136AbfCDRVA (ORCPT + 31 others); Mon, 4 Mar 2019 12:21:00 -0500 Received: from foss.arm.com ([217.140.101.70]:36322 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726098AbfCDRVA (ORCPT ); Mon, 4 Mar 2019 12:21:00 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 979BBA78; Mon, 4 Mar 2019 09:20:59 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8714C3F703; Mon, 4 Mar 2019 09:20:58 -0800 (PST) From: Julien Grall To: linux-kernel@vger.kernel.org Cc: jslaby@suse.com, gregkh@linuxfoundation.org, linux-rt-users@vger.kernel.ort, Julien Grall Subject: [PATCH] tty/sysrq: Convert show_lock to raw_spinlock_t Date: Mon, 4 Mar 2019 17:20:53 +0000 Message-Id: <20190304172053.17340-1-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At the moment show_lock is implemented using spin_lock_t and called from an interrupt context on Arm64. The following backtrace was triggered by: 42sh# echo l > /proc/sysrq-trigger [ 4432.073756] sysrq: SysRq : Show backtrace of all active CPUs [ 4432.403422] BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:974 [ 4432.403424] sysrq: CPU6: [ 4432.403426] in_atomic(): 1, irqs_disabled(): 128, pid: 2410, name: kworker/u16:2 [...] [ 4432.403581] Call trace: [ 4432.403584] dump_backtrace+0x0/0x148 [ 4432.403586] show_stack+0x14/0x20 [ 4432.403588] dump_stack+0x9c/0xd4 [ 4432.403592] ___might_sleep+0x1cc/0x298 [ 4432.403595] rt_spin_lock+0x5c/0x70 [ 4432.403596] showacpu+0x34/0x68 [ 4432.403599] flush_smp_call_function_queue+0xd4/0x278 [ 4432.403602] generic_smp_call_function_single_interrupt+0x10/0x18 [ 4432.403605] handle_IPI+0x26c/0x668 [ 4432.403607] gic_handle_irq+0x9c/0xa0 [ 4432.403609] el1_irq+0xb4/0x13c With RT-patches, spin_lock can now sleep and therefore cannot be used from interrupt context. Use a raw_spin_lock instead to prevent the lock to sleep. Signed-off-by: Julien Grall --- drivers/tty/sysrq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.11.0 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index 1f03078ec352..8473557c7ab2 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -208,7 +208,7 @@ static struct sysrq_key_op sysrq_showlocks_op = { #endif #ifdef CONFIG_SMP -static DEFINE_SPINLOCK(show_lock); +static DEFINE_RAW_SPINLOCK(show_lock); static void showacpu(void *dummy) { @@ -218,10 +218,10 @@ static void showacpu(void *dummy) if (idle_cpu(smp_processor_id())) return; - spin_lock_irqsave(&show_lock, flags); + raw_spin_lock_irqsave(&show_lock, flags); pr_info("CPU%d:\n", smp_processor_id()); show_stack(NULL, NULL); - spin_unlock_irqrestore(&show_lock, flags); + raw_spin_unlock_irqrestore(&show_lock, flags); } static void sysrq_showregs_othercpus(struct work_struct *dummy)