Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
BACKPORT: delayacct: track delays from thrashing cache pages
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Johannes Weiner <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Tested-by: Daniel Drake <[email protected]>
Tested-by: Suren Baghdasaryan <[email protected]>
Cc: Christopher Lameter <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Enderborg <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Shakeel Butt <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Vinayak Menon <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>

(cherry picked from commit b1d29ba82cf2bc784f4c963ddd6a2cf29e229b33)

Conflicts:
        kernel/delayacct.c

(manual merge to remote extra parameter in delayacct_end)

Bug: 111308141
Test: modified lmkd to use PSI and tested using lmkd_unit_test

Signed-off-by: Suren Baghdasaryan <[email protected]>
Change-Id: Ie0237b0fc85efd2ecf0eda209036ca950c612dc6
  • Loading branch information
hnaz authored and reocat committed Jan 18, 2024
1 parent 0b0723e commit 325bbda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 5 additions & 0 deletions include/linux/delayacct.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ struct task_delay_info {

u64 freepages_start;
u64 freepages_delay; /* wait for memory reclaim */

u64 thrashing_start;
u64 thrashing_delay; /* wait for thrashing page */

u32 freepages_count; /* total count of memory reclaim */
u32 thrashing_count; /* total count of thrash waits */
};
#endif

Expand Down
6 changes: 0 additions & 6 deletions mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,12 +837,6 @@ int wait_on_page_bit_killable_timeout(struct page *page,
psi_memstall_leave(&pflags);
}

if (thrashing) {
if (!PageSwapBacked(page))
delayacct_thrashing_end();
psi_memstall_leave(&pflags);
}

/*
* A signal could leave PageWaiters set. Clearing it here if
* !waitqueue_active would be possible (by open-coding finish_wait),
Expand Down

0 comments on commit 325bbda

Please sign in to comment.