psi: pressure stall information for CPU, memory, and IO
[platform/kernel/linux-starfive.git] / mm / page_alloc.c
index 20f25d0..f97b5a1 100644 (file)
@@ -66,6 +66,7 @@
 #include <linux/ftrace.h>
 #include <linux/lockdep.h>
 #include <linux/nmi.h>
+#include <linux/psi.h>
 
 #include <asm/sections.h>
 #include <asm/tlbflush.h>
@@ -3549,15 +3550,20 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
                enum compact_priority prio, enum compact_result *compact_result)
 {
        struct page *page;
+       unsigned long pflags;
        unsigned int noreclaim_flag;
 
        if (!order)
                return NULL;
 
+       psi_memstall_enter(&pflags);
        noreclaim_flag = memalloc_noreclaim_save();
+
        *compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac,
                                                                        prio);
+
        memalloc_noreclaim_restore(noreclaim_flag);
+       psi_memstall_leave(&pflags);
 
        if (*compact_result <= COMPACT_INACTIVE)
                return NULL;
@@ -3756,11 +3762,13 @@ __perform_reclaim(gfp_t gfp_mask, unsigned int order,
        struct reclaim_state reclaim_state;
        int progress;
        unsigned int noreclaim_flag;
+       unsigned long pflags;
 
        cond_resched();
 
        /* We now go into synchronous reclaim */
        cpuset_memory_pressure_bump();
+       psi_memstall_enter(&pflags);
        fs_reclaim_acquire(gfp_mask);
        noreclaim_flag = memalloc_noreclaim_save();
        reclaim_state.reclaimed_slab = 0;
@@ -3772,6 +3780,7 @@ __perform_reclaim(gfp_t gfp_mask, unsigned int order,
        current->reclaim_state = NULL;
        memalloc_noreclaim_restore(noreclaim_flag);
        fs_reclaim_release(gfp_mask);
+       psi_memstall_leave(&pflags);
 
        cond_resched();