On Sun, Dec 04, 2022 at 02:31:41PM +0000, Visa Hankala wrote:
> Do not re-insert the event counter to evcount_list in evcount_percpu().
> Otherwise the list becomes corrupt when evcount_percpu() is called
> after evcount_init_percpu().
> 
> OK?

Huh.  That's no good.

ok cheloha@

> As an extra, use percpu counters with mips64 clock and ipi interrupts.

In a separate commit, please.  Assuming you've tested it:

ok cheloha@

> Index: kern/subr_evcount.c
> ===================================================================
> RCS file: src/sys/kern/subr_evcount.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 subr_evcount.c
> --- kern/subr_evcount.c       10 Nov 2022 07:05:41 -0000      1.14
> +++ kern/subr_evcount.c       4 Dec 2022 14:17:59 -0000
> @@ -56,7 +56,6 @@ evcount_percpu(struct evcount *ec)
>               TAILQ_INSERT_TAIL(&evcount_percpu_init_list, ec, next);
>       } else {
>               ec->ec_percpu = counters_alloc(1);
> -             TAILQ_INSERT_TAIL(&evcount_list, ec, next);
>       }
>  }
>  
> Index: arch/mips64/mips64/clock.c
> ===================================================================
> RCS file: src/sys/arch/mips64/mips64/clock.c,v
> retrieving revision 1.48
> diff -u -p -r1.48 clock.c
> --- arch/mips64/mips64/clock.c        19 Nov 2022 16:23:48 -0000      1.48
> +++ arch/mips64/mips64/clock.c        4 Dec 2022 14:17:58 -0000
> @@ -37,7 +37,6 @@
>  #include <sys/param.h>
>  #include <sys/kernel.h>
>  #include <sys/systm.h>
> -#include <sys/atomic.h>
>  #include <sys/clockintr.h>
>  #include <sys/device.h>
>  #include <sys/evcount.h>
> @@ -100,6 +99,7 @@ clockattach(struct device *parent, struc
>        */
>       set_intr(INTPRI_CLOCK, CR_INT_5, cp0_int5);
>       evcount_attach(&cp0_clock_count, "clock", &cp0_clock_irq);
> +     evcount_percpu(&cp0_clock_count);
>  
>       /* try to avoid getting clock interrupts early */
>       cp0_set_compare(cp0_get_count() - 1);
> @@ -121,7 +121,7 @@ cp0_int5(uint32_t mask, struct trapframe
>       struct cpu_info *ci = curcpu();
>       int s;
>  
> -     atomic_inc_long((unsigned long *)&cp0_clock_count.ec_count);
> +     evcount_inc(&cp0_clock_count);
>  
>       cp0_set_compare(cp0_get_count() - 1);   /* clear INT5 */
>  
> Index: arch/mips64/mips64/ipifuncs.c
> ===================================================================
> RCS file: src/sys/arch/mips64/mips64/ipifuncs.c,v
> retrieving revision 1.25
> diff -u -p -r1.25 ipifuncs.c
> --- arch/mips64/mips64/ipifuncs.c     10 Apr 2022 13:23:14 -0000      1.25
> +++ arch/mips64/mips64/ipifuncs.c     4 Dec 2022 14:17:58 -0000
> @@ -84,6 +84,7 @@ mips64_ipi_init(void)
>       if (!cpuid) {
>               mtx_init(&smp_rv_mtx, IPL_HIGH);
>               evcount_attach(&ipi_count, "ipi", &ipi_irq);
> +             evcount_percpu(&ipi_count);
>       }
>  
>       hw_ipi_intr_clear(cpuid);
> @@ -113,8 +114,7 @@ mips64_ipi_intr(void *arg)
>               for (bit = 0; bit < MIPS64_NIPIS; bit++) {
>                       if (pending_ipis & (1UL << bit)) {
>                               (*ipifuncs[bit])();
> -                             atomic_inc_long(
> -                                 (unsigned long *)&ipi_count.ec_count);
> +                             evcount_inc(&ipi_count);
>                       }
>               }
>       }
> 

Reply via email to