[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190827230451.GB5263@ming.t460p>
Date: Wed, 28 Aug 2019 07:04:52 +0800
From: Ming Lei <ming.lei@...hat.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>,
Long Li <longli@...rosoft.com>, Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Keith Busch <keith.busch@...el.com>, Jens Axboe <axboe@...com>,
Christoph Hellwig <hch@....de>,
Sagi Grimberg <sagi@...mberg.me>,
John Garry <john.garry@...wei.com>,
Hannes Reinecke <hare@...e.com>,
linux-nvme@...ts.infradead.org, linux-scsi@...r.kernel.org,
Daniel Lezcano <daniel.lezcano@...aro.org>
Subject: Re: [PATCH 1/4] softirq: implement IRQ flood detection mechanism
On Tue, Aug 27, 2019 at 06:19:00PM +0200, Thomas Gleixner wrote:
> On Tue, 27 Aug 2019, Thomas Gleixner wrote:
> > On Tue, 27 Aug 2019, Ming Lei wrote:
> > > +/*
> > > + * Update average irq interval with the Exponential Weighted Moving
> > > + * Average(EWMA)
> > > + */
> > > +static void irq_update_interval(void)
> > > +{
> > > +#define IRQ_INTERVAL_EWMA_WEIGHT 128
> > > +#define IRQ_INTERVAL_EWMA_PREV_FACTOR 127
> > > +#define IRQ_INTERVAL_EWMA_CURR_FACTOR (IRQ_INTERVAL_EWMA_WEIGHT - \
> > > + IRQ_INTERVAL_EWMA_PREV_FACTOR)
> >
> > Please do not stick defines into a function body. That's horrible.
> >
> > > +
> > > + int cpu = raw_smp_processor_id();
> > > + struct irq_interval *inter = per_cpu_ptr(&avg_irq_interval, cpu);
> > > + u64 delta = sched_clock_cpu(cpu) - inter->last_irq_end;
> >
> > Why are you doing that raw_smp_processor_id() dance? The call site has
> > interrupts and preemption disabled.
> >
> > Also how is that supposed to work when sched_clock is jiffies based?
> >
> > > + inter->avg = (inter->avg * IRQ_INTERVAL_EWMA_PREV_FACTOR +
> > > + delta * IRQ_INTERVAL_EWMA_CURR_FACTOR) /
> > > + IRQ_INTERVAL_EWMA_WEIGHT;
> >
> > We definitely are not going to have a 64bit multiplication and division on
> > every interrupt. Asided of that this breaks 32bit builds all over the place.
>
> That said, we already have infrastructure for something like this in the
> core interrupt code which is optimized to be lightweight in the fast path.
>
> kernel/irq/timings.c
irq/timings.c is much more complicated, especially it applies EWMA to
compute each irq's average interval. However, we only need it for
do_IRQ() to cover all interrupt & softirq handler.
Also CONFIG_IRQ_TIMINGS is usually disabled on distributions.
thanks,
Ming
Powered by blists - more mailing lists