Received: by 10.223.148.5 with SMTP id 5csp7732421wrq; Thu, 18 Jan 2018 08:50:38 -0800 (PST) X-Google-Smtp-Source: ACJfBovToxVuvQFL9VoRDXSh+nOIZoBH6aOuaVLphGjfZ9u0SehhIvVS6f1MYsbWcywFTKQ7mheV X-Received: by 10.99.146.3 with SMTP id o3mr1878509pgd.309.1516294238811; Thu, 18 Jan 2018 08:50:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516294238; cv=none; d=google.com; s=arc-20160816; b=rsbwlmOdke89xrqLyEVZH7iZXls4G00b6zCBA4G7Ov51rGgyMNVnIlvPsB4IvKjjdD /XwwApZX6x7626ZCU3/DdLqdFf+k+jRuG8ox+7proAhftdMVWvvpbyuypGC4JBE1gI+q soc83Uo9pqzLtKrlXXWsvj64Z1FN7BapFeEnL5xpEPbH5ZowDRLw1xP9ARFBQJCC+WFK VgcBfUtMVNKSnx3h4kxo7ExnmPc2xmv5xUr/A7HLhPWGKTjXGbTixISHQYTb+q9fGAj3 mCeNbrS0mgo8jJXbkTWIv55sM2yGDhwAaaMwey0S2uNkkQnfTLCIld9VGpcNYx4afLuy fG5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Iv+BOoO+GSWD766GsN7B6/Dl2cbueW4cwIedVvzn0t4=; b=QzKM9MlyfXtJf7URk0IdQ4Kmuz5ihBOSwoUKhO6cvN0r1fIXp2V4h606PjqXXR0gFV to/uh7HXjnqOWy56WGjfUi/6PCUEJsi43pHFB3KzRLWV3p0XmIg2Ps9hwxmxao1tcxlF bqoys9w/Ad3MKcwE3/98iNRRfprhMdCJ3wH4QFJZElXk7ebBUHUxkjz0TSNWkKWzA7jP EAqJzzuWOQhW0ujUgmGV4NV82TyQCixX19ZHhNaNg+4P+R9A6/LYc0KXDtL9b06TfUWB gpKBIzaVVyNwaMMsN5+/unKNCsCB/6XJvSc+l3nvaaOabNbMt4wvTEVYj2c1b7mnYgOZ RsNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=2hv3bG7T; 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 g6-v6si21496plj.709.2018.01.18.08.50.25; Thu, 18 Jan 2018 08:50:38 -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; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=2hv3bG7T; 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 S932617AbeARQtK (ORCPT + 99 others); Thu, 18 Jan 2018 11:49:10 -0500 Received: from mail-cys01nam02on0070.outbound.protection.outlook.com ([104.47.37.70]:52635 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932507AbeARQtH (ORCPT ); Thu, 18 Jan 2018 11:49:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Iv+BOoO+GSWD766GsN7B6/Dl2cbueW4cwIedVvzn0t4=; b=2hv3bG7TFJjJmCt4WKQNPsvnwcVp5OwmT6BUQ5qO/EASKaAh7tOsyiVqTEoM9Taqt/zQMhkvVE4BuhP03/oaLbdOdIjeZZI8UlPNqUj50O5cEmB1UQ+N2mEEHFGeftyG3bEi1IUBVmVCxI/OtQbDQSJ6vaCFywjRDrpQJh6KJQE= Received: from CY1PR12CA0081.namprd12.prod.outlook.com (10.163.230.49) by CY4PR12MB1447.namprd12.prod.outlook.com (10.172.71.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.407.7; Thu, 18 Jan 2018 16:49:05 +0000 Received: from CO1NAM03FT027.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::205) by CY1PR12CA0081.outlook.office365.com (2a01:111:e400:c42b::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.428.17 via Frontend Transport; Thu, 18 Jan 2018 16:49:05 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by CO1NAM03FT027.mail.protection.outlook.com (10.152.80.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.345.12 via Frontend Transport; Thu, 18 Jan 2018 16:49:04 +0000 Received: from agrodzovsky-All-Series.amd.com (10.34.1.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server id 14.3.361.1; Thu, 18 Jan 2018 10:49:02 -0600 From: Andrey Grodzovsky To: , , , CC: , Andrey Grodzovsky Subject: [PATCH 2/4] oom: take per file badness into account Date: Thu, 18 Jan 2018 11:47:50 -0500 Message-ID: <1516294072-17841-3-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516294072-17841-1-git-send-email-andrey.grodzovsky@amd.com> References: <1516294072-17841-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(39860400002)(396003)(376002)(346002)(39380400002)(2980300002)(428003)(189003)(199004)(110136005)(54906003)(8936002)(105586002)(2906002)(104016004)(81166006)(4326008)(53936002)(81156014)(106466001)(8676002)(16586007)(6666003)(51416003)(2950100002)(76176011)(356003)(316002)(7696005)(53416004)(97736004)(26005)(36756003)(77096007)(5660300001)(50226002)(72206003)(68736007)(48376002)(305945005)(50466002)(2201001)(47776003)(478600001)(86362001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1447;H:SATLEXCHOV02.amd.com;FPR:;SPF:None;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;CO1NAM03FT027;1:VyPpZz6ytQnhDYHQz0+0+Vf6otJgO1rqWaw88xmJNUeWHLcfurJaAElIM4j33sVDhrSQC+CS4rnVzUymfneCPbP7GWcBaSOuQxlphWWHC6oogjvDae113swuTHjEcywW X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d5e2e28e-4bc6-4d7f-95db-08d55e9362a6 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(2017052603307)(7153060);SRVR:CY4PR12MB1447; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1447;3:1pfviwvWhca743o9S/t9UfhUEUVYV7X85SL/3uafwLjVtFzQ7J1r/YJceGUwVBZrUosfPUtPI5YDMv3g0nFzmFPDYRq1aiXAkPHJ20CvP4n4lG1LP1hIv72B21CWHPBXWtiN7XRsk2uJMijgEUd2gSuH4865cUZ/DV35sqANVMTNUORRdUf3fOfzUBjwOTmViF/JYv+FhUcyLTiGJU5JZotA4HsYYQ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azocqHL3lCSUdLAoaxpp7QGEni9IW1WCTcIUrE39FfNZdIGEVJG8se7k7+6wyParrqqyUOwSqYko6czEjoiyAWOn1lhR3Yxenp8eZp4iUY+P6n0EftsZnArOKu5OdnKeMs081q5LzZf3CFhseDteJ1O05UDRj15WEp7FUwXP8JKEujUNtw553Jyaf9NGydeJvH/17AWrCxfjGe3hQQCv3YUS9kIlGaQZLUjqLs4y6e X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(8121501046)(5005006)(10201501046)(3231023)(2400064)(944501161)(3002001)(93006095)(93003095)(6055026)(6041268)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:CY4PR12MB1447;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:CY4PR12MB1447; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1447;4:WUIC65TzDz6e/z6YsoY+0VpmL068gjuLrF7mwD0AJsrlnTHXuDEP27Bo8vNNmjP8fHUrRqnn7eRT8Mm2VBC5zCvKiZpeRoS1O5uD1Knd2glA2jLx1Dkdg+A+7nJCDAKZ+c169k3pSaxSJkCy4s7a+ftHFiAuKY2GWiezJZuhKPjGt7siAVjQknN+blBIIQFbbHNx/CluxTG8fmi8olNBQMugKZhfDoelj7KVaqvkXQsGbG1ORghSfGwNfnXVuyu/LuI4D5G/YVP3WxGZYYsc/bbYZHgJFK6NIxSC9UEsUoSi92xqim+LaqtZypLHYlBl X-Forefront-PRVS: 05568D1FF7 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR12MB1447;23:OOyGliPsok45YgSBA+gYSf8vZXYyBH+Qwc4NT2ptp?= =?us-ascii?Q?zr7IqmEDFGRLhpAaRLNkUtY/38ndlkSRcb8MRT7r9nVzjKRJeDntBKsE5UyQ?=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SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1447;20:US6S/GR/TWyckluOcsgbfVNHRY4NiXcJ8TSCGRw/24R5nvhi1UrKOIWp34WjFxDXmwHZQnj60U3FYWiLGrY8qU+Ev1soQR49J9svQ3PSTXoZO02a1ROCGJH7EkIW+MSBAmbP0jlu9CHf5afm7ONoWlgyJo7vj6t06KgZ+s2xwHb+jE83UPL3AFA1zgXJOI0gVvps8ynhD6zjU7v7vpbvAyN+SULQUjyHmbCZhW1+EyLyYjKhzSjMwZae6oCpc9XG X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2018 16:49:04.9206 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d5e2e28e-4bc6-4d7f-95db-08d55e9362a6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1447 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Try to make better decisions which process to kill based on per file OOM badness Signed-off-by: Andrey Grodzovsky --- mm/oom_kill.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 29f8555..825ed52 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -49,6 +49,8 @@ #define CREATE_TRACE_POINTS #include +#include + int sysctl_panic_on_oom; int sysctl_oom_kill_allocating_task; int sysctl_oom_dump_tasks = 1; @@ -182,6 +184,21 @@ static bool is_dump_unreclaim_slabs(void) } /** + * oom_file_badness - add per file badness + * @points: pointer to summed up badness points + * @file: tasks open file + * @n: file descriptor id (unused) + */ +static int oom_file_badness(const void *points, struct file *file, unsigned n) +{ + if (file->f_op->oom_file_badness) + *((long *)points) += file->f_op->oom_file_badness(file); + + return 0; +} + + +/** * oom_badness - heuristic function to determine which candidate task to kill * @p: task struct of which task we should calculate * @totalpages: total present RAM allowed for page allocation @@ -222,6 +239,12 @@ unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg, */ points = get_mm_rss(p->mm) + get_mm_counter(p->mm, MM_SWAPENTS) + mm_pgtables_bytes(p->mm) / PAGE_SIZE; + + /* + * Add how much memory a task uses in opened files, e.g. device drivers. + */ + iterate_fd(p->files, 0, oom_file_badness, &points); + task_unlock(p); /* -- 2.7.4