From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934875AbcCORLF (ORCPT ); Tue, 15 Mar 2016 13:11:05 -0400 Received: from smtprelay0046.hostedemail.com ([216.40.44.46]:43803 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932351AbcCORLC (ORCPT ); Tue, 15 Mar 2016 13:11:02 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:69:355:379:541:599:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:4031:4078:4081:4250:4321:5007:6119:6261:7903:10004:10400:10848:11026:11232:11473:11658:11783:11914:12043:12296:12438:12517:12519:12555:12679:12740:13439:13894:14659:14721:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: laugh96_7c21dc06fc916 X-Filterd-Recvd-Size: 3179 Message-ID: <1458061851.11972.193.camel@perches.com> Subject: Re: [PATCH] iommu/vt-d: Ratelimit fault handler From: Joe Perches To: Alex Williamson , iommu@lists.linux-foundation.org, dwmw2@infradead.org Cc: joro@8bytes.org, linux-kernel@vger.kernel.org Date: Tue, 15 Mar 2016 10:10:51 -0700 In-Reply-To: <20160315163503.2875.49980.stgit@gimli.home> References: <20160315163503.2875.49980.stgit@gimli.home> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2016-03-15 at 10:35 -0600, Alex Williamson wrote: > Fault rates can easily overwhelm the console and make the system > unresponsive.  Ratelimit to allow an opportunity for maintenance. A few suggestions: o Use a single ratelimit state. o The multiple lines output are unnecessary and hard to grep   in the dmesg output because of inconsistent prefixing as   second and subsequent output lines are not prefixed by pr_fmt. o The DMAR prefix on the second block is also unnecessary as   it's already prefixed by pr_fmt o Coalesce the formats for easier grep. so maybe: ---  drivers/iommu/dmar.c | 28 ++++++++++++++++------------  1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c index 8ffd756..59dcaaa 100644 --- a/drivers/iommu/dmar.c +++ b/drivers/iommu/dmar.c @@ -1575,23 +1575,27 @@ static int dmar_fault_do_one(struct intel_iommu *iommu, int type,  {   const char *reason;   int fault_type; + static DEFINE_RATELIMIT_STATE(rs, +       DEFAULT_RATELIMIT_INTERVAL, +       DEFAULT_RATELIMIT_BURST); + + if (__ratelimit(&rs)) + return 0;     reason = dmar_get_fault_reason(fault_reason, &fault_type);     if (fault_type == INTR_REMAP) - pr_err("INTR-REMAP: Request device [[%02x:%02x.%d] " -        "fault index %llx\n" - "INTR-REMAP:[fault reason %02d] %s\n", - (source_id >> 8), PCI_SLOT(source_id & 0xFF), - PCI_FUNC(source_id & 0xFF), addr >> 48, - fault_reason, reason); + pr_err("[INTR-REMAP] Request device [%02x:%02x.%d] fault index %llx [fault reason %02d] %s\n", +        source_id >> 8, PCI_SLOT(source_id & 0xFF), +        PCI_FUNC(source_id & 0xFF), addr >> 48, +        fault_reason, reason);   else - pr_err("DMAR:[%s] Request device [%02x:%02x.%d] " -        "fault addr %llx \n" -        "DMAR:[fault reason %02d] %s\n", -        (type ? "DMA Read" : "DMA Write"), -        (source_id >> 8), PCI_SLOT(source_id & 0xFF), -        PCI_FUNC(source_id & 0xFF), addr, fault_reason, reason); + pr_err("[%s] Request device [%02x:%02x.%d] fault addr %llx [fault reason %02d] %s\n", +        type ? "DMA Read" : "DMA Write", +        source_id >> 8, PCI_SLOT(source_id & 0xFF), +        PCI_FUNC(source_id & 0xFF), addr, +        fault_reason, reason); +   return 0;  }