From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752421AbdFVP0B (ORCPT ); Thu, 22 Jun 2017 11:26:01 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:56360 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750969AbdFVP0A (ORCPT ); Thu, 22 Jun 2017 11:26:00 -0400 Date: Thu, 22 Jun 2017 17:25:56 +0200 (CEST) From: Thomas Gleixner To: Daniel Lezcano cc: linux-kernel@vger.kernel.org, Peter Zijlstra , "Rafael J . Wysocki" , Vincent Guittot , Nicolas Pitre , Jens Axboe , Hannes Reinecke , Bjorn Helgaas Subject: Re: [PATCH 3/3] irq: Compute the periodic interval for interrupts In-Reply-To: <1497994139-19816-3-git-send-email-daniel.lezcano@linaro.org> Message-ID: References: <20170620212657.GB1812@mai> <1497994139-19816-1-git-send-email-daniel.lezcano@linaro.org> <1497994139-19816-3-git-send-email-daniel.lezcano@linaro.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 20 Jun 2017, Daniel Lezcano wrote: > struct irq_timings { > u64 values[IRQ_TIMINGS_SIZE]; /* our circular buffer */ > - unsigned int count; /* Number of interruptions since last inspection */ > + int count; /* Number of interruptions since last inspection */ WTF? > + ret = irq_timings_alloc(irq); > + if (ret) { > + pr_warn("Failed to allocate irq timing stats for irq%d (%d)", > + irq, ret); That error code is -ENOMEM always, right? > @@ -19,6 +25,18 @@ DEFINE_STATIC_KEY_FALSE(irq_timing_enabled); > > DEFINE_PER_CPU(struct irq_timings, irq_timings); > > +struct irqt_stat { > + u64 ne; /* next event */ Kernel doc format for struct documentation please. And with proper struct member names you can spare that whole documentation. What the heck is wrong with next_evt, last_ts, nr_samples or such ? > + u64 lts; /* last timestamp */ > + u64 variance; /* variance */ > + u32 avg; /* mean value */ > + u32 count; /* number of samples */ > + int anomalies; /* number of consecutives anomalies */ > + int valid; /* behaviour of the interrupt */ > +}; That would be too intuitive and spare a permanent lookup of the fricking acronyms, right? > +/** > + * irqs_update - update the irq timing statistics with a new timestamp > + * > + * @irqs: an irqt_stat struct pointer > + * @ts: the new timestamp > + * > + * ** This function must be called with the local irq disabled ** No need to yell here. And if you really fear that it's called with interrupts enabled, then add a proper debug check. Also instead of making mandatory statements it's better to explain WHY. > +/** > + * irq_timings_next_event - Return when the next event is supposed to arrive > + * > + * *** This function must be called with the local irq disabled *** Idem. > +void irq_timings_free(int irq) > +{ > + struct irqt_stat __percpu *s; > + > + s = idr_find(&irqt_stats, irq); > + if (s) { > + free_percpu(s); > + idr_remove(&irqt_stats, irq); > + } > +} > + > +int irq_timings_alloc(int irq) > +{ > + int id; > + struct irqt_stat __percpu *s; struct irqt_stat __percpu *s; int id; Please ... Don't bother to offer me a git tree, I'm going to apply that manually anyway. Thanks, tglx