From nobody Fri Jan 14 20:39:32 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id EDF50195E7AE; Fri, 14 Jan 2022 20:39:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JbCpD4wb3z3Cq5; Fri, 14 Jan 2022 20:39:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642192772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qckrVVfYyMhpYE/FgU3/orsib0gqPjz4RHb1fknKR6w=; b=dHlpWdtousBNGTqtEv/ver+XkMvNGJHnojTYNeLzcWXd6xqC4m9jqMNuQxbPzPU+ZkUTtA k35ts4gCBxehlInaeTefTX6WTyKObzcpyIlwOYMi/3tKwmdSBb/8qkdjNH4oljkF6tcG/A yHTvYmAd6YCpAkIeEXnpSiUu6mH3k6F9z+AqZ21i/e+w31dgEvCIe9isHnlmVSfMkg81Ns qwoTyTJr2a8H6JZk3UEW9uiA24BuknFZ0GqFMjFGxpDwIJ6dQabiwfDKwloekCm7ZyhBBx 92ZEvKO9/OKhkNS7P38yRLLVtkMr2C2JZQmKy5lnInolskixaqAXmPxLuVQcww== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 741471A718; Fri, 14 Jan 2022 20:39:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20EKdW9X087534; Fri, 14 Jan 2022 20:39:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20EKdWQV087533; Fri, 14 Jan 2022 20:39:32 GMT (envelope-from git) Date: Fri, 14 Jan 2022 20:39:32 GMT Message-Id: <202201142039.20EKdWQV087533@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 4a864f624a70 - main - vm_pageout: Print a more accurate message to the console before an OOM kill List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4a864f624a7097f1d032a0350ac70fa6c371179e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642192772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qckrVVfYyMhpYE/FgU3/orsib0gqPjz4RHb1fknKR6w=; b=fGOtpAVPXj3jwi0+OSNanMhh/oSRIyo1bP/kcfrQizcFrXNYMix0QRvUtIkWEOQplGKgdf nM3hSmz26cmIeX48tc/bAykRrI5EQ4ZzHLC7+5KWDnU3N6OAlJbS68UJ/PhTov4yYYzIuJ c9wRjNG2mw6M8HyIRQ5cdXKsb+ySjY+FZtNYzQ6DWeFpzPD8rlZXdjGpFw8RtY/YqK4pTj 7WOE1by//kWLUI0Ux5iXk9UNbssxdjkb480+5wAbC8xWtR2+TscnUMqexYQbx1Q+JXmgdf 02/bQvcSz9P3VxqzDG6IYinRmhPecniPyAbML/TNJkMQ4l0rDNJlqztQ/LcPUw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642192772; a=rsa-sha256; cv=none; b=Zdnx01RgZg0DSrSenYyfxQRJhZ0NDqqG+PLffeLenOj6vsAL42hmhXJC3DNnZqTCZ23EXj gfQiRw3+hSrvDG2V6XuyvXAg8omGtH2Ier0ZMNbI9Gy2fBWdg4iFh0DAirm2aTBZT8dEUI RB1QdBvT9WJZjfxIoBH8OrfDjvspwvVu9ODhWzGhbgjCJQ4L8oXH3Y47jFwSq5x5WFq52N KxbpjbXGk786RFC2denjSqgC3lr0jnCoTJRIWwBoTmXiIbAg/Z9oDm4vSlZEY6qADuTyZT G4qdaG01M2jZVSKFC4+ilvByEJFYRhTbBanmEiIAaH+yuaMAnHX8cbiq2I01RA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4a864f624a7097f1d032a0350ac70fa6c371179e commit 4a864f624a7097f1d032a0350ac70fa6c371179e Author: Mark Johnston AuthorDate: 2022-01-14 20:03:53 +0000 Commit: Mark Johnston 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);