Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1179968imp; Thu, 21 Feb 2019 21:08:18 -0800 (PST) X-Google-Smtp-Source: AHgI3IZXqIRDKOrqjY+SLHCXnU2oOTudWN0uUrtTojuS4UcvPe759w6eCxwH0mSE9fist+SWHPKH X-Received: by 2002:a63:2ccd:: with SMTP id s196mr2220194pgs.194.1550812098849; Thu, 21 Feb 2019 21:08:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550812098; cv=none; d=google.com; s=arc-20160816; b=pKv18Hgym+NK0GlS0dGA2bFQwC6nNuDSJhYu9kAx0iXc8By/U0MhCGtVc2gA5G42Ic EwJG53WY+QiQmtAEkCa2vUTBBm9tMKvIZ9OeSmIR7tfJcCkgcmQhgoSn5zeD/ts8ECT6 mBdsBkeDeoc4b0NLGSHRNuYDlRGqOzi/gbcBJMjIAKJEXj505SbzKSkJNw/UesOuEGny UFOZo0iTpoHgVsctbEltA4mixSNu8zHTt8IOBqw0km3o02SvC1Bd0ufms6Zsbu72Exy4 HVs7Sn0z54f2K5tNl8mFl8aawMJWhD6Xf42mJm+YKvwAdMNbZGsmzEpi6nchE/bC4xqD pA3Q== 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=sMzbtLXxmUkTmnmDuOn/8WkbA9/hakMSs7eQaMVhfII=; b=koQk1YttQCEhTbUFJo03JMFJdcPWjBYDCwZLG1P2xJYJhPajzDWi7dlvf6/vugzlYY ZV4wwELlwf0TAFvqID/h0YQqZ15fJSNcw1fl+ewHJlKa+1q/EDG1pEJ+M8O89eATo5cw NGlKZDTV66GWfAVIIYK/XYt31Z+e0r3+A2rH5D5RIZpD09N9tN4MCwuLGwF3XZk3J9Bx jqUoHGVjn1mkrZgZb9zY2LnGgxK5TnXkvgUrYD3p8mDqhHJl8UcArw6/WUISbMiNviKN rJxUoXKSVUsVBdIhSIqttyRAa5LOb1aeNQ2wymlqWVOwgH52lL/BbIriYVwavfZh3djl E03A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 75si476013pgb.230.2019.02.21.21.08.01; Thu, 21 Feb 2019 21:08:18 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725872AbfBVFHj (ORCPT + 99 others); Fri, 22 Feb 2019 00:07:39 -0500 Received: from lgeamrelo12.lge.com ([156.147.23.52]:46408 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725710AbfBVFHj (ORCPT ); Fri, 22 Feb 2019 00:07:39 -0500 X-Greylist: delayed 1800 seconds by postgrey-1.27 at vger.kernel.org; Fri, 22 Feb 2019 00:07:38 EST Received: from unknown (HELO lgeamrelo02.lge.com) (156.147.1.126) by 156.147.23.52 with ESMTP; 22 Feb 2019 13:37:36 +0900 X-Original-SENDERIP: 156.147.1.126 X-Original-MAILFROM: junil0814.lee@lge.com Received: from unknown (HELO localhost.localdomain) (10.168.178.220) by 156.147.1.126 with ESMTP; 22 Feb 2019 13:37:35 +0900 X-Original-SENDERIP: 10.168.178.220 X-Original-MAILFROM: junil0814.lee@lge.com From: Junil Lee To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, pasha.tatashin@oracle.com, kirill.shutemov@linux.intel.com, jrdr.linux@gmail.com, dan.j.williams@intel.com, alexander.h.duyck@linux.intel.com, andreyknvl@google.com, arunks@codeaurora.org, keith.busch@intel.com, guro@fb.com, hannes@cmpxchg.org, rientjes@google.com, penguin-kernel@I-love.SAKURA.ne.jp, shakeelb@google.com, yuzhoujian@didichuxing.com, Junil Lee Subject: [PATCH] mm, oom: OOM killer use rss size without shmem Date: Fri, 22 Feb 2019 13:37:33 +0900 Message-Id: <1550810253-152925-1-git-send-email-junil0814.lee@lge.com> X-Mailer: git-send-email 2.6.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The oom killer use get_mm_rss() function to estimate how free memory will be reclaimed when the oom killer select victim task. However, the returned rss size by get_mm_rss() function was changed from "mm, shmem: add internal shmem resident memory accounting" commit. This commit makes the get_mm_rss() return size including SHMEM pages. The oom killer can't get free memory from SHMEM pages directly after kill victim process, it leads to mis-calculate victim points. Therefore, make new API as get_mm_rss_wo_shmem() which returns the rss value excluding SHMEM_PAGES. Signed-off-by: Junil Lee --- include/linux/mm.h | 6 ++++++ mm/oom_kill.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 2d483db..bca3acc 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1701,6 +1701,12 @@ static inline int mm_counter(struct page *page) return mm_counter_file(page); } +static inline unsigned long get_mm_rss_wo_shmem(struct mm_struct *mm) +{ + return get_mm_counter(mm, MM_FILEPAGES) + + get_mm_counter(mm, MM_ANONPAGES); +} + static inline unsigned long get_mm_rss(struct mm_struct *mm) { return get_mm_counter(mm, MM_FILEPAGES) + diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 3a24848..e569737 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -230,7 +230,7 @@ unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg, * The baseline for the badness score is the proportion of RAM that each * task's rss, pagetable and swap space use. */ - points = get_mm_rss(p->mm) + get_mm_counter(p->mm, MM_SWAPENTS) + + points = get_mm_rss_wo_shmem(p->mm) + get_mm_counter(p->mm, MM_SWAPENTS) + mm_pgtables_bytes(p->mm) / PAGE_SIZE; task_unlock(p); @@ -419,7 +419,7 @@ static void dump_tasks(struct mem_cgroup *memcg, const nodemask_t *nodemask) 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), + task->tgid, task->mm->total_vm, get_mm_rss_wo_shmem(task->mm), mm_pgtables_bytes(task->mm), get_mm_counter(task->mm, MM_SWAPENTS), task->signal->oom_score_adj, task->comm); -- 2.6.2