Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5766934ybl; Tue, 27 Aug 2019 09:21:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSqjNx48Bvb/Fu1XKSg/oBiDhS+SGpdwFuVe+PA6VhywVY4CdLi5aOO5LwtOgXcH9M24aK X-Received: by 2002:a63:89c7:: with SMTP id v190mr21151696pgd.299.1566922886081; Tue, 27 Aug 2019 09:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566922886; cv=none; d=google.com; s=arc-20160816; b=fIEZvPSjoDPKQN5bg+hZAtme+hDe4/kug0TG8iSHr292rpoaWT4vZqeib4imOnyL/A TmizcLSpPQFZBLx90s29NIi3OBpRvWgGWJ3PUMpQzuUcmzSCyo2//9yQ+jUO+vCHR63k qLOd7M5Ky/2If6oDzSe5+IbrqykkZ+oNWOsR/+mZCmol/6WMoRutPh82/DCyptIL6wSF EIvcuvosUfJIDtabI2u+yxImIesx44pnh6JSb4G4enAHM5QGe/urVS/HBySGsRox6Xah vOtHnNvbaE4xAcK7rXpYjLW0kGHQjoKS7SLyC5AuHTW1DCBdwXtVjwHpYL6dsaHU9IaK vD+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=DHqs+eCau9dbPL8VEx7WYiFCRwaP6+d0i0dkcRu7uuY=; b=CaOvbzY80BcJOcpo+oh6IG0Yo838u7AdvogIRO33CjTggOO8sy8t7KT+LLaHU4oy4w OvcRLbjCLHjvCFaswPGLo2WKxZ7kuU9K7pfUSflfckZAl1H262vW5Sja9j3rWkpIAIx9 tQCC2l1EB1cBDOz/W0IO/F2iJyyN75/QOezmnUSVz6k202v0Xvb6lN40tVFoRIZIlr08 gcx95KVE0BPQL+RuvqkejCvijDq8qRRt/OBh10IMvdWYgIzLagWUV7JzhxQwsUlyaO/p jxOKvVZwCp5gqRvHqK+Ul60JZn5f8rP4GTakvHlp7YwtOd0v/JNyqmbudEMDwViOQIfs r5HQ== 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 69si12187367pgc.40.2019.08.27.09.21.09; Tue, 27 Aug 2019 09:21:26 -0700 (PDT) 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 S1729616AbfH0QTr (ORCPT + 99 others); Tue, 27 Aug 2019 12:19:47 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:44288 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726621AbfH0QTq (ORCPT ); Tue, 27 Aug 2019 12:19:46 -0400 Received: from p5de0b6c5.dip0.t-ipconnect.de ([93.224.182.197] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1i2eBS-0002Hz-3S; Tue, 27 Aug 2019 18:19:02 +0200 Date: Tue, 27 Aug 2019 18:19:00 +0200 (CEST) From: Thomas Gleixner To: Ming Lei cc: LKML , Long Li , Ingo Molnar , Peter Zijlstra , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , John Garry , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, Daniel Lezcano Subject: Re: [PATCH 1/4] softirq: implement IRQ flood detection mechanism In-Reply-To: Message-ID: References: <20190827085344.30799-1-ming.lei@redhat.com> <20190827085344.30799-2-ming.lei@redhat.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Talk to Daniel Lezcano (Cc'ed) how you can (ab)use that. Thanks, tglx