diff --git a/include/linux/page_size_compat.h b/include/linux/page_size_compat.h index 644f74d8c959..1730e7c5ee7a 100644 --- a/include/linux/page_size_compat.h +++ b/include/linux/page_size_compat.h @@ -174,6 +174,20 @@ static inline bool __is_emulated_pagemap_file(struct file *file) } #endif +static __always_inline void __adjust_cachestat_counters(struct cachestat *cs) +{ + unsigned int nr_sub_pages = __PAGE_SIZE / PAGE_SIZE; + + if (nr_sub_pages <= 1) + return; + + cs->nr_cache /= nr_sub_pages; + cs->nr_dirty /= nr_sub_pages; + cs->nr_writeback /= nr_sub_pages; + cs->nr_evicted /= nr_sub_pages; + cs->nr_recently_evicted /= nr_sub_pages; +} + #endif /* !__ASSEMBLY__ */ #endif /* __LINUX_PAGE_SIZE_COMPAT_H */ diff --git a/mm/filemap.c b/mm/filemap.c index 6540cc77a20b..2316c739c8b3 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -4447,6 +4448,8 @@ resched: } } rcu_read_unlock(); + + __adjust_cachestat_counters(cs); } /*