From patchwork Fri Jun 24 08:04:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12894082 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00196CCA483 for ; Fri, 24 Jun 2022 08:04:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A7478E01F1; Fri, 24 Jun 2022 04:04:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 527ED8E01E7; Fri, 24 Jun 2022 04:04:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C8388E01F1; Fri, 24 Jun 2022 04:04:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 228768E01E7 for ; Fri, 24 Jun 2022 04:04:52 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 031E533C08 for ; Fri, 24 Jun 2022 08:04:51 +0000 (UTC) X-FDA: 79612393224.09.4D65F45 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) by imf04.hostedemail.com (Postfix) with ESMTP id 6B83340024 for ; Fri, 24 Jun 2022 08:04:51 +0000 (UTC) Received: by mail-ed1-f54.google.com with SMTP id e2so2335676edv.3 for ; Fri, 24 Jun 2022 01:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6j0Gpi54M48fI1NcNiQ2zQbh0cpYb0wFPGGgMk6DiNo=; b=fk1Q8DhcfpcNKxoNpWHiQSY9AE96A9aVxjRhZQQUWDZRdv7jEZGX6hMqBKr6rqq5fy 9t7SzX2Vl712znvGA8+d7SsV/SLjOuEz8EJqw7KMYQFjdKxhRvkPZZZiwuZ1Mbl3yEfV 0czXl+5DWtas1YhPkEGvL798aRjcHESclYc/C/XKzSoId3CQoIeGfVhaQ9gE8V4nAnvz yPNyik6e47/+4vPDqcfn3WUpjSuAR16t34HQILns5txBmvATmE4OpVbQiTQ3jTbxv/Ju QRq5NGdaccxi64UFpJMIIRqRVNhqRxqlSvbkbbvI6sIihwWIzkjAbvWZWMqIO6dN8QxY AsDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6j0Gpi54M48fI1NcNiQ2zQbh0cpYb0wFPGGgMk6DiNo=; b=Tc8lC3g8eopJzhC+pOk2VShDxcCTsCaALfivOV6EaEM/UqGdtXFXDosiU9hJfhoz4L 823EU8MjZzv9/dRGWT0dEkaulxkWtxT3ZNVjELQ8pg+vA/iW30lTMVVy1csrdDTBIzCU 4eKQcQFXd+O/69aISwL3yaQs03Mj6ZONbVHiyofgg/KtItQva0gt08Xcx5kgybmO4VYz n90UNaZjhuxQb0oxZ8zOmPknwlKyFeTI9gqpNMoRjgCDFBPPuB2vsC2mWIT7S14fR5RI PSmFnctSQgHsU/ykdJtQlHAaVXh/Cjjst+JE23UZlYMGgdvsD0iy0Zr4ks0SLIPAl/4j mNbw== X-Gm-Message-State: AJIora/ZiwV8ETx8Bb661zQbuPR8QCKC8DdcmooZB4dM8OzLdRLgtNsC Mcs5svbHkn2WitLHX1IVcEA= X-Google-Smtp-Source: AGRyM1srTDsD3lF1Nj8u/D/xjMuJOrSeuMWkaVaQOvHyyq+uUmVQu5uN8XQJNPLwVdaC1R98cp8x3A== X-Received: by 2002:a05:6402:350f:b0:42f:68f9:ae5 with SMTP id b15-20020a056402350f00b0042f68f90ae5mr16118492edd.36.1656057890308; Fri, 24 Jun 2022 01:04:50 -0700 (PDT) Received: from able.fritz.box (p57b0bd9f.dip0.t-ipconnect.de. [87.176.189.159]) by smtp.gmail.com with ESMTPSA id c19-20020a170906155300b006fea43db5c1sm697779ejd.21.2022.06.24.01.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 01:04:49 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, dri-devel@lists.freedesktop.org Cc: mhocko@suse.com, Andrey Grodzovsky Subject: [PATCH 02/14] oom: take per file RSS into account Date: Fri, 24 Jun 2022 10:04:32 +0200 Message-Id: <20220624080444.7619-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220624080444.7619-1-christian.koenig@amd.com> References: <20220624080444.7619-1-christian.koenig@amd.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fk1Q8Dhc; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of ckoenig.leichtzumerken@gmail.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=ckoenig.leichtzumerken@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656057891; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6j0Gpi54M48fI1NcNiQ2zQbh0cpYb0wFPGGgMk6DiNo=; b=ISA0bWVVHlms9i5S9Flz2p8AoaC9PnMCS+MKqnSwO64ZaZvuaGYl1pgxpubd0alLX3uTfM z2yOLC6fOYIyBjMRSI/Z3UKlFYh62OoAb3c8sBkt8pkjDr9YDM/eYh7DIBR7lR+Lqk69Kj et1F92UOPQEH6sZ7dUFhMxBcqc5E60A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656057891; a=rsa-sha256; cv=none; b=XXOHlNOou6FAAgDtD3ACi4GTSvOWSKoQbMjifW14B/15+gsLxbA7nw94WGaH43CnXd2SN5 UT4VOqIk+/ntQQGueyqe4YQRcPMHjMXNj2iDXcwrT6UVIcPaz+cEfXdq/LCPs6n6hdEGQh CrpsowynAajqiKgVaEDOj8p4KEUOH6o= X-Stat-Signature: fh36ndm45k1756ddpambxyr5xjgbezia X-Rspamd-Queue-Id: 6B83340024 X-Rspam-User: Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fk1Q8Dhc; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of ckoenig.leichtzumerken@gmail.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=ckoenig.leichtzumerken@gmail.com X-Rspamd-Server: rspam12 X-HE-Tag: 1656057891-540795 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Andrey Grodzovsky Try to make better decisions which process to kill based on per file RSS. Signed-off-by: Andrey Grodzovsky --- mm/oom_kill.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 3c6cf9e3cd66..76a5ea73eb6a 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -18,6 +18,7 @@ * kernel subsystems and hints as to where to find out what things do. */ +#include #include #include #include @@ -228,7 +229,8 @@ long oom_badness(struct task_struct *p, unsigned long totalpages) * task's rss, pagetable and swap space use. */ points = get_mm_rss(p->mm) + get_mm_counter(p->mm, MM_SWAPENTS) + - mm_pgtables_bytes(p->mm) / PAGE_SIZE; + files_rss(p->files) + mm_pgtables_bytes(p->mm) / PAGE_SIZE; + task_unlock(p); /* Normalize to oom_score_adj units */ @@ -401,8 +403,8 @@ static int dump_task(struct task_struct *p, void *arg) pr_info("[%7d] %5d %5d %8lu %8lu %8ld %8lu %5hd %s\n", task->pid, from_kuid(&init_user_ns, task_uid(task)), - task->tgid, task->mm->total_vm, get_mm_rss(task->mm), - mm_pgtables_bytes(task->mm), + task->tgid, task->mm->total_vm, get_mm_rss(task->mm) + + files_rss(task->files), mm_pgtables_bytes(task->mm), get_mm_counter(task->mm, MM_SWAPENTS), task->signal->oom_score_adj, task->comm); task_unlock(task); @@ -594,7 +596,8 @@ static bool oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm) pr_info("oom_reaper: reaped process %d (%s), now anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n", task_pid_nr(tsk), tsk->comm, K(get_mm_counter(mm, MM_ANONPAGES)), - K(get_mm_counter(mm, MM_FILEPAGES)), + K(get_mm_counter(mm, MM_FILEPAGES) + + files_rss(tsk->files)), K(get_mm_counter(mm, MM_SHMEMPAGES))); out_finish: trace_finish_task_reaping(tsk->pid); @@ -950,7 +953,7 @@ static void __oom_kill_process(struct task_struct *victim, const char *message) pr_err("%s: Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB, UID:%u pgtables:%lukB oom_score_adj:%hd\n", message, task_pid_nr(victim), victim->comm, K(mm->total_vm), K(get_mm_counter(mm, MM_ANONPAGES)), - K(get_mm_counter(mm, MM_FILEPAGES)), + K(get_mm_counter(mm, MM_FILEPAGES) + files_rss(victim->files)), K(get_mm_counter(mm, MM_SHMEMPAGES)), from_kuid(&init_user_ns, task_uid(victim)), mm_pgtables_bytes(mm) >> 10, victim->signal->oom_score_adj);