delayacct: add memory reclaim delay in get_page_from_freelist
authorliwenyu <wenyuli@ex.bilibili.com>
Wed, 20 Sep 2023 09:38:49 +0000 (17:38 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 6 Oct 2023 21:44:10 +0000 (14:44 -0700)
The current memory reclaim delay statistics only count the direct memory
reclaim of the task in do_try_to_free_pages().  In systems with NUMA open,
some tasks occasionally experience slower response times, but the total
count of reclaim does not increase, using ftrace can show that
node_reclaim has occurred.

The memory reclaim occurring in get_page_from_freelist() is also due to
heavy memory load.  To get the impact of tasks in memory reclaim, this
patch adds the statistics of the memory reclaim delay statistics for
__node_reclaim().

Link: https://lkml.kernel.org/r/181C946095F0252B+7cc60eca-1abf-4502-aad3-ffd8ef89d910@ex.bilibili.com
Signed-off-by: Wen Yu Li <wenyuli@ex.bilibili.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: <wangyun@bilibili.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vmscan.c

index 3df0e2a59052e31847d48cd82909a4e7eeb39d11..55424215f75944ae7bd1b99ce714c7fd28f3c311 100644 (file)
@@ -7326,6 +7326,7 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in
 
        cond_resched();
        psi_memstall_enter(&pflags);
+       delayacct_freepages_start();
        fs_reclaim_acquire(sc.gfp_mask);
        /*
         * We need to be able to allocate from the reserves for RECLAIM_UNMAP
@@ -7348,6 +7349,7 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in
        memalloc_noreclaim_restore(noreclaim_flag);
        fs_reclaim_release(sc.gfp_mask);
        psi_memstall_leave(&pflags);
+       delayacct_freepages_end();
 
        trace_mm_vmscan_node_reclaim_end(sc.nr_reclaimed);