Re: [PATCH v7 4/6] rcu: Add RCU stall diagnosis information

From: Frederic Weisbecker
Date: Mon Nov 14 2022 - 07:47:38 EST


On Mon, Nov 14, 2022 at 08:32:19PM +0800, Leizhen (ThunderTown) wrote:
> >> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> >> index ed93ddb8203d42c..3921aacfd421ba9 100644
> >> --- a/kernel/rcu/tree.c
> >> +++ b/kernel/rcu/tree.c
> >> @@ -866,6 +866,24 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
> >> rdp->rcu_iw_gp_seq = rnp->gp_seq;
> >> irq_work_queue_on(&rdp->rcu_iw, rdp->cpu);
> >> }
> >> +
> >> + if (rcu_cpu_stall_cputime && rdp->snap_record.gp_seq != rdp->gp_seq) {
> >> + int cpu = rdp->cpu;
> >> + struct rcu_snap_record *rsrp;
> >> + struct kernel_cpustat *kcsp;
> >> +
> >> + kcsp = &kcpustat_cpu(cpu);
> >> +
> >> + rsrp = &rdp->snap_record;
> >> + rsrp->cputime_irq = kcpustat_field(kcsp, CPUTIME_IRQ, cpu);
> >> + rsrp->cputime_softirq = kcpustat_field(kcsp, CPUTIME_SOFTIRQ, cpu);
> >> + rsrp->cputime_system = kcpustat_field(kcsp, CPUTIME_SYSTEM, cpu);
> >> + rsrp->nr_hardirqs = kstat_cpu_irqs_sum(rdp->cpu);
> >> + rsrp->nr_softirqs = kstat_cpu_softirqs_sum(rdp->cpu);
> >
> > Getting the sum of all CPU's IRQs, with even two iterations on all of them, look
> > costly. So I have to ask: why is this information useful and why can't we deduce
> > it from other CPUs stall reports?
>
> Only the RCU stalled CPUs are recorded. Why all CPUs?

Bah, I misread kstat_cpu_softirqs_sum() kstat_cpu_irqs_sum() content. Sorry
about that, my brainfart... :-)