From patchwork Tue Nov 29 22:48:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oussama Ghorbel X-Patchwork-Id: 9453195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E53AF60235 for ; Tue, 29 Nov 2016 22:51:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7D4C28119 for ; Tue, 29 Nov 2016 22:51:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBEC828334; Tue, 29 Nov 2016 22:51:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 96F1728119 for ; Tue, 29 Nov 2016 22:51:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBrE3-0003gx-Jn; Tue, 29 Nov 2016 22:50:11 +0000 Received: from mail-wj0-x242.google.com ([2a00:1450:400c:c01::242]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBrE0-00032j-Ck for linux-arm-kernel@lists.infradead.org; Tue, 29 Nov 2016 22:50:09 +0000 Received: by mail-wj0-x242.google.com with SMTP id kp2so20014760wjc.0 for ; Tue, 29 Nov 2016 14:49:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=R27dvF8ugXHpQkrfDMPysu1lKpRc/3qtDdRWSfFB4V8=; b=TP0Cwar2jb+RHwlvhfAM4TTfgAZXKkaXroBgxh4S7pRSexcFn3Cn/6d8B2kpfAgCeB 6pbaEV6jgY5rV3H0POsZaMDENmofxNcTeBFfF2KSdBvtYbBzHFrQ4Dqpi0C1WGqj4+N/ F9qUJM2JPq1hDpsOPpMifQnFfbxMWMfcjaGOMcUNK6rjUAWTrAtyt5t4ezcUPzy1os8D cLNWpCEyiFu1mi60Q9DE1yHFNYaZ9OdEtPhibJWv5oPsy59MQ9LvPQcauZsFQYUgG63A mqsaHOKbt/LCiPXyYtvKJ8Vys0fzpP0+OraFQOt4+yYdGLnn0ds8g8jzxswZpIPv0jbz biHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=R27dvF8ugXHpQkrfDMPysu1lKpRc/3qtDdRWSfFB4V8=; b=PV2KFbZHvl9Qn6pUuiHqy7/GDRMAxES2e78QOd1imJyib3IWcIZ8T1UeI6UUiRREOi M6VViIyTOkzIDCHuuG5Rzo15XjmuRrYXaOoAtzcOlqopGzLtuIkBKnNJAoD20zJz9wY+ 4wgYOOKNIVHiPuSq7LhFaONMTEfjSUE3xgdyrXPAcHGvaLrl4UMLL+VSdIXAvv4SNygB eRK9JABf/Uai1iJqv88OMRFEdh/xIAzlc49Gm3PII/P2WRp3sx5Npu9PeS3aLye9rLFp 3qPBgdqpZ6YUzHStkY9y2Qw2v982Jqz7xpOHsK79HwjdpIk3As8QfzDzSAfIchGU/k6u PvHQ== X-Gm-Message-State: AKaTC00e/41u9H81jz3DMMofZjajg/qfF+/PcvEavel1LR5HLK9NKRE0JdImyfflDyS9kQ== X-Received: by 10.194.171.104 with SMTP id at8mr25498620wjc.159.1480459785114; Tue, 29 Nov 2016 14:49:45 -0800 (PST) Received: from neutrino.home ([41.228.220.196]) by smtp.gmail.com with ESMTPSA id 197sm4978206wmy.16.2016.11.29.14.49.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Nov 2016 14:49:44 -0800 (PST) From: Oussama Ghorbel To: Russell King Subject: [PATCH] arm: add stat support to fiq Date: Tue, 29 Nov 2016 23:48:35 +0100 Message-Id: <1480459715-19496-1-git-send-email-ghorbel@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161129_145008_644252_E618E826 X-CRM114-Status: GOOD ( 16.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Oussama Ghorbel , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch allows drivers that uses fiq to have a stat on the execution number of the fiq handler. For that three APIs has been defined: - fiq_kstat_enable: this function enables fiq stat and allocates required memory for it - fiq_kstat_disable: this function disable fiq stat and free its allocated memory - fiq_kstat_this_cpu_inc: This function increments the fiq stat counter of the current CPU running the fiq handler A driver may call fiq_kstat_enable at its initialization to enable fiq stat and then call fiq_kstat_this_cpu_inc from the fiq handler When the fiq stat is enabled by a driver, then /proc/interrupts shows the fiq entry as the following example: FIQ: 0 21642080 0 0 usb_fiq If the fiq stat is not enabled, the content will be similar to the old one as the following example: FIQ: usb_fiq The fiq name will be always written on the first column after the last CPU column Signed-off-by: Oussama Ghorbel --- arch/arm/include/asm/fiq.h | 10 ++++++++++ arch/arm/kernel/fiq.c | 31 +++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/arch/arm/include/asm/fiq.h b/arch/arm/include/asm/fiq.h index d493d0b..77f819b 100644 --- a/arch/arm/include/asm/fiq.h +++ b/arch/arm/include/asm/fiq.h @@ -31,6 +31,8 @@ struct fiq_handler { /* data for the relinquish/reacquire functions */ void *dev_id; + /* fiq stats percpu */ + unsigned int __percpu *fiq_kstat; }; extern int claim_fiq(struct fiq_handler *f); @@ -53,4 +55,12 @@ static inline void get_fiq_regs(struct pt_regs *regs) __get_fiq_regs(®s->ARM_r8); } +extern int fiq_kstat_enable(struct fiq_handler *fh); +extern void fiq_kstat_disable(struct fiq_handler *fh); + +static inline void fiq_kstat_this_cpu_inc(struct fiq_handler *fh) +{ + __this_cpu_inc(*fh->fiq_kstat); +} + #endif diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c index 059c3da..4b606df 100644 --- a/arch/arm/kernel/fiq.c +++ b/arch/arm/kernel/fiq.c @@ -83,10 +83,19 @@ static struct fiq_handler *current_fiq = &default_owner; int show_fiq_list(struct seq_file *p, int prec) { - if (current_fiq != &default_owner) - seq_printf(p, "%*s: %s\n", prec, "FIQ", - current_fiq->name); - + int j; + + if (current_fiq == &default_owner) + return 0; + seq_printf(p, "%*s: ", prec, "FIQ"); + for_each_online_cpu(j) { + if (current_fiq->fiq_kstat) + seq_printf(p, "%10u ", + *per_cpu_ptr(current_fiq->fiq_kstat, j)); + else + seq_printf(p, "%10s ", ""); + } + seq_printf(p, " %s\n", current_fiq->name); return 0; } @@ -162,3 +171,17 @@ void __init init_FIQ(int start) get_fiq_regs(&dfl_fiq_regs); fiq_start = start; } + +int fiq_kstat_enable(struct fiq_handler *fh) +{ + fh->fiq_kstat = alloc_percpu(unsigned int); + return fh->fiq_kstat != 0 ? 0 : 1; +} +EXPORT_SYMBOL(fiq_kstat_enable); + +void fiq_kstat_disable(struct fiq_handler *fh) +{ + free_percpu(fh->fiq_kstat); + fh->fiq_kstat = NULL; +} +EXPORT_SYMBOL(fiq_kstat_disable);