Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp274767imm; Mon, 1 Oct 2018 09:43:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV62uMvI7KsMWfipAk64evMzCCA/f7CZaFofDG7dW/DkoIpRz7extBWEt4wh/hEWOxlmTCo2u X-Received: by 2002:a17:902:b109:: with SMTP id q9-v6mr12590893plr.83.1538412188955; Mon, 01 Oct 2018 09:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538412188; cv=none; d=google.com; s=arc-20160816; b=jObqhkDlFOobYvuQFYpoJ+nkPQcFv+TcTG3a4PK+SNwn5MT1uW153qqUzxaNuIMZ3t bnctxhZ1g2S1iaD80rSqW/9uW0/3YKqHsTY5auIw8ISh0p6WfMdtuRoi5Ao0Ywslpm6S IQPfeXMqfp9kecYVIlKuKgywyeS7YbzRbrYSpi8FFdXgEGrPjEnfb2d2E2skTqMgBDba xacKg7x1UYEK1WOV4TZDQfk1m6iP/bWq/scYBRnQxUBOPmQ2wmntcDC4UKTY2nZ3101J xm6gaogQtxpsOymDUGna3AV31yDBp7Dxyden35ndzvFSwldd0/r3486JwWVSxvN8FLoD PtGg== 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:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=joTFncqOhr/5ceRUNjE9Oyw+p4mkklFna4saanIGUr0=; b=ze9XWlGJ1OIm9JC8BLj1ADn0R0/6lXLCeO6sktDdH2khIxD4lU9qhSVs8ONEW78Cch QvCdMYqJ6aMHqdfq8jcibyzyt8r+pcC/niGrxF/INAGevrilvCYpCphW7VOW857D++Nr 87GMah9pklcqZa9uqrOXIInI2XwZB7R+WN2+p3vR5XMLhk1tHnOqflxNjuLqkIqLrrar K7itvR9xsHcuq875Bp6+tFjBvWYEQRRGjC24ynecgC0/T6tPMWFl8+pXJczLjaKC4vtJ I5be6C9WSdgS6Pg6sJ22qol6Y+42MXzowiR6AqLlA7X6HECa3tj7cr70uVBcvD5dGi+u LvGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=jR1Qe7kp; 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 l8-v6si14587766pls.13.2018.10.01.09.42.54; Mon, 01 Oct 2018 09:43:08 -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=pass header.i=@sifive.com header.s=google header.b=jR1Qe7kp; 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 S1726391AbeJAXVX (ORCPT + 99 others); Mon, 1 Oct 2018 19:21:23 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35116 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726184AbeJAXVW (ORCPT ); Mon, 1 Oct 2018 19:21:22 -0400 Received: by mail-pf1-f196.google.com with SMTP id p12-v6so9653317pfh.2 for ; Mon, 01 Oct 2018 09:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=joTFncqOhr/5ceRUNjE9Oyw+p4mkklFna4saanIGUr0=; b=jR1Qe7kpM2bPlFjcayPpef2qaSv493wDBvaItSgQsC1IN60cavGYjmWWYnj2nZRBon TPE52pnPtBrpVvgZK7umoAFE9ducwk0S7e3/AxAGVAJ6PgnfCvvZrJMguwVIUXENKiVS Ewy5M+ehtgNcGYLjBnwGJa/pxWzkhSn7agfvmcBvX2q72SQndlC7YWOOyn4YOrS+4hmJ l5jELd0EJRmqI1ECYExl5AsCUtcdhOIrYUnqcB6w7q4s7wOUQ+fQacgw+9yvwi9OU8Gf YCDu67pknZINgwS2N3PlSgVi7Q3yVq1IyScKv8sEtqIMi/c4ChBqXXs/eycrOs+7oppz v6fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=joTFncqOhr/5ceRUNjE9Oyw+p4mkklFna4saanIGUr0=; b=P0Pk1HzjRqHvwmxk9OyJRYUbzVzLKdnNw06NVzUBydpkEdjfOpPYzYW1qF6PrxwSJ4 6BQByqJsYuSR5Y/RbQ7/4xrf3M1ygxMInlSKJ4SaYWPKD4cQTuGDWj+4x7RCjpss2wUX JwLnpvnFcWE5yLugojovC2QkJpKbDkEaxmQXy3dWt+xjBQ7gO82vMrnC8e23GfoIH74V yZssQUGquXxsoPIey5+HDMGQet8LhFskFwCu5yB891UnIjXpAEvg4DY77jtYH7mhpEYX tvCd2siDotaqrQo8Nqa4HKpCmzQOCQHID1QhlFIZxGITKr6jyRtOEhhM/y47b+P2ArYL gJUg== X-Gm-Message-State: ABuFfohlOTJrgnXhJuGPLacBsIpP23RelAof34V7Tj3iCmlCM1L/ff/B KHj34IAJoeSQzGn22pup5cgYGA== X-Received: by 2002:a63:4e11:: with SMTP id c17-v6mr10925725pgb.6.1538412162731; Mon, 01 Oct 2018 09:42:42 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id e9-v6sm4601457pgs.92.2018.10.01.09.42.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Oct 2018 09:42:41 -0700 (PDT) Date: Mon, 01 Oct 2018 09:42:41 -0700 (PDT) X-Google-Original-Date: Mon, 01 Oct 2018 09:41:40 PDT (-0700) Subject: Re: [PATCH v3] RISC-V: Show IPI stats In-Reply-To: <20180929062605.12888-1-anup@brainfault.org> CC: aou@eecs.berkeley.edu, atish.patra@wdc.com, Christoph Hellwig , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, anup@brainfault.org From: Palmer Dabbelt To: anup@brainfault.org, Atish Patra Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 28 Sep 2018 23:26:05 PDT (-0700), anup@brainfault.org 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 > > Signed-off-by: Anup Patel > > Changes since v2: > - Remove use of IPI_CALL_WAKEUP because it's being removed > > 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 Reviewed-by: Palmer Dabbelt This is going in through Atish's patch set. > > --- > arch/riscv/include/asm/smp.h | 9 +++++++++ > arch/riscv/kernel/irq.c | 8 ++++++++ > arch/riscv/kernel/smp.c | 39 +++++++++++++++++++++++++++++------- > 3 files changed, 49 insertions(+), 7 deletions(-) > > diff --git a/arch/riscv/include/asm/smp.h b/arch/riscv/include/asm/smp.h > index fce312ce3516..5278ae8f1346 100644 > --- a/arch/riscv/include/asm/smp.h > +++ b/arch/riscv/include/asm/smp.h > @@ -25,8 +25,13 @@ > extern unsigned long __cpuid_to_hardid_map[NR_CPUS]; > #define cpuid_to_hardid_map(cpu) __cpuid_to_hardid_map[cpu] > > +struct seq_file; > + > #ifdef CONFIG_SMP > > +/* print IPI stats */ > +void show_ipi_stats(struct seq_file *p, int prec); > + > /* SMP initialization hook for setup_arch */ > void __init setup_smp(void); > > @@ -47,6 +52,10 @@ void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out); > > #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 ca4593317e45..48e6b7db83a1 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) > { > struct pt_regs *old_regs = set_irq_regs(regs); > diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c > index 89d95866f562..686fa7a427ff 100644 > --- a/arch/riscv/kernel/smp.c > +++ b/arch/riscv/kernel/smp.c > @@ -22,22 +22,24 @@ > #include > #include > #include > +#include > > #include > #include > #include > > -/* A collection of single bit ipi messages. */ > -static struct { > - unsigned long bits ____cacheline_aligned; > -} ipi_data[NR_CPUS] __cacheline_aligned; > - > enum ipi_message_type { > IPI_RESCHEDULE, > IPI_CALL_FUNC, > IPI_MAX > }; > > +/* 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; > + > int riscv_hartid_to_cpuid(int hartid) > { > int i = -1; > @@ -67,6 +69,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); > @@ -81,11 +84,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); > > @@ -111,6 +118,24 @@ 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", > +}; > + > +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);