Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp997113imm; Thu, 13 Sep 2018 10:56:41 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYudCBNrBLdKznirkjjMB/3tHLsLN6ta0hiOK/j6H/OTyL1HANfvAnTxdQygMhbXrc+Ji63 X-Received: by 2002:a17:902:9a82:: with SMTP id w2-v6mr8381037plp.109.1536861401392; Thu, 13 Sep 2018 10:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536861401; cv=none; d=google.com; s=arc-20160816; b=bb0s8kkHeAOMjOkdPi+2bDq09QJju6XaI/GBqaVHTJEc08oDB+G2WtaYS1KPYQtJkU N+X8qlU+HWqHbj9CLsCf7qaEXNMpnF+7OlRepg5EYcUonbiNcxDBZldP0uYEDuk0GA4s a0d6a5kusRS1iH+M05w23NZX3n7tYw3svIhdkTus96Y+HyRKZnmX2ihZ++chRkM6FW1P D5OA2/SnZPFi4D+A+4zYNFkc7K/Fgz0k9ZckKeBQTUZeD9QTM3AQbkjw93NCggDo38OU jCc9yihvoATGp/va2zvsfX5Kw4tXoA8g3cfbnPCNY7kGG0DNkg5gmFKGBT1m5PSZ3MIx Wu1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=/74a1sxsRlXcTN2GybsduX9Y6AlSWRcDgxs4ucJOgS0=; b=DyP2NBTr3AaUjH6ll/E6HDXTvnolyChhnWz5fKaYB2XZL/KvBTLwTpst0DPif57MOQ xp5b7OzbBAcGmToOHMAPTyNXsMSSxWiv74BSoifhEb5UljwubbgRHfN6xUsdsHBPBO8T akKs5MIQ6FdHH46HIxTBCp0FPpCwXnE++LYs9HoGSnqZ092qCgZ+MwsqXKRKBRTz7oqY P/8v1Vzg/b5mNvgsJga0HAbvFU+V5BJS/u8706YQQL5eDSLtlBGo2DJO9z/ckORNn1yG 4s8R98/MT+DZWDlnAIwL7MUGcep8Of0N1P2lq2F6BycBd9EBxcoDzHe7nBFKtl09tjc8 ts4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="qL/1DdeM"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r14-v6si3705800pgl.490.2018.09.13.10.56.25; Thu, 13 Sep 2018 10:56:41 -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; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="qL/1DdeM"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728008AbeIMXFu (ORCPT + 99 others); Thu, 13 Sep 2018 19:05:50 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:24012 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726862AbeIMXFu (ORCPT ); Thu, 13 Sep 2018 19:05:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1536861318; x=1568397318; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=3E4/ATHJLOh+b1ScgrMNZVQ+6bBG79IYeG801uLNeVw=; b=qL/1DdeMJtvQ143vgbjOk1HjCSnPbbdaTcwC29lYem4WdQz6gEByBmRO Z/gKtop77wRaJCB4NniziHafyfFV+5IUzh7W+EY/Rm+kSj0iMa/eAaOw7 9tKTlFjFaQHECt5DDbwC5EfP6SzfoA8jDz4CjNJ/GQDhomMWblmlw9hUY Szbr951MgSNHZTybr4+hC5iaQa/9Lnr0kAHLOGtXqrV8Gj5KzpVB9vmCk PxZ7KhszmcCgWvtEFQrPU3UYwwuORtCr13E5f9wwYv39wFN78N6jAhGEU k+7cvIHkiKvk3V8pHqQj8sOVyD8kHdsw1mdn1s8L+8T/Pv76dVs5Gch+1 Q==; X-IronPort-AV: E=Sophos;i="5.53,370,1531756800"; d="scan'208";a="89709051" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 14 Sep 2018 01:51:56 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 13 Sep 2018 10:38:16 -0700 Received: from c02v91rdhtd5.sdcorp.global.sandisk.com (HELO [10.196.159.148]) ([10.196.159.148]) by uls-op-cesaip01.wdc.com with ESMTP; 13 Sep 2018 10:51:56 -0700 Subject: Re: [PATCH v2] RISC-V: Show IPI stats To: Anup Patel , Palmer Dabbelt , Albert Ou Cc: Christoph Hellwig , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" References: <20180912143734.21205-1-anup@brainfault.org> From: Atish Patra Message-ID: Date: Thu, 13 Sep 2018 10:51:54 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180912143734.21205-1-anup@brainfault.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/12/18 7:37 AM, Anup Patel wrote: > This patch provides arch_show_interrupts() implementation to > show IPI stats via /proc/interrupts. > > Now the contents of /proc/interrupts" will look like below: > CPU0 CPU1 CPU2 CPU3 > 8: 17 7 6 14 SiFive PLIC 8 virtio0 > 10: 10 10 9 11 SiFive PLIC 10 ttyS0 > IPI0: 170 673 251 79 Rescheduling interrupts > IPI1: 1 12 27 1 Function call interrupts > IPI2: 0 0 0 0 CPU wake-up interrupts > > Signed-off-by: Anup Patel > --- > > Changes since v1: > - Add stub inline show_ipi_stats() function for !CONFIG_SMP > - Make ipi_names[] dynamically sized at compile time > - Minor beautification of ipi_names[] using tabs > > arch/riscv/include/asm/smp.h | 9 +++++++++ > arch/riscv/kernel/irq.c | 8 ++++++++ > arch/riscv/kernel/smp.c | 30 ++++++++++++++++++++++++++++-- > 3 files changed, 45 insertions(+), 2 deletions(-) > > diff --git a/arch/riscv/include/asm/smp.h b/arch/riscv/include/asm/smp.h > index 8145b8657d20..37e909c04f47 100644 > --- a/arch/riscv/include/asm/smp.h > +++ b/arch/riscv/include/asm/smp.h > @@ -36,6 +36,8 @@ static inline bool can_hotplug_cpu(void) > static inline void arch_send_call_wakeup_ipi(int cpu) { } > #endif > > +struct seq_file; > + > #ifdef CONFIG_SMP > > enum ipi_message_type { > @@ -48,6 +50,9 @@ enum ipi_message_type { > void send_ipi_message(const struct cpumask *to_whom, > enum ipi_message_type operation); > > +/* print IPI stats */ > +void show_ipi_stats(struct seq_file *p, int prec); > + > /* SMP initialization hook for setup_arch */ > void __init setup_smp(void); > > @@ -75,6 +80,10 @@ void boot_sec_cpu(void); > > #else > > +static inline void show_ipi_stats(struct seq_file *p, int prec) > +{ > +} > + > static inline int riscv_hartid_to_cpuid(int hartid) > { > return 0; > diff --git a/arch/riscv/kernel/irq.c b/arch/riscv/kernel/irq.c > index 7e14b0d9a71d..96202139ade5 100644 > --- a/arch/riscv/kernel/irq.c > +++ b/arch/riscv/kernel/irq.c > @@ -8,6 +8,8 @@ > #include > #include > #include > +#include > +#include > > /* > * Possible interrupt causes: > @@ -24,6 +26,12 @@ > */ > #define INTERRUPT_CAUSE_FLAG (1UL << (__riscv_xlen - 1)) > > +int arch_show_interrupts(struct seq_file *p, int prec) > +{ > + show_ipi_stats(p, prec); > + return 0; > +} > + > asmlinkage void __irq_entry do_IRQ(struct pt_regs *regs, unsigned long cause) > { > struct pt_regs *old_regs = set_irq_regs(regs); > diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c > index 629456bb6122..70fd1351d6d9 100644 > --- a/arch/riscv/kernel/smp.c > +++ b/arch/riscv/kernel/smp.c > @@ -22,6 +22,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -29,6 +30,7 @@ > > /* A collection of single bit ipi messages. */ > static struct { > + unsigned long stats[IPI_MAX] ____cacheline_aligned; > unsigned long bits ____cacheline_aligned; > } ipi_data[NR_CPUS] __cacheline_aligned; > > @@ -61,6 +63,7 @@ int setup_profiling_timer(unsigned int multiplier) > void riscv_software_interrupt(void) > { > unsigned long *pending_ipis = &ipi_data[smp_processor_id()].bits; > + unsigned long *stats = ipi_data[smp_processor_id()].stats; > > /* Clear pending IPI */ > csr_clear(sip, SIE_SSIE); > @@ -75,11 +78,15 @@ void riscv_software_interrupt(void) > if (ops == 0) > return; > > - if (ops & (1 << IPI_RESCHEDULE)) > + if (ops & (1 << IPI_RESCHEDULE)) { > + stats[IPI_RESCHEDULE]++; > scheduler_ipi(); > + } > > - if (ops & (1 << IPI_CALL_FUNC)) > + if (ops & (1 << IPI_CALL_FUNC)) { > + stats[IPI_CALL_FUNC]++; > generic_smp_call_function_interrupt(); > + } > > BUG_ON((ops >> IPI_MAX) != 0); > > @@ -105,6 +112,25 @@ send_ipi_message(const struct cpumask *to_whom, enum ipi_message_type operation) > sbi_send_ipi(cpumask_bits(&hartid_mask)); > } > > +static const char *ipi_names[] = { > + [IPI_RESCHEDULE] = "Rescheduling interrupts", > + [IPI_CALL_FUNC] = "Function call interrupts", > + [IPI_CALL_WAKEUP] = "CPU wake-up interrupts", There were some concerns about cpu hotplug patch which introduced IPI_CALL_WAKEUP. I have dropped it as of now from my series. I will send it as a separate patch. So we may want to add IPI_CALL_WAKEUP along with cpu hotplug patch which makes more sense to me. Other than that, LGTM. Regards, Atish > +}; > + > +void show_ipi_stats(struct seq_file *p, int prec) > +{ > + unsigned int cpu, i; > + > + for (i = 0; i < IPI_MAX; i++) { > + seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i, > + prec >= 4 ? " " : ""); > + for_each_online_cpu(cpu) > + seq_printf(p, "%10lu ", ipi_data[cpu].stats[i]); > + seq_printf(p, " %s\n", ipi_names[i]); > + } > +} > + > void arch_send_call_function_ipi_mask(struct cpumask *mask) > { > send_ipi_message(mask, IPI_CALL_FUNC); >