From patchwork Fri Sep 4 12:53:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 7122051 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 32AAA9F32B for ; Fri, 4 Sep 2015 12:55:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 695A02089C for ; Fri, 4 Sep 2015 12:55:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4021C20896 for ; Fri, 4 Sep 2015 12:55:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 676756EBC6; Fri, 4 Sep 2015 05:55:26 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from pegasos-out.vodafone.de (pegasos-out.vodafone.de [80.84.1.38]) by gabe.freedesktop.org (Postfix) with ESMTP id 53C476EBC6 for ; Fri, 4 Sep 2015 05:55:23 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by pegasos-out.vodafone.de (Rohrpostix1 Daemon) with ESMTP id B4E87260754; Fri, 4 Sep 2015 14:55:22 +0200 (CEST) X-Virus-Scanned: amavisd-new at vodafone.de X-Spam-Score: -0.054 X-Spam-Level: X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Authentication-Results: rohrpostix1.prod.vfnet.de (amavisd-new); dkim=pass header.i=@vodafone.de Received: from pegasos-out.vodafone.de ([127.0.0.1]) by localhost (rohrpostix1.prod.vfnet.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xCqDy5bTac5S; Fri, 4 Sep 2015 14:55:21 +0200 (CEST) Received: from smtp-05.vodafone.de (smtp-05.vodafone.de [10.215.254.32]) by pegasos-out.vodafone.de (Rohrpostix1 Daemon) with ESMTP id 2D7EB26140A; Fri, 4 Sep 2015 14:55:21 +0200 (CEST) X-DKIM: OpenDKIM Filter v2.6.8 pegasos-out.vodafone.de 2D7EB26140A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafone.de; s=mail; t=1441371321; bh=FyfRtq6EQP5c41JfYrsbtrmihDRXGSkXgP+pwm6p+cE=; h=From:To:Subject:Date:In-Reply-To:References; b=q43euDMlu5kw78OEgupxdjRgw4IasNmiaD4S4EXUUlDy9+grI5uAZPFgxr0l3G2cL hxXdsqpVraoqiaeoxU+Jyc1egTgvwSRSLZl7FflnbjLdFsdlr/VWi8lLyh+ysUbsuP emz/ewGhGi6yK71hAywS+oRn/JkQGWNeFstpMZdg= X-Virus-Scanned: amavisd-new at vodafone.de Received: from smtp-05.vodafone.de ([127.0.0.1]) by localhost (xsmail-dmz1.prod.vfnet.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g4vTx1Ad9pLP; Fri, 4 Sep 2015 14:55:15 +0200 (CEST) From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: lkml@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 4/4] staging: android: lowmemorykiller: take per file badness into account Date: Fri, 4 Sep 2015 14:53:33 +0200 Message-Id: <1441371213-3543-5-git-send-email-deathsimple@vodafone.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441371213-3543-1-git-send-email-deathsimple@vodafone.de> References: <1441371213-3543-1-git-send-email-deathsimple@vodafone.de> MIME-Version: 1.0 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-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christian König Try to make better decisions which process to kill based on per file OOM badness. Signed-off-by: Christian König Reviewed-by: Alex Deucher --- drivers/staging/android/lowmemorykiller.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c index feafa17..baefe8f 100644 --- a/drivers/staging/android/lowmemorykiller.c +++ b/drivers/staging/android/lowmemorykiller.c @@ -41,6 +41,7 @@ #include #include #include +#include static uint32_t lowmem_debug_level = 1; static short lowmem_adj[6] = { @@ -75,6 +76,13 @@ static unsigned long lowmem_count(struct shrinker *s, global_page_state(NR_INACTIVE_FILE); } +static int lowmem_file_badness(const void *tasksize, struct file *file, unsigned n) +{ + *((int*)tasksize) += atomic_long_read(&file->f_oom_badness); + + return 0; +} + static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc) { struct task_struct *tsk; @@ -139,6 +147,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc) continue; } tasksize = get_mm_rss(p->mm); + iterate_fd(p->files, 0, lowmem_file_badness, &tasksize); task_unlock(p); if (tasksize <= 0) continue;