Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp985497yba; Fri, 26 Apr 2019 12:02:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+s0ACLrc3zFVsMifpra9eofGBb6DkJcuwUa4jozozvM8t0PdBDj10eaoICrxEG0ePyCj5 X-Received: by 2002:a63:1555:: with SMTP id 21mr4675765pgv.204.1556305363512; Fri, 26 Apr 2019 12:02:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556305363; cv=none; d=google.com; s=arc-20160816; b=QvTFK0IJdhQkdmRA5G+1LoJavm4pTKFXZXVqYrfh4cX9c1xvdAi1eu1jy9wYvzgQCo FgSTPD9wjobwtCvWUDKi7s4SbB64WZn8a+WD7WyB4yIZJ5QhyUURd+L8cYGnyJVGQm5V ioB1J8tur31I+ImXHCa8YPlvKMZmm3CgSwIk22pN+eEPFodxpZnh14Yy+ySeczel6X2g uMi7CcMXAOr0ZFvuDl7pxt+BeJQ8jUuJfkSlcPijCNpFSEYbcjhx+xvFYXynaMOjkALk NMU95bTngNEeQrvt/tm++sPFqTu6uxTQEoJt9aLT1FMj7GZ722g+ZByP8M11XdbxzuVh LoGw== 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=7vquQD1bZCWUPIvdWygcCm4ZdQjp43fj2hDyr5d0FSY=; b=OKXZ2+HQ/uaEs/+j71p96HnD08GM3X14mKpR6lxHSvR1PPSjXuuAjyUpezvWR/B3rr JLR6uP37JINkugP0Yq4enps/k6O0XLKJqkpeXFrmv48lqBaE0KNO9nj4AcEZtMd+6oC+ iUdQVzadzZmxV1Aew4Hr2MkrByODwVI0XxdnuNJDKj/jQ7hzEm9krRzM5uV7vBCGkzmn KwI8Q6cS3bBAHnv4Ujh5zToZTJj27kLBPTwA9icQx4O/dh3eECVRMSsSMKTJBdePWvC+ tRdTASIFmvkSaAqg5cd3YXmeQIRVz7lXlumQpNnrsOS7RQCQSgz7J8xwIb8QHfHwWGbb kF8g== 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 k9si26479505pfb.251.2019.04.26.12.02.25; Fri, 26 Apr 2019 12:02:43 -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 S1726385AbfDZTAK (ORCPT + 99 others); Fri, 26 Apr 2019 15:00:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38547 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726252AbfDZTAK (ORCPT ); Fri, 26 Apr 2019 15:00:10 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9111B8B97F for ; Fri, 26 Apr 2019 19:00:10 +0000 (UTC) Received: from jsavitz.bos.com (dhcp-17-3.bos.redhat.com [10.18.17.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7171600C5; Fri, 26 Apr 2019 19:00:07 +0000 (UTC) From: Joel Savitz To: linux-kernel@vger.kernel.org Cc: Joel Savitz , Rafael Aquini Subject: [PATCH v2] mm/oom_killer: Add task UID to info message on an oom kill Date: Fri, 26 Apr 2019 14:59:57 -0400 Message-Id: <1556305197-1600-1-git-send-email-jsavitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 26 Apr 2019 19:00:10 +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), total-vm:133880028kB, anon-rss:129754836kB, file-rss:0kB, shmem-rss:0kB, UID 0 Signed-off-by: Joel Savitz --- mm/oom_kill.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 3a2484884cfd..af2e3faa72a0 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -874,12 +874,13 @@ 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) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB, UID %d\n", message, task_pid_nr(victim), victim->comm, 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))); + K(get_mm_counter(victim->mm, MM_SHMEMPAGES)), + from_kuid(&init_user_ns, task_uid(victim))); task_unlock(victim); /* -- 2.18.1