Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp899053yba; Wed, 24 Apr 2019 11:24:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7aYRrK3Bpka5MObmuoTiSl+8yHkeq8vsUOxgXXDI3rnGPOh68Uqh05un0lsgdiDu/shkq X-Received: by 2002:a17:902:9b83:: with SMTP id y3mr34076789plp.165.1556130285944; Wed, 24 Apr 2019 11:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556130285; cv=none; d=google.com; s=arc-20160816; b=rU9VBJSuTbP3kJV3EXvhhfn4Ow959Ap9WQDZJSDGwYOlL1F6cLzV7/crNrT/OSKaji PoWQIb4PtQDRTOYpLY1HzXOBldKDD/fz/Sm5MvLBYjny3zlHAdzs2rR0azwHKVCjDCQk RIg5nPE0o0xDevPcHnQMj/TjtOmCkLdLxFRkJW1jSEAowGjm6wLfplRgjStX/XM4Oi9z m+sA4DUCV1AI2Sid4dGcIRYwoN7l+u02QBZNIarEPjyLzBr/sTmjWhpk15SKNrAqrJit Flm0NRdkGBZEox6AMBr7G9EarMlD9fXm+LH+yTAfk/561s8xcijeenotV7M0zKELDcHk uOSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=eJViKmsAzVSM0DDfErvXPZinn5xPdL3l5cHBWN7lxyE=; b=NSH8F+KbnFC36vOMBFaWZTdkl8nNej5CmX4wJwLBPyqxHkgrdNxVQkOC5PiV15nlbF X+sBd9hHqPRZZ+7T2plGhsbeVwplrhn9aw4tfiu4CbaED1DEAvSedu5a0SoWE5zRzhs+ YvSCpLBPKHCUnbMoXD1pn48P4aWbP+HfsQUugvtmf/G4Hv8beJHd73DWOP5n3MrE8WMn IPrZQGBvIUk0kpkrxsuDh/MT6nnBxWcSutQprydYKeWfWbPlhn20wQZQnwRhIh3GVT1J F/YMhaesyrmDQat4G0/ZwRj4+Yjd+2jGmz4smRS4oPn7Cz9V8JyoVr8SP3Dn0FYo5tQs luaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si18436049pga.498.2019.04.24.11.24.30; Wed, 24 Apr 2019 11:24:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733265AbfDXSVk (ORCPT + 99 others); Wed, 24 Apr 2019 14:21:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34628 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbfDXSVk (ORCPT ); Wed, 24 Apr 2019 14:21:40 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 206391393C3 for ; Wed, 24 Apr 2019 18:21:40 +0000 (UTC) Received: from jsavitz.bos.com (dhcp-17-124.bos.redhat.com [10.18.17.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EF061884F; Wed, 24 Apr 2019 18:21:37 +0000 (UTC) From: Joel Savitz To: linux-kernel@vger.kernel.org Cc: Joel Savitz , Rafael Aquini Subject: [PATCH] mm/oom_killer: Add task UID to info message on an oom kill Date: Wed, 24 Apr 2019 14:20:13 -0400 Message-Id: <1556130013-19021-1-git-send-email-jsavitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 24 Apr 2019 18:21:40 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the event of an oom kill, useful information about the killed process is printed to dmesg. Users, especially system administrators, will find it useful to immediately see the UID of the process. In the following example, abuse_the_ram is the name of a program that attempts to iteratively allocate all available memory until it is stopped by force. Current message: Out of memory: Killed process 35389 (abuse_the_ram) total-vm:133718232kB, anon-rss:129624980kB, file-rss:0kB, shmem-rss:0kB Patched message: Out of memory: Killed process 2739 (abuse_the_ram), UID 0, total-vm:133880028kB, anon-rss:129754836kB, file-rss:0kB, shmem-rss:0kB Signed-off-by: Joel Savitz --- mm/oom_kill.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 3a2484884cfd..22972648b758 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -874,9 +874,9 @@ static void __oom_kill_process(struct task_struct *victim, const char *message) */ do_send_sig_info(SIGKILL, SEND_SIG_PRIV, victim, PIDTYPE_TGID); mark_oom_victim(victim); - pr_err("%s: Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n", + pr_err("%s: Killed process %d (%s), UID %d, total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n", message, task_pid_nr(victim), victim->comm, - K(victim->mm->total_vm), + task_uid(victim).val, K(victim->mm->total_vm), K(get_mm_counter(victim->mm, MM_ANONPAGES)), K(get_mm_counter(victim->mm, MM_FILEPAGES)), K(get_mm_counter(victim->mm, MM_SHMEMPAGES))); -- 2.18.1