Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3318709imu; Sun, 11 Nov 2018 12:15:46 -0800 (PST) X-Google-Smtp-Source: AJdET5eHtkTir4Wv/3AgrtgoJioNLSYv47v+KvoBYQjPF0ZlF6kIr4vgC56oBYKnkOvog530QjiP X-Received: by 2002:a63:ba48:: with SMTP id l8mr14744298pgu.72.1541967346264; Sun, 11 Nov 2018 12:15:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541967346; cv=none; d=google.com; s=arc-20160816; b=vH68mQTV672RcD0zWQjkvMLTJ3C92yuaukkORavZ/27pTLEoeuWA9shhWtyJaJM6Wu qMTAwUTxe2l4yt2VSojOz56qvKPqc+HxSqYwIYhUjIS8laR06M16wENJ0u4RAVVO9vaf bNpnkqqUF0q5Btt66tUHDNGzeRFSkaYClx5qYsCw5GjesLEcW/0sA4r6U53jvCacvx2Z tCjtnFyXmOY1HeOgDtonwEUjKF+/4ZbZEy7nUD08PH0evVV7H2W4QWInjmWrTCfInrWA RFYyzm5mN420fZDvH81Cp+NCp6Gib8pQz7iGBTm3a9yNnWVrArYZ/KKYHOcfcrmDjkzC i+tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=PVu4xJuDQhJacfR/saS+AwRxBmELTooqyMEk9fx4Sig=; b=oqkLU3AQ/cOkcLPoAeNXHCqr32plbuRfrHKxgHoWxbdzMCdE2KxBf1coDlxK/Gpcp9 cf/e5LrsdL6L9Bc6PXqRDt6yZjPE5lD4mRf7u49wI0/a2aRCCJP4HCc63rzr4MqAfT53 I8AXw9zjXYJVbDyrhEjj6Fo7eHRF1L8TB3vTkI/jqZlm8+K+j16XkqsbfsgMr1K+LgcD xyZYNVe/vH75DKPvfPSMVyAoCb4zrx0BRRbPyb3Ww4sEri2TPr5rAJH+nz/2S8JR8aQ6 zhrmOTqf+/DwEMrgopvW6Q3AIyTCy2rP6QJdKAQijPNSOViVTlbbR782LpK+7SNZs1CX QXOw== 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 y5-v6si16090475pfg.52.2018.11.11.12.15.31; Sun, 11 Nov 2018 12:15:46 -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 S1731470AbeKLGDZ (ORCPT + 99 others); Mon, 12 Nov 2018 01:03:25 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:52782 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727144AbeKLGDY (ORCPT ); Mon, 12 Nov 2018 01:03:24 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvtD-0000oO-Kr; Sun, 11 Nov 2018 19:59:23 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsO-0001Ob-Ai; Sun, 11 Nov 2018 19:58:32 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Joerg Roedel" , "Lu Baolu" , "Joerg Roedel" , "Dmitry Safonov" , "David Woodhouse" , "Ingo Molnar" , iommu@lists.linux-foundation.org, "Alex Williamson" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 032/366] iommu/vt-d: Ratelimit each dmar fault printing In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Dmitry Safonov commit 6c50d79f66382d78918a768374839d6d1b606d3f upstream. There is a ratelimit for printing, but it's incremented each time the cpu recives dmar fault interrupt. While one interrupt may signal about *many* faults. So, measuring the impact it turns out that reading/clearing one fault takes < 1 usec, and printing info about the fault takes ~170 msec. Having in mind that maximum number of fault recording registers per remapping hardware unit is 256.. IRQ handler may run for (170*256) msec. And as fault-serving loop runs without a time limit, during servicing new faults may occur.. Ratelimit each fault printing rather than each irq printing. Fixes: commit c43fce4eebae ("iommu/vt-d: Ratelimit fault handler") BUG: spinlock lockup suspected on CPU#0, CliShell/9903 lock: 0xffffffff81a47440, .magic: dead4ead, .owner: kworker/u16:2/8915, .owner_cpu: 6 CPU: 0 PID: 9903 Comm: CliShell Call Trace:$\n' [..] dump_stack+0x65/0x83$\n' [..] spin_dump+0x8f/0x94$\n' [..] do_raw_spin_lock+0x123/0x170$\n' [..] _raw_spin_lock_irqsave+0x32/0x3a$\n' [..] uart_chars_in_buffer+0x20/0x4d$\n' [..] tty_chars_in_buffer+0x18/0x1d$\n' [..] n_tty_poll+0x1cb/0x1f2$\n' [..] tty_poll+0x5e/0x76$\n' [..] do_select+0x363/0x629$\n' [..] compat_core_sys_select+0x19e/0x239$\n' [..] compat_SyS_select+0x98/0xc0$\n' [..] sysenter_dispatch+0x7/0x25$\n' [..] NMI backtrace for cpu 6 CPU: 6 PID: 8915 Comm: kworker/u16:2 Workqueue: dmar_fault dmar_fault_work Call Trace:$\n' [..] wait_for_xmitr+0x26/0x8f$\n' [..] serial8250_console_putchar+0x1c/0x2c$\n' [..] uart_console_write+0x40/0x4b$\n' [..] serial8250_console_write+0xe6/0x13f$\n' [..] call_console_drivers.constprop.13+0xce/0x103$\n' [..] console_unlock+0x1f8/0x39b$\n' [..] vprintk_emit+0x39e/0x3e6$\n' [..] printk+0x4d/0x4f$\n' [..] dmar_fault+0x1a8/0x1fc$\n' [..] dmar_fault_work+0x15/0x17$\n' [..] process_one_work+0x1e8/0x3a9$\n' [..] worker_thread+0x25d/0x345$\n' [..] kthread+0xea/0xf2$\n' [..] ret_from_fork+0x58/0x90$\n' Cc: Alex Williamson Cc: David Woodhouse Cc: Ingo Molnar Cc: Joerg Roedel Cc: Lu Baolu Cc: iommu@lists.linux-foundation.org Signed-off-by: Dmitry Safonov Signed-off-by: Joerg Roedel Signed-off-by: Ben Hutchings --- drivers/iommu/dmar.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) --- a/drivers/iommu/dmar.c +++ b/drivers/iommu/dmar.c @@ -1483,17 +1483,13 @@ irqreturn_t dmar_fault(int irq, void *de int reg, fault_index; u32 fault_status; unsigned long flag; - bool ratelimited; static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); - /* Disable printing, simply clear the fault when ratelimited */ - ratelimited = !__ratelimit(&rs); - raw_spin_lock_irqsave(&iommu->register_lock, flag); fault_status = readl(iommu->reg + DMAR_FSTS_REG); - if (fault_status && !ratelimited) + if (fault_status && __ratelimit(&rs)) pr_err("DRHD: handling fault status reg %x\n", fault_status); /* TBD: ignore advanced fault log currently */ @@ -1503,6 +1499,8 @@ irqreturn_t dmar_fault(int irq, void *de fault_index = dma_fsts_fault_record_index(fault_status); reg = cap_fault_reg_offset(iommu->cap); while (1) { + /* Disable printing, simply clear the fault when ratelimited */ + bool ratelimited = !__ratelimit(&rs); u8 fault_reason; u16 source_id; u64 guest_addr;