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>
This commit is contained in:

committed by
Linus Torvalds

parent
1899ad18c6
commit
b1d29ba82c
11
mm/filemap.c
11
mm/filemap.c
@@ -36,6 +36,7 @@
|
||||
#include <linux/cleancache.h>
|
||||
#include <linux/shmem_fs.h>
|
||||
#include <linux/rmap.h>
|
||||
#include <linux/delayacct.h>
|
||||
#include "internal.h"
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
@@ -1073,8 +1074,15 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,
|
||||
{
|
||||
struct wait_page_queue wait_page;
|
||||
wait_queue_entry_t *wait = &wait_page.wait;
|
||||
bool thrashing = false;
|
||||
int ret = 0;
|
||||
|
||||
if (bit_nr == PG_locked && !PageSwapBacked(page) &&
|
||||
!PageUptodate(page) && PageWorkingset(page)) {
|
||||
delayacct_thrashing_start();
|
||||
thrashing = true;
|
||||
}
|
||||
|
||||
init_wait(wait);
|
||||
wait->flags = lock ? WQ_FLAG_EXCLUSIVE : 0;
|
||||
wait->func = wake_page_function;
|
||||
@@ -1113,6 +1121,9 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,
|
||||
|
||||
finish_wait(q, wait);
|
||||
|
||||
if (thrashing)
|
||||
delayacct_thrashing_end();
|
||||
|
||||
/*
|
||||
* A signal could leave PageWaiters set. Clearing it here if
|
||||
* !waitqueue_active would be possible (by open-coding finish_wait),
|
||||
|
Reference in New Issue
Block a user