aboutsummaryrefslogtreecommitdiffstats
path: root/mm/filemap.c
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2018-10-26 18:06:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-10-26 19:26:32 -0400
commitb1d29ba82cf2bc784f4c963ddd6a2cf29e229b33 (patch)
tree4fc15315a4c1f8c1d1e99968a3077dcf1ac45407 /mm/filemap.c
parent1899ad18c6072d689896badafb81267b0a1092a4 (diff)
delayacct: track delays from thrashing cache pages
Delay accounting already measures the time a task spends in direct reclaim and waiting for swapin, but in low memory situations tasks spend can spend a significant amount of their time waiting on thrashing page cache. This isn't tracked right now. To know the full impact of memory contention on an individual task, measure the delay when waiting for a recently evicted active cache page to read back into memory. Also update tools/accounting/getdelays.c: [hannes@computer accounting]$ sudo ./getdelays -d -p 1 print delayacct stats ON PID 1 CPU count real total virtual total delay total delay average 50318 745000000 847346785 400533713 0.008ms IO count delay total delay average 435 122601218 0ms SWAP count delay total delay average 0 0 0ms RECLAIM count delay total delay average 0 0 0ms THRASHING count delay total delay average 19 12621439 0ms Link: http://lkml.kernel.org/r/20180828172258.3185-4-hannes@cmpxchg.org Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Daniel Drake <drake@endlessm.com> Tested-by: Suren Baghdasaryan <surenb@google.com> Cc: Christopher Lameter <cl@linux.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Johannes Weiner <jweiner@fb.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Enderborg <peter.enderborg@sony.com> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Shakeel Butt <shakeelb@google.com> Cc: Tejun Heo <tj@kernel.org> Cc: Vinayak Menon <vinmenon@codeaurora.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r--mm/filemap.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index 7997adce5a29..01a841f17bf4 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -36,6 +36,7 @@
36#include <linux/cleancache.h> 36#include <linux/cleancache.h>
37#include <linux/shmem_fs.h> 37#include <linux/shmem_fs.h>
38#include <linux/rmap.h> 38#include <linux/rmap.h>
39#include <linux/delayacct.h>
39#include "internal.h" 40#include "internal.h"
40 41
41#define CREATE_TRACE_POINTS 42#define CREATE_TRACE_POINTS
@@ -1073,8 +1074,15 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,
1073{ 1074{
1074 struct wait_page_queue wait_page; 1075 struct wait_page_queue wait_page;
1075 wait_queue_entry_t *wait = &wait_page.wait; 1076 wait_queue_entry_t *wait = &wait_page.wait;
1077 bool thrashing = false;
1076 int ret = 0; 1078 int ret = 0;
1077 1079
1080 if (bit_nr == PG_locked && !PageSwapBacked(page) &&
1081 !PageUptodate(page) && PageWorkingset(page)) {
1082 delayacct_thrashing_start();
1083 thrashing = true;
1084 }
1085
1078 init_wait(wait); 1086 init_wait(wait);
1079 wait->flags = lock ? WQ_FLAG_EXCLUSIVE : 0; 1087 wait->flags = lock ? WQ_FLAG_EXCLUSIVE : 0;
1080 wait->func = wake_page_function; 1088 wait->func = wake_page_function;
@@ -1113,6 +1121,9 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,
1113 1121
1114 finish_wait(q, wait); 1122 finish_wait(q, wait);
1115 1123
1124 if (thrashing)
1125 delayacct_thrashing_end();
1126
1116 /* 1127 /*
1117 * A signal could leave PageWaiters set. Clearing it here if 1128 * A signal could leave PageWaiters set. Clearing it here if
1118 * !waitqueue_active would be possible (by open-coding finish_wait), 1129 * !waitqueue_active would be possible (by open-coding finish_wait),