Skip to content

Commit 934a115

Browse files
author
CKI KWF Bot
committed
Merge: mm: fix the inaccurate memory statistics issue for users
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1198 JIRA: https://issues.redhat.com/browse/RHEL-101961 This MR fixes an accounting issue with the 64K kernel on large systems where VmRSS, RssAnon and RssFile from /proc/self/status may be reported as zeroes for certain applications. Signed-off-by: Luiz Capitulino <luizcap@redhat.com> Approved-by: Waiman Long <longman@redhat.com> Approved-by: Rafael Aquini <raquini@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 3bda682 + 478532b commit 934a115

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

fs/proc/task_mmu.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
3636
unsigned long text, lib, swap, anon, file, shmem;
3737
unsigned long hiwater_vm, total_vm, hiwater_rss, total_rss;
3838

39-
anon = get_mm_counter(mm, MM_ANONPAGES);
40-
file = get_mm_counter(mm, MM_FILEPAGES);
41-
shmem = get_mm_counter(mm, MM_SHMEMPAGES);
39+
anon = get_mm_counter_sum(mm, MM_ANONPAGES);
40+
file = get_mm_counter_sum(mm, MM_FILEPAGES);
41+
shmem = get_mm_counter_sum(mm, MM_SHMEMPAGES);
4242

4343
/*
4444
* Note: to minimize their overhead, mm maintains hiwater_vm and
@@ -59,7 +59,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
5959
text = min(text, mm->exec_vm << PAGE_SHIFT);
6060
lib = (mm->exec_vm << PAGE_SHIFT) - text;
6161

62-
swap = get_mm_counter(mm, MM_SWAPENTS);
62+
swap = get_mm_counter_sum(mm, MM_SWAPENTS);
6363
SEQ_PUT_DEC("VmPeak:\t", hiwater_vm);
6464
SEQ_PUT_DEC(" kB\nVmSize:\t", total_vm);
6565
SEQ_PUT_DEC(" kB\nVmLck:\t", mm->locked_vm);
@@ -92,12 +92,12 @@ unsigned long task_statm(struct mm_struct *mm,
9292
unsigned long *shared, unsigned long *text,
9393
unsigned long *data, unsigned long *resident)
9494
{
95-
*shared = get_mm_counter(mm, MM_FILEPAGES) +
96-
get_mm_counter(mm, MM_SHMEMPAGES);
95+
*shared = get_mm_counter_sum(mm, MM_FILEPAGES) +
96+
get_mm_counter_sum(mm, MM_SHMEMPAGES);
9797
*text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK))
9898
>> PAGE_SHIFT;
9999
*data = mm->data_vm + mm->stack_vm;
100-
*resident = *shared + get_mm_counter(mm, MM_ANONPAGES);
100+
*resident = *shared + get_mm_counter_sum(mm, MM_ANONPAGES);
101101
return mm->total_vm;
102102
}
103103

include/linux/mm.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,6 +2669,11 @@ static inline unsigned long get_mm_counter(struct mm_struct *mm, int member)
26692669
return percpu_counter_read_positive(&mm->rss_stat[member]);
26702670
}
26712671

2672+
static inline unsigned long get_mm_counter_sum(struct mm_struct *mm, int member)
2673+
{
2674+
return percpu_counter_sum_positive(&mm->rss_stat[member]);
2675+
}
2676+
26722677
void mm_trace_rss_stat(struct mm_struct *mm, int member);
26732678

26742679
static inline void add_mm_counter(struct mm_struct *mm, int member, long value)

0 commit comments

Comments
 (0)