git: 4a864f624a70 - main - vm_pageout: Print a more accurate message to the console before an OOM kill
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 14 Jan 2022 20:39:32 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=4a864f624a7097f1d032a0350ac70fa6c371179e
commit 4a864f624a7097f1d032a0350ac70fa6c371179e
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-01-14 20:03:53 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-01-14 20:04:21 +0000
vm_pageout: Print a more accurate message to the console before an OOM kill
Previously we'd always print "out of swap space." This can be
misleading, as there are other reasons an OOM kill can be triggered. In
particular, it's entirely possible to trigger an OOM kill on a system
with plenty of free swap space.
Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33810
---
sys/vm/vm_pageout.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c
index 899d35cd43b6..36d5f3275800 100644
--- a/sys/vm/vm_pageout.c
+++ b/sys/vm/vm_pageout.c
@@ -1902,6 +1902,7 @@ static struct mtx vm_oom_ratelim_mtx;
void
vm_pageout_oom(int shortage)
{
+ const char *reason;
struct proc *p, *bigproc;
vm_offset_t size, bigsize;
struct thread *td;
@@ -2014,11 +2015,25 @@ vm_pageout_oom(int shortage)
}
}
sx_sunlock(&allproc_lock);
+
if (bigproc != NULL) {
+ switch (shortage) {
+ case VM_OOM_MEM:
+ reason = "failed to reclaim memory";
+ break;
+ case VM_OOM_MEM_PF:
+ reason = "a thread waited too long to allocate a page";
+ break;
+ case VM_OOM_SWAPZ:
+ reason = "out of swap space";
+ break;
+ default:
+ panic("unknown OOM reason %d", shortage);
+ }
if (vm_panic_on_oom != 0 && --vm_panic_on_oom == 0)
- panic("out of swap space");
+ panic("%s", reason);
PROC_LOCK(bigproc);
- killproc(bigproc, "out of swap space");
+ killproc(bigproc, reason);
sched_nice(bigproc, PRIO_MIN);
_PRELE(bigproc);
PROC_UNLOCK(bigproc);