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

From: Joerg Roedel
Date: Thu Mar 15 2018 - 09:46:59 EST


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.



Joerg