From: Ma Wupeng mawupeng1@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4SK3S CVE: NA
--------------------------------
Add ReliableTaskUsed in /proc/meminfo if memory reliable is enabled. - ReliableTaskUsed: reliable memory used by special user tasks and global init process
Change variable reliable_user_used_nr_page to a more accurate reliable_task_used_nr_page.
Signed-off-by: Ma Wupeng mawupeng1@huawei.com Reviewed-by: Kefeng Wangwangkefeng.wang@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- Documentation/filesystems/proc.txt | 3 +++ include/linux/mem_reliable.h | 6 +++--- mm/mem_reliable.c | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index 3c0e7e5f78a96..7329e8a4281f7 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt @@ -884,6 +884,7 @@ ShmemHugePages: 0 kB ShmemPmdMapped: 0 kB ReliableTotal: 7340032 kB ReliableUsed: 418824 kB +ReliableTaskUsed: 418824 kB ReliableBuddyMem: 418824 kB ReliableShmem: 96 kB
@@ -978,6 +979,8 @@ VmallocChunk: largest contiguous block of vmalloc area which is free allocations. This stat excludes the cost of metadata. ReliableTotal: Total reliable memory size ReliableUsed: The used amount of reliable memory +ReliableTaskUsed: Reliable memory used by special user tasks and global + init process ReliableBuddyMem: Total mirrored memory size in buddy system ReliableShmem: Reliable memory used by shmem
diff --git a/include/linux/mem_reliable.h b/include/linux/mem_reliable.h index 4c15db9c19443..c9c9b9aa8dfbb 100644 --- a/include/linux/mem_reliable.h +++ b/include/linux/mem_reliable.h @@ -15,7 +15,7 @@ extern struct static_key_false mem_reliable;
extern bool reliable_enabled; -extern atomic_long_t reliable_user_used_nr_page; +extern atomic_long_t reliable_task_used_nr_page; extern unsigned long task_reliable_limit __read_mostly; extern bool reliable_allow_fallback; extern bool shmem_reliable; @@ -74,13 +74,13 @@ static inline void reliable_page_counter(struct page *page, { if (page_reliable(page)) { atomic_long_add(val, &mm->reliable_nr_page); - atomic_long_add(val, &reliable_user_used_nr_page); + atomic_long_add(val, &reliable_task_used_nr_page); } }
static inline bool reliable_mem_limit_check(unsigned long nr_page) { - return atomic_long_read(&reliable_user_used_nr_page) + nr_page <= + return atomic_long_read(&reliable_task_used_nr_page) + nr_page <= task_reliable_limit / PAGE_SIZE; }
diff --git a/mm/mem_reliable.c b/mm/mem_reliable.c index 5c56b2c6f4b52..4aa6b83ca4a6b 100644 --- a/mm/mem_reliable.c +++ b/mm/mem_reliable.c @@ -24,7 +24,7 @@ DEFINE_STATIC_KEY_FALSE(mem_reliable);
bool reliable_enabled; static atomic_long_t total_reliable_mem; -atomic_long_t reliable_user_used_nr_page; +atomic_long_t reliable_task_used_nr_page; /* reliable user limit for user tasks with reliable flag */ unsigned long task_reliable_limit = ULONG_MAX; bool reliable_allow_fallback __read_mostly = true; @@ -192,6 +192,8 @@ void reliable_report_meminfo(struct seq_file *m) total_reliable_mem_sz() >> PAGE_SHIFT); show_val_kb(m, "ReliableUsed: ", used_reliable_mem_sz() >> PAGE_SHIFT); + show_val_kb(m, "ReliableTaskUsed: ", + atomic_long_read(&reliable_task_used_nr_page)); show_val_kb(m, "ReliableBuddyMem: ", nr_buddy_pages);
if (shmem_reliable_is_enabled()) { @@ -514,7 +516,7 @@ void reliable_show_mem_info(void) pr_info("task_reliable_limit: %lu kB", task_reliable_limit >> 10); pr_info("reliable_user_used: %ld kB", - atomic_long_read(&reliable_user_used_nr_page) << + atomic_long_read(&reliable_task_used_nr_page) << (PAGE_SHIFT - 10)); } }