From patchwork Thu Jan 18 16:47:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 10173707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AD5896055D for ; Thu, 18 Jan 2018 16:49:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EA2B20134 for ; Thu, 18 Jan 2018 16:49:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92E4F20572; Thu, 18 Jan 2018 16:49:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9006E20416 for ; Thu, 18 Jan 2018 16:49:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0833D6E5B4; Thu, 18 Jan 2018 16:49:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0046.outbound.protection.outlook.com [104.47.33.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id C2A5B6E5B4; Thu, 18 Jan 2018 16:49:10 +0000 (UTC) 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: , , , 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 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/t9Uf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LN7dUQyHUst0tsRPYP8ud0zcT5LE1mSajDem66l980ISFCiE3ahnWQGX6nzltfsjvL+reIVaWTkEeQjJShcIPGyEd9zdr7aPQv23ETyUEl7+enDtkZn4ipllRSuBzmE7ya+MNTfOZpgaTXEfA/9fvSSho02LtzSfzWE7Esc7kn0e65uvU88VQR5HpqzBO5DfDwUYB/sxRhbTapvIazocqHL3lCSUdLAoaxpp7QGEni9IW1WCTcIUrE39FfNZdIGEVJG8se7k7+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?= =?us-ascii?Q?0uX36zqa/jWXHUj0GxFPiiiiti/c6V/ShghaXSpFfRieYoLV0F8/m0AJUU93?= =?us-ascii?Q?mAfgC+mQfz+enaH3PgCgkGvfPvGQzmQdXCRkTtp0r07chs2UOw8a6TIoB4j/?= =?us-ascii?Q?qhd1hGk+Zu6LXmvM0xmpVNAAbkUqqjQ/bwPysU5Z0seSVmRxcPPzS1PCM6t7?= =?us-ascii?Q?ySIruuvffo49t4L+93SwmcRbSw6vil4IcUhy097l2OXoWnT5oCMtupXj85A5?= =?us-ascii?Q?AJZ70IveKsIWcUJRkUJ+3m3y/2dVBpmiFmiYHcnUDmfV+tKytMZhsiqBcQvN?= =?us-ascii?Q?G+BVVXvC3c69vK1q9GmwlMeBX7nx6IQUp2RmXXlHHQwuGchC7oIdL3K9oO7W?= =?us-ascii?Q?VweP/B2aclaUriay1Srvk4/vmWZ2bWlFbK8vrYluO2ZxtKaVwCTuq9LWhKgi?= =?us-ascii?Q?fUCUje8GSEtHm4eNJC5N0scdrgLLXvwj2zylrzQcpan+Myp18QgDfpeU7h6l?= =?us-ascii?Q?i8vusy1kLHRG7eRMKmjiBXX6saDe4hvz+UPfAoqP9V1bCwco6lSzW7mpp1ed?= =?us-ascii?Q?JiCilaiaaKkc9vGNR3+mWSLfLUXi9USd9gLDEQtPNfx8g74WZeOIh4q9cQ3c?= =?us-ascii?Q?zbzzFVuZfb8AdjtxWVfic95GyDg515rNCLYA4cbymmEycQhOdt33JCOh3Y4e?= =?us-ascii?Q?VrqK6bhG/pPULh4V75EA1iZoT29rT8QX9zwXuGFaWYyFIk/qjoPhosvLb9t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7oRAAiyTxs3g0c9msSQFUStmhHcJ2M/lt0zVPvLcjh97aJHtlvKiNo7ZcDB89NSE1y85BqpOCv+mgQCRG2GIZeW8uIuSaupsHNcncOKrktd/GUXrZe9rORa11bDH+LFO/U7ZuqVJFeD74NNk5N++1XtetUEby8JPa+nOUdTwateSW8XTih/Q4+98N2HvB6hVyeuAeolzY2ifnWEKVKttk 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 Cc: Christian.Koenig@amd.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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); /*