From patchwork Fri Sep 4 12:53:31 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: 7122041 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B2D0ABEEC1 for ; Fri, 4 Sep 2015 12:55:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D69652089E 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 0027B2089C 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 0377C6EBCD; Fri, 4 Sep 2015 05:55:24 -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 BB0EE6EBC4 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 24125261396; 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 0kk1fq7DCYZ5; 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 8970B26092C; Fri, 4 Sep 2015 14:55:19 +0200 (CEST) X-DKIM: OpenDKIM Filter v2.6.8 pegasos-out.vodafone.de 8970B26092C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafone.de; s=mail; t=1441371319; bh=+Y4V7X+7wsx+BNbDFEmXAivjvxYi5y0IEimjkuHzFe8=; h=From:To:Subject:Date:In-Reply-To:References; b=kP4SLJLzZDVlwCvXcJbkfnkenacVgy6hdopV6YJdlyMWj712iS+BeekrRK92+GBon k2IbiPGeq/04uq91sV0mdw13uLolbGFcI29wpTqKJZMX3RQZcnIK/IBKxW1UbemP7g ddsaq7oe3YBPqlmfl2/0GJuiPvFJiks2qx1AVrSE= 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 sZWkAtig6QUJ; 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 2/4] drm/gem: adjust per file OOM badness on handling buffers Date: Fri, 4 Sep 2015 14:53:31 +0200 Message-Id: <1441371213-3543-3-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 Large amounts of VRAM are usually not CPU accessible, so they are not mapped into the processes address space. But since the device drivers usually support swapping buffers from VRAM to system memory we can still run into an out of memory situation when userspace starts to allocate to much. This patch gives the OOM and lower memory killer another hint which process is holding how many resources. Signed-off-by: Christian König Reviewed-by: Alex Deucher --- drivers/gpu/drm/drm_gem.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 16a1647..17d14c1 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -282,6 +282,9 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle) if (dev->driver->gem_close_object) dev->driver->gem_close_object(obj, filp); + + atomic_long_sub(obj->size >> PAGE_SHIFT, &filp->filp->f_oom_badness); + drm_gem_object_handle_unreference_unlocked(obj); return 0; @@ -358,6 +361,9 @@ drm_gem_handle_create_tail(struct drm_file *file_priv, } } + atomic_long_add(obj->size >> PAGE_SHIFT, + &file_priv->filp->f_oom_badness); + return 0; } @@ -717,6 +723,9 @@ drm_gem_object_release_handle(int id, void *ptr, void *data) if (dev->driver->gem_close_object) dev->driver->gem_close_object(obj, file_priv); + atomic_long_sub(obj->size >> PAGE_SHIFT, + &file_priv->filp->f_oom_badness); + drm_gem_object_handle_unreference_unlocked(obj); return 0;