Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5948089ybi; Wed, 12 Jun 2019 11:11:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqybXMME7nD2/XfpkL6LgCD78AJEUOJAMYG4ibC5hxhw+A2T69nCCHnwfqGUtBeA3BXYYfep X-Received: by 2002:a63:144e:: with SMTP id 14mr25977210pgu.304.1560363093480; Wed, 12 Jun 2019 11:11:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560363093; cv=none; d=google.com; s=arc-20160816; b=qDJx5NBddF0EKQow2rOE1sTRkdB3dWj0zZm7OYTF0hRUmzH1QPUlqvDcn8NMH2BEpK iRy9CZxE8a9VTU+4xsQMuSZXP3rP5hwCBRwTGvH2A1/1fNF/2c9pH/9fBAQa+Tpgh2y2 IOvsvS91bov6EDu+OdNTMiMIJamI92CtFRn1gtBYnOFsJ7dJR6gBh+t4nbq8TxehKN3K URbHA76nCsCmg2x050JMVpYbcYxdemGuT9vRMq7ru1eu7g5guluQkWVe1peZstpEwpkK HfnggfhGmaSoo7BgdAQALtwcRl/Y5NoGMHrkMn//L8oofAZbMgGQXm8be1icjy8JGAN7 75Hg== 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=Re4Dt0O/x00kMRajxlQQ1fNxVXQ/i3h5Zs5UpC9Yu5Q=; b=U53eCVal2jXVcYDexiuaEHm3SYUu/cfBw4vpMblmUwhxzma94NGkKfi+qZhkUj6Cjm mJE3eS3S6DPgJRCCQD+FucFTVxsZgiHFRh3dLMlloLGf7Gds9KG4y5vV0Yn6dB68sKTD ibtscmyKfotsgHQpFgcTFHzlcvTDRaVygMVrTYlBY20V3uuofCaQtkm9qppwdUqLhjSK Ggfibm+Q+ciDVhOvHmS4T+9TVpUvBQpb66GGmQwzMKWhf8xFkkXWzt5lR8PDrRZ2nP9y PxvH4MntDf/fIdWijGc4mX0MbptcIsokVOaUnI18tLuNlJBJZnouE4Isd8yD6jccARo4 KLrg== 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 l10si408320pgk.276.2019.06.12.11.11.18; Wed, 12 Jun 2019 11:11:33 -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 S1728774AbfFLR6D (ORCPT + 99 others); Wed, 12 Jun 2019 13:58:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49262 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727439AbfFLR6C (ORCPT ); Wed, 12 Jun 2019 13:58:02 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E4BC3001572; Wed, 12 Jun 2019 17:58:02 +0000 (UTC) Received: from jsavitz.bos.com (dhcp-17-175.bos.redhat.com [10.18.17.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE1371001B17; Wed, 12 Jun 2019 17:57:55 +0000 (UTC) From: Joel Savitz To: linux-kernel@vger.kernel.org Cc: Joel Savitz , Rafael Aquini , Andrew Morton , David Rientjes , linux-mm@kvack.org Subject: [RESEND PATCH v2] mm/oom_killer: Add task UID to info message on an oom kill Date: Wed, 12 Jun 2019 13:57:53 -0400 Message-Id: <1560362273-534-1-git-send-email-jsavitz@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 12 Jun 2019 17:58:02 +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 Suggested-by: David Rientjes 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