From patchwork Fri Sep 4 12:53:30 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: 7122031 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 D9C459F32B for ; Fri, 4 Sep 2015 12:55:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 212462089D for ; Fri, 4 Sep 2015 12:55:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 486AC20896 for ; Fri, 4 Sep 2015 12:55:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 473276EBC4; Fri, 4 Sep 2015 05:55:23 -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 BB28B6EBC6 for ; Fri, 4 Sep 2015 05:55:21 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by pegasos-out.vodafone.de (Rohrpostix1 Daemon) with ESMTP id 253942613FE; Fri, 4 Sep 2015 14:55:21 +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 cZ0PcoCO1AQb; Fri, 4 Sep 2015 14:55:19 +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 94415261384; Fri, 4 Sep 2015 14:55:19 +0200 (CEST) X-DKIM: OpenDKIM Filter v2.6.8 pegasos-out.vodafone.de 94415261384 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafone.de; s=mail; t=1441371319; bh=eexhJGB3hTORCU2T8D06/vp2kgAnqzWMzSGlTxuD26I=; h=From:To:Subject:Date:In-Reply-To:References; b=FpCRxtpOREjBSbRU2qsUAa8Xh+J8iE+sYsf9AicnM/fSZ825u8M6/IvrhzJ44F/Pm 6PzEtMPrtp+409FS8rbpl2T7acODJBC3vpl+xcRBeLzX2k9a3U+vW/lEcybKjlJSiz dsxoIxujSqbywNqrJNNgxUUy+hdUZqrgsIQfX7VQ= 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 s6+ehWddJVmu; Fri, 4 Sep 2015 14:55:13 +0200 (CEST) From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: lkml@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 1/4] fs: add per file OOM badness Date: Fri, 4 Sep 2015 14:53:30 +0200 Message-Id: <1441371213-3543-2-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 This allows device drivers to specify an additional badness for the OOM and low memory killer when they allocate memory on behalf of userspace. Signed-off-by: Christian König Reviewed-by: Alex Deucher --- fs/file_table.c | 1 + include/linux/fs.h | 1 + 2 files changed, 2 insertions(+) diff --git a/fs/file_table.c b/fs/file_table.c index 294174d..23b797d 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -136,6 +136,7 @@ struct file *get_empty_filp(void) spin_lock_init(&f->f_lock); mutex_init(&f->f_pos_lock); eventpoll_init_file(f); + atomic_long_set(&f->f_oom_badness, 0); /* f->f_version: 0 */ return f; diff --git a/include/linux/fs.h b/include/linux/fs.h index 35ec87e..5a5d20a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -861,6 +861,7 @@ struct file { struct list_head f_tfile_llink; #endif /* #ifdef CONFIG_EPOLL */ struct address_space *f_mapping; + atomic_long_t f_oom_badness; } __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */ struct file_handle {