mm: mm_event: add special kernel allocation stat
authorMinchan Kim <minchan@google.com>
Mon, 6 Aug 2018 06:12:44 +0000 (15:12 +0900)
committerPDO SCM Team <hudsoncm@motorola.com>
Fri, 15 Nov 2019 06:58:46 +0000 (00:58 -0600)
Record the count of special page allocation on the process context.

This patch aims for accounting of special page allocation which
consumed a lot by android system.
At this moment, ION system heap is good candidate(it could cover
other kernel allocation in future).
With that, we could keep tracking burst kernel allocation owner
so that it would be useful to find places caused by lmk, reclaim,
compaction latency.

Mot-CRs-fixed: (CR)

Bug: 80168800
Change-Id: I5942fd940d98baa2eb814f66b076cb37ecd3b4aa
Signed-off-by: Minchan Kim <minchan@google.com>
Reviewed-on: https://gerrit.mot.com/1453724
Tested-by: Jira Key
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key

drivers/staging/android/ion/ion_page_pool.c
include/linux/mm_event.h
include/trace/events/mm_event.h
mm/mm_event.c

index 311f9d0b38d459703d98009dc23c8ecdcad4772f..6b2f68e6abf1109039f9358ca9af825626c32198 100644 (file)
@@ -41,6 +41,9 @@ static void *ion_page_pool_alloc_pages(struct ion_page_pool *pool, bool nozero)
                        perrfn("failed to alloc order-0 page (gfp %pGg)", &gfpmask);
                return NULL;
        }
+
+       mm_event_count(MM_KERN_ALLOC, 1 << pool->order);
+
        return page;
 }
 
index 2778fa09c65088bec2350282db74550dffc3037f..81d9a72b11db9541f3a882c2fb52ec8b63459648 100644 (file)
@@ -11,6 +11,7 @@ enum mm_event_type {
        MM_COMPACTION,
        MM_RECLAIM,
        MM_SWP_FAULT,
+       MM_KERN_ALLOC,
        MM_TYPE_NUM,
 };
 
@@ -26,9 +27,11 @@ struct task_struct;
 void mm_event_task_init(struct task_struct *tsk);
 void mm_event_start(ktime_t *time);
 void mm_event_end(enum mm_event_type event, ktime_t start);
+void mm_event_count(enum mm_event_type event, int count);
 #else
 static inline void mm_event_task_init(struct task_struct *tsk) {}
 static inline void mm_event_start(ktime_t *time) {}
 static inline void mm_event_end(enum mm_event_type event, ktime_t start) {}
+static inline void mm_event_count(enum mm_event_type event, int count) {}
 #endif /* _LINUX_MM_EVENT_H */
 #endif
index 34e6d55f0266cfcb449f10b3bb832e141e01a130..7d69e42bc8bd210e9793e5a281785a4e5a6f778f 100644 (file)
@@ -16,7 +16,8 @@ struct mm_event_task;
        { MM_MAJ_FAULT, "maj_flt" },                                    \
        { MM_COMPACTION, "compaction" },                                \
        { MM_RECLAIM, "reclaim" },                                      \
-       { MM_SWP_FAULT, "swp_flt" })
+       { MM_SWP_FAULT, "swp_flt" },                                    \
+       { MM_KERN_ALLOC, "kern_alloc" })
 
 TRACE_EVENT(mm_event_record,
 
index 5d5c90bbd3b9aace34738033b366b2a80d703ce1..af2e28d41b6a876979d40ad83cb1e9ed947f39e3 100644 (file)
@@ -49,6 +49,12 @@ void mm_event_end(enum mm_event_type event, ktime_t start)
        record_stat();
 }
 
+void mm_event_count(enum mm_event_type event, int count)
+{
+       current->mm_event[event].count += count;
+       record_stat();
+}
+
 static struct dentry *mm_event_root;
 
 static int period_ms_set(void *data, u64 val)