mm/util: Fix meminfo CommitLimit
Subsystems (2)
PATCH 1/1 mm/util: Fix meminfo CommitLimit
On a machine with 8GB memory, no any swap device, the /proc/meminfo CommitLimit shows 4070944KB regardless of overcommit_memory being set to 0/1/2. This patch fixes this bug, and the final effect is as follows:
- when overcommit_memory being set to 0 ## OVERCOMMIT_GUESS
CommitLimit: 8141884 kB
- when overcommit_memory being set to 1 ## OVERCOMMIT_ALWAYS
CommitLimit: 0 kB
- when overcommit_memory being set to 2 ## OVERCOMMIT_NEVER and overcommit_ratio 50
CommitLimit: 4070940 kB
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by Vernon Yang <[email protected]>
--- mm/util.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
mm/util.c +10 -1
@@ -932,12 +932,21 @@ int overcommit_kbytes_handler(const struct ctl_table *table, int write, void *bu }/* -* Committed memory limit enforced when OVERCOMMIT_NEVER policy is used +* Committed virtual memory limit +* +* return 0 if OVERCOMMIT_ALWAYS policy is used, otherwise return committed +* memory limit enforced if OVERCOMMIT_GUESS or OVERCOMMIT_NEVER policy is used. */ unsigned long vm_commit_limit (void ) {unsigned long allowed; +if (sysctl_overcommit_memory ==OVERCOMMIT_ALWAYS ) +return 0 ; + +if (sysctl_overcommit_memory ==OVERCOMMIT_GUESS ) +return totalram_pages () + total_swap_pages; +if (sysctl_overcommit_kbytes) allowed = sysctl_overcommit_kbytes >> (PAGE_SHIFT -10 );else
base-commit: 47ac09b91befbb6a235ab620c32af719f8208399
Signature · 1 line
2.34.1