[PATCH v6 0/2] tick/sched: Ensure quiet_vmstat() is called when the idle tick was stopped too

From: Aaron Tomlin
Date: Mon Aug 08 2022 - 15:48:36 EST


Hi Frederic and Marcelo,

I have incorporated an idea from Marcelo's patch [1] where a CPU-specific
variable is used to indicate if a vmstat differential/or imbalance is
present for a given CPU. So, at the appropriate time, vmstat processing can
be initiated. The hope is that this particular approach is "cheaper" when
compared to need_update() - used currently; in the context of nohz_full and
the scheduling-clock tick being stopped, we would now with this patch,
check if a CPU-specific vmstat imbalance is present before exiting
user-mode (see tick_nohz_user_enter_prepare()).

This trivial test program [2] was used to determine the somewhat impact
under vanilla and with the proposed changes; mlock(2) and munlock(2) was
used solely to modify vmstat item 'NR_MLOCK'. The following is an average
count of CPU-cycles across the aforementioned system calls and the idle
loop, respectively. I believe these results are negligible:

Modified | Vanilla
|
cycles per syscall: 7399 | cycles per syscall: 4150
cycles per idle loop: 141048 | cycles per idle loop: 144730
|


Any feedback would be appreciated. Thanks.

Changes since v5 [3]:

- Introduced __tick_nohz_user_enter_prepare()
- Switched to EXPORT_SYMBOL_GPL()

Changes since v4 [4]:

- Moved vmstat_dirty specific changes into a separate patch
(Marcelo Tosatti)

Changes since v3 [5]:

- Used EXPORT_SYMBOL() on tick_nohz_user_enter_prepare()
- Replaced need_update()
- Introduced CPU-specific variable namely vmstat_dirty
and mark_vmstat_dirty()

[1]: https://lore.kernel.org/lkml/20220204173554.763888172@fedora.localdomain/
[2]: https://pastebin.com/8AtzSAuK
[3]: https://lore.kernel.org/lkml/20220801234258.134609-1-atomlin@xxxxxxxxxx/
[4]: https://lore.kernel.org/lkml/20220621172207.1501641-1-atomlin@xxxxxxxxxx/
[5]: https://lore.kernel.org/lkml/20220422193647.3808657-1-atomlin@xxxxxxxxxx/


Aaron Tomlin (2):
mm/vmstat: Use per cpu variable to track a vmstat discrepancy
tick/sched: Ensure quiet_vmstat() is called when the idle tick was
stopped too

include/linux/tick.h | 5 +++--
kernel/time/tick-sched.c | 19 ++++++++++++++++-
mm/vmstat.c | 46 +++++++++++++---------------------------
3 files changed, 36 insertions(+), 34 deletions(-)

--
2.37.1