Re: [PATCH 1/3] sched: define a function to report the number of context switches on a CPU

From: Peter Zijlstra
Date: Wed Aug 21 2019 - 06:35:12 EST


On Wed, Aug 21, 2019 at 08:20:48AM +0000, Long Li wrote:
> >>>Subject: Re: [PATCH 1/3] sched: define a function to report the number of
> >>>context switches on a CPU
> >>>
> >>>On Mon, Aug 19, 2019 at 11:14:27PM -0700, longli@xxxxxxxxxxxxxxxxx
> >>>wrote:
> >>>> From: Long Li <longli@xxxxxxxxxxxxx>
> >>>>
> >>>> The number of context switches on a CPU is useful to determine how
> >>>> busy this CPU is on processing IRQs. Export this information so it can
> >>>> be used by device drivers.
> >>>
> >>>Please do explain that; because I'm not seeing how number of switches
> >>>relates to processing IRQs _at_all_!
>
> Some kernel components rely on context switch to progress, for example
> watchdog and RCU. On a CPU with reasonable interrupt load, it
> continues to make context switches, normally a number of switches per
> seconds.

That isn't true; RCU is perfectly fine with a single task always running
and not making context switches, and so is the watchdog.