ANDROID: mm: introduce gcma_stat_get function

Introduce helper function to get gcma stats and move enum gcma_stat_type
to include/linux/gcma.h. For debugging purposes, I'd like to print usage
status of gcma area into kernel log via show_mem vendor hook and add gcma
stats in /proc/meminfo via meminfo vendor hook.
So let's export this helper function.

Bug: 410432482
Change-Id: I1e4fd209c8a3037fba69ab2ed190f4c308477835
Signed-off-by: Sooyong Suk <s.suk@samsung.corp-partner.google.com>
This commit is contained in:
Sooyong Suk
2025-07-08 17:40:01 +09:00
committed by Suren Baghdasaryan
parent 1707d02075
commit d6034d0269
3 changed files with 22 additions and 9 deletions
+15
View File
@@ -5,6 +5,21 @@
#include <linux/types.h>
#ifdef CONFIG_GCMA
enum gcma_stat_type {
STORED_PAGE,
LOADED_PAGE,
EVICTED_PAGE,
CACHED_PAGE,
DISCARDED_PAGE,
NUM_OF_GCMA_STAT,
};
#ifdef CONFIG_GCMA_SYSFS
u64 gcma_stat_get(enum gcma_stat_type type);
#else
static inline u64 gcma_stat_get(enum gcma_stat_type type) { return 0; }
#endif
extern void gcma_alloc_range(unsigned long start_pfn, unsigned long end_pfn);
extern void gcma_free_range(unsigned long start_pfn, unsigned long end_pfn);
extern int register_gcma_area(const char *name, phys_addr_t base,
+7
View File
@@ -1,5 +1,6 @@
#include <linux/kobject.h>
#include <linux/sysfs.h>
#include <linux/gcma.h>
#include "gcma_sysfs.h"
extern struct kobject *vendor_mm_kobj;
@@ -22,6 +23,12 @@ void gcma_stat_add(enum gcma_stat_type type, unsigned long delta)
atomic64_add(delta, &gcma_stats[type]);
}
u64 gcma_stat_get(enum gcma_stat_type type)
{
return (u64)atomic64_read(&gcma_stats[type]);
}
EXPORT_SYMBOL_GPL(gcma_stat_get);
/*
* This all compiles without CONFIG_SYSFS, but is a waste of space.
*/
-9
View File
@@ -2,15 +2,6 @@
#ifndef __GCMA_SYSFS_H__
#define __GCMA_SYSFS_H__
enum gcma_stat_type {
STORED_PAGE,
LOADED_PAGE,
EVICTED_PAGE,
CACHED_PAGE,
DISCARDED_PAGE,
NUM_OF_GCMA_STAT,
};
#ifdef CONFIG_GCMA_SYSFS
void gcma_stat_inc(enum gcma_stat_type type);
void gcma_stat_dec(enum gcma_stat_type type);