From: Marcelo Tosatti <mtosatti@redhat.com>
To: atomlin@redhat.com, frederic@kernel.org
Cc: cl@linux.com, tglx@linutronix.de, mingo@kernel.org,
peterz@infradead.org, pauld@redhat.com, neelx@redhat.com,
oleksandr@natalenko.name, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, Marcelo Tosatti <mtosatti@redhat.com>
Subject: [PATCH v7 3/3] mm/vmstat: do not queue vmstat_update if tick is stopped
Date: Wed, 17 Aug 2022 16:13:49 -0300 [thread overview]
Message-ID: <20220817191524.263315216@redhat.com> (raw)
In-Reply-To: 20220817191346.287594886@redhat.com
>From the vmstat shepherd, for CPUs that have the tick stopped,
do not queue local work to flush the per-CPU vmstats, since
in that case the flush is performed on return to
userspace or when entering idle.
Per-cpu pages can be freed remotely from housekeeping CPUs.
Move the quiet_vmstat call after ts->tick_stopped = 1 assignment.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
kernel/time/tick-sched.c | 6 +++---
mm/vmstat.c | 22 +++++++++++++++++-----
2 files changed, 20 insertions(+), 8 deletions(-)
Index: linux-2.6/mm/vmstat.c
===================================================================
--- linux-2.6.orig/mm/vmstat.c
+++ linux-2.6/mm/vmstat.c
@@ -29,6 +29,7 @@
#include <linux/page_ext.h>
#include <linux/page_owner.h>
#include <linux/migrate.h>
+#include <linux/tick.h>
#include "internal.h"
@@ -1973,19 +1974,27 @@ static void vmstat_update(struct work_st
*/
void quiet_vmstat(void)
{
+ struct delayed_work *dw;
+
if (system_state != SYSTEM_RUNNING)
return;
if (!__this_cpu_read(vmstat_dirty))
return;
+ refresh_cpu_vm_stats(false);
+
/*
- * Just refresh counters and do not care about the pending delayed
- * vmstat_update. It doesn't fire that often to matter and canceling
- * it would be too expensive from this path.
- * vmstat_shepherd will take care about that for us.
+ * If the tick is stopped, cancel any delayed work to avoid
+ * interruptions to this CPU in the future.
+ *
+ * Otherwise just refresh counters and do not care about the pending
+ * delayed vmstat_update. It doesn't fire that often to matter
+ * and canceling it would be too expensive from this path.
*/
- refresh_cpu_vm_stats(false);
+ dw = &per_cpu(vmstat_work, smp_processor_id());
+ if (delayed_work_pending(dw) && tick_nohz_tick_stopped())
+ cancel_delayed_work(dw);
}
/*
@@ -2007,6 +2016,9 @@ static void vmstat_shepherd(struct work_
for_each_online_cpu(cpu) {
struct delayed_work *dw = &per_cpu(vmstat_work, cpu);
+ if (tick_nohz_tick_stopped_cpu(cpu))
+ continue;
+
if (!delayed_work_pending(dw) && per_cpu(vmstat_dirty, cpu))
queue_delayed_work_on(cpu, mm_percpu_wq, dw, 0);
Index: linux-2.6/kernel/time/tick-sched.c
===================================================================
--- linux-2.6.orig/kernel/time/tick-sched.c
+++ linux-2.6/kernel/time/tick-sched.c
@@ -905,9 +905,6 @@ static void tick_nohz_stop_tick(struct t
ts->do_timer_last = 0;
}
- /* Attempt to fold when the idle tick is stopped or not */
- quiet_vmstat();
-
/* Skip reprogram of event if its not changed */
if (ts->tick_stopped && (expires == ts->next_tick)) {
/* Sanity check: make sure clockevent is actually programmed */
@@ -935,6 +932,9 @@ static void tick_nohz_stop_tick(struct t
trace_tick_stop(1, TICK_DEP_MASK_NONE);
}
+ /* Attempt to fold when the idle tick is stopped or not */
+ quiet_vmstat();
+
ts->next_tick = tick;
/*
next prev parent reply other threads:[~2022-08-17 19:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-17 19:13 [PATCH v7 0/3] tick/sched: Ensure quiet_vmstat() is called when the idle tick was stopped too Marcelo Tosatti
2022-08-17 19:13 ` [PATCH v7 1/3] mm/vmstat: Use per cpu variable to track a vmstat discrepancy Marcelo Tosatti
2022-08-24 20:20 ` Andrew Morton
2022-08-26 13:29 ` Aaron Tomlin
2022-08-17 19:13 ` [PATCH v7 2/3] tick/sched: Ensure quiet_vmstat() is called when the idle tick was stopped too Marcelo Tosatti
2022-08-24 20:20 ` Andrew Morton
2022-09-09 12:12 ` Frederic Weisbecker
2022-09-09 19:35 ` Marcelo Tosatti
2022-09-12 14:38 ` Aaron Tomlin
2022-09-14 11:04 ` Frederic Weisbecker
2022-08-17 19:13 ` Marcelo Tosatti [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-08-17 19:01 [patch 0/3] " Marcelo Tosatti
2022-08-17 19:01 ` [PATCH v7 3/3] mm/vmstat: do not queue vmstat_update if tick is stopped Marcelo Tosatti
2022-08-17 19:01 ` Marcelo Tosatti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220817191524.263315216@redhat.com \
--to=mtosatti@redhat.com \
--cc=atomlin@redhat.com \
--cc=cl@linux.com \
--cc=frederic@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@kernel.org \
--cc=neelx@redhat.com \
--cc=oleksandr@natalenko.name \
--cc=pauld@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.