diff --git a/include/linux/gcma.h b/include/linux/gcma.h index f61edd466d23..831180cd1483 100644 --- a/include/linux/gcma.h +++ b/include/linux/gcma.h @@ -5,6 +5,21 @@ #include #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, diff --git a/mm/gcma_sysfs.c b/mm/gcma_sysfs.c index a2a83c2c2661..c1eaabbb6fdb 100644 --- a/mm/gcma_sysfs.c +++ b/mm/gcma_sysfs.c @@ -1,5 +1,6 @@ #include #include +#include #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. */ diff --git a/mm/gcma_sysfs.h b/mm/gcma_sysfs.h index 161baac9341d..cf93302b7e4f 100644 --- a/mm/gcma_sysfs.h +++ b/mm/gcma_sysfs.h @@ -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);