Commit bba8d3d1 authored by Paul E. McKenney's avatar Paul E. McKenney
Browse files

Merge branch 'stall.2023.01.09a' into HEAD

stall.2023.01.09a: RCU CPU stall-warning updates.
parents 8e1704b6 84ec7c20
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -5113,6 +5113,12 @@
			rcupdate.rcu_cpu_stall_timeout to be used (after
			conversion from seconds to milliseconds).

	rcupdate.rcu_cpu_stall_cputime= [KNL]
			Provide statistics on the cputime and count of
			interrupts and tasks during the sampling period. For
			multiple continuous RCU stalls, all sampling periods
			begin at half of the first RCU stall timeout.

	rcupdate.rcu_exp_stall_task_details= [KNL]
			Print stack dumps of any tasks blocking the
			current expedited RCU grace period during an
+13 −1
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ DECLARE_PER_CPU(struct kernel_cpustat, kernel_cpustat);
#define kstat_cpu(cpu) per_cpu(kstat, cpu)
#define kcpustat_cpu(cpu) per_cpu(kernel_cpustat, cpu)

extern unsigned long long nr_context_switches_cpu(int cpu);
extern unsigned long long nr_context_switches(void);

extern unsigned int kstat_irqs_cpu(unsigned int irq, int cpu);
@@ -67,6 +68,17 @@ static inline unsigned int kstat_softirqs_cpu(unsigned int irq, int cpu)
       return kstat_cpu(cpu).softirqs[irq];
}

static inline unsigned int kstat_cpu_softirqs_sum(int cpu)
{
	int i;
	unsigned int sum = 0;

	for (i = 0; i < NR_SOFTIRQS; i++)
		sum += kstat_softirqs_cpu(i, cpu);

	return sum;
}

/*
 * Number of interrupts per specific IRQ source, since bootup
 */
@@ -75,7 +87,7 @@ extern unsigned int kstat_irqs_usr(unsigned int irq);
/*
 * Number of interrupts per cpu, since bootup
 */
static inline unsigned int kstat_cpu_irqs_sum(unsigned int cpu)
static inline unsigned long kstat_cpu_irqs_sum(unsigned int cpu)
{
	return kstat_cpu(cpu).irqs_sum;
}
+14 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ config RCU_CPU_STALL_TIMEOUT
config RCU_EXP_CPU_STALL_TIMEOUT
	int "Expedited RCU CPU stall timeout in milliseconds"
	depends on RCU_STALL_COMMON
	range 0 21000
	range 0 300000
	default 0
	help
	  If a given expedited RCU grace period extends more than the
@@ -92,6 +92,19 @@ config RCU_EXP_CPU_STALL_TIMEOUT
	  says to use the RCU_CPU_STALL_TIMEOUT value converted from
	  seconds to milliseconds.

config RCU_CPU_STALL_CPUTIME
	bool "Provide additional RCU stall debug information"
	depends on RCU_STALL_COMMON
	default n
	help
	  Collect statistics during the sampling period, such as the number of
	  (hard interrupts, soft interrupts, task switches) and the cputime of
	  (hard interrupts, soft interrupts, kernel tasks) are added to the
	  RCU stall report. For multiple continuous RCU stalls, all sampling
	  periods begin at half of the first RCU stall timeout.
	  The boot option rcupdate.rcu_cpu_stall_cputime has the same function
	  as this one, but will override this if it exists.

config RCU_TRACE
	bool "Enable tracing for RCU"
	depends on DEBUG_KERNEL
+1 −0
Original line number Diff line number Diff line
@@ -224,6 +224,7 @@ extern int rcu_cpu_stall_ftrace_dump;
extern int rcu_cpu_stall_suppress;
extern int rcu_cpu_stall_timeout;
extern int rcu_exp_cpu_stall_timeout;
extern int rcu_cpu_stall_cputime;
extern bool rcu_exp_stall_task_details __read_mostly;
int rcu_jiffies_till_stall_check(void);
int rcu_exp_jiffies_till_stall_check(void);
+18 −0
Original line number Diff line number Diff line
@@ -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);
			rsrp->nr_csw = nr_context_switches_cpu(rdp->cpu);
			rsrp->jiffies = jiffies;
			rsrp->gp_seq = rdp->gp_seq;
		}
	}

	return 0;
Loading