Re: [PATCHv3] iommu/intel: Ratelimit each dmar fault printing

From: Dmitry Safonov
Date: Thu Mar 15 2018 - 10:13:10 EST


On Thu, 2018-03-15 at 14:46 +0100, Joerg Roedel wrote:
> On Thu, Feb 15, 2018 at 07:17:29PM +0000, Dmitry Safonov wrote:
> > diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
> > index accf58388bdb..6c4ea32ee6a9 100644
> > --- a/drivers/iommu/dmar.c
> > +++ b/drivers/iommu/dmar.c
> > @@ -1618,17 +1618,13 @@ irqreturn_t dmar_fault(int irq, void
> > *dev_id)
> > 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);
>
> This looks aweful. Have you tried to limit the number of loops in
> this
> function and returning? You can handle the next faults by the next
> interrupt. This ensures that the cpu visits a scheduling point from
> time
> to time so that you don't see soft-lockups.

So, you suggest to remove ratelimit at all?
Do we really need printk flood for each happened fault?
Imagine, you've hundreds of mappings and then PCI link flapped..
Wouldn't it be better to keep ratelimiting?
I don't mind, just it looks a bit strange to me.

--
Thanks,
Dmitry