]> git.karo-electronics.de Git - linux-beck.git/blobdiff - include/linux/mm.h
mm, shmem: add internal shmem resident memory accounting
[linux-beck.git] / include / linux / mm.h
index 00bad7793788b2fb3342bda26335fc0713f0e909..a8ab1fc0e9bcfd3dc488a917ffa91e534e20b42d 100644 (file)
@@ -1361,10 +1361,26 @@ static inline void dec_mm_counter(struct mm_struct *mm, int member)
        atomic_long_dec(&mm->rss_stat.count[member]);
 }
 
+/* Optimized variant when page is already known not to be PageAnon */
+static inline int mm_counter_file(struct page *page)
+{
+       if (PageSwapBacked(page))
+               return MM_SHMEMPAGES;
+       return MM_FILEPAGES;
+}
+
+static inline int mm_counter(struct page *page)
+{
+       if (PageAnon(page))
+               return MM_ANONPAGES;
+       return mm_counter_file(page);
+}
+
 static inline unsigned long get_mm_rss(struct mm_struct *mm)
 {
        return get_mm_counter(mm, MM_FILEPAGES) +
-               get_mm_counter(mm, MM_ANONPAGES);
+               get_mm_counter(mm, MM_ANONPAGES) +
+               get_mm_counter(mm, MM_SHMEMPAGES);
 }
 
 static inline unsigned long get_mm_hiwater_rss(struct mm_struct *mm)