linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Synchronize task mm counters on context switch
@ 2018-02-05 22:03 Daniel Colascione
  2018-02-21 19:05 ` Daniel Colascione
  0 siblings, 1 reply; 22+ messages in thread
From: Daniel Colascione @ 2018-02-05 22:03 UTC (permalink / raw)
  To: linux-mm; +Cc: Daniel Colascione

When SPLIT_RSS_COUNTING is in use (which it is on SMP systems,
generally speaking), we buffer certain changes to mm-wide counters
through counters local to the current struct task, flushing them to
the mm after seeing 64 page faults, as well as on task exit and
exec. This scheme can leave a large amount of memory unaccounted-for
in process memory counters, especially for processes with many threads
(each of which gets 64 "free" faults), and it produces an
inconsistency with the same memory counters scanned VMA-by-VMA using
smaps. This inconsistency can persist for an arbitrarily long time,
since there is no way to force a task to flush its counters to its mm.

This patch flushes counters on context switch. This way, we bound the
amount of unaccounted memory without forcing tasks to flush to the
mm-wide counters on each minor page fault. The flush operation should
be cheap: we only have a few counters, adjacent in struct task, and we
don't atomically write to the mm counters unless we've changed
something since the last flush.

Signed-off-by: Daniel Colascione <dancol@google.com>
---
 kernel/sched/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index a7bf32aabfda..7f197a7698ee 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3429,6 +3429,9 @@ asmlinkage __visible void __sched schedule(void)
 	struct task_struct *tsk = current;
 
 	sched_submit_work(tsk);
+	if (tsk->mm)
+		sync_mm_rss(tsk->mm);
+
 	do {
 		preempt_disable();
 		__schedule(false);
-- 
2.16.0.rc1.238.g530d649a79-goog

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-02-27 10:02 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-05 22:03 [PATCH] Synchronize task mm counters on context switch Daniel Colascione
2018-02-21 19:05 ` Daniel Colascione
2018-02-22  0:16   ` Minchan Kim
2018-02-22  0:23     ` Daniel Colascione
2018-02-22  2:06       ` Minchan Kim
2018-02-22  2:46         ` [PATCH] Synchronize task mm counters on demand Daniel Colascione
2018-02-23  2:01           ` Minchan Kim
2018-02-23  2:09             ` Daniel Colascione
2018-02-23  2:24               ` Daniel Colascione
2018-02-23  2:28               ` Minchan Kim
2018-02-23  2:43                 ` Daniel Colascione
2018-02-23  3:12                   ` Minchan Kim
2018-02-23  9:50           ` f66871fb4c: WARNING:inconsistent_lock_state kernel test robot
2018-02-22  2:49         ` [PATCH] Synchronize task mm counters on context switch Daniel Colascione
2018-02-23  8:11           ` Michal Hocko
2018-02-23 16:34             ` Daniel Colascione
2018-02-23 17:50               ` Michal Hocko
2018-02-23 18:47                 ` Daniel Colascione
2018-02-27 10:02                   ` Michal Hocko
2018-02-22  9:40         ` Peter Zijlstra
2018-02-22 13:06           ` Minchan Kim
2018-02-22 16:23           ` Daniel Colascione

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).