From patchwork Wed Aug 13 03:52:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 4715901 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DF27F9F375 for ; Wed, 13 Aug 2014 03:52:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 62861201BF for ; Wed, 13 Aug 2014 03:52:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 726C6201C0 for ; Wed, 13 Aug 2014 03:52:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2254E6E240; Tue, 12 Aug 2014 20:52:06 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qg0-f52.google.com (mail-qg0-f52.google.com [209.85.192.52]) by gabe.freedesktop.org (Postfix) with ESMTP id 604676E213 for ; Tue, 12 Aug 2014 20:52:05 -0700 (PDT) Received: by mail-qg0-f52.google.com with SMTP id f51so10492564qge.11 for ; Tue, 12 Aug 2014 20:52:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=EBnanDgxPrTzgxpO4T+l0nS5/q4UuR4Lt0JE4SikEw8=; b=M4JezM7XOS8ea21+lUizWTS8GbJBqHDIXgCD623P45+VanCBmIlPHsYjYUq/B1+b8t C0G0b5fkdVYAhoEHUKXl5kYaxQxaZOx3arIp8RGUkLPocf17vxA182TkVsWebdRJyP+g Jx7SYoMAaQAWPpIy8U52uxLYaSpynJwviP3HA7+18wKFj3YTQE9elIjR72+DyFANU0hM yezdQQEkZJmacRtL1WJZJsTdZJeGG9eXWXtwt5ett9W7zii/eyDk3hAB3gyQkMCrrEKg +VUt/rAJ3uz6KKLnpwyrazlKCB2a+Z7t+R1soEHZ7OC7XLFlDoyBXM3KYFs4VJ7mD/Xj umjg== X-Received: by 10.224.137.65 with SMTP id v1mr2507191qat.53.1407901924932; Tue, 12 Aug 2014 20:52:04 -0700 (PDT) Received: from unused-10-19-63-219.boston.devel.redhat.com (c-66-31-44-77.hsd1.ma.comcast.net. [66.31.44.77]) by mx.google.com with ESMTPSA id b5sm1320673qag.17.2014.08.12.20.52.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Aug 2014 20:52:04 -0700 (PDT) From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] drm/ttm: set sensible pool size limit. Date: Tue, 12 Aug 2014 23:52:04 -0400 Message-Id: <1407901926-24516-2-git-send-email-j.glisse@gmail.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1407901926-24516-1-git-send-email-j.glisse@gmail.com> References: <1407901926-24516-1-git-send-email-j.glisse@gmail.com> MIME-Version: 1.0 Cc: =?UTF-8?q?Michel=20D=C3=A4nzer?= , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Konrad Rzeszutek Wilk , Thomas Hellstrom X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 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-Status: No, score=-4.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jérôme Glisse Due to bug in code it appear that some of the pool where never properly use and always empty. Before fixing that bug this patch set sensible limit on pool size. The magic 64MB number was nominated. This is obviously a some what arbitrary number but the intend of ttm pool is to minimize page alloc cost especialy when allocating page that will be mark to be excluded from cpu cache mecanisms. We assume that mostly small buffer that are constantly allocated/deallocated might suffer from core memory allocation overhead as well as cache status change. This are the assumptions behind the 64MB value. This obviously need some serious testing including monitoring pool size. Signed-off-by: Jérôme Glisse Cc: Mario Kleiner Cc: Michel Dänzer Cc: Thomas Hellstrom Cc: Konrad Rzeszutek Wilk --- drivers/gpu/drm/ttm/ttm_memory.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c index dbc2def..73b2ded 100644 --- a/drivers/gpu/drm/ttm/ttm_memory.c +++ b/drivers/gpu/drm/ttm/ttm_memory.c @@ -38,6 +38,16 @@ #include #define TTM_MEMORY_ALLOC_RETRIES 4 +/* Have a maximum of 64MB of memory inside the pool. + * + * This is obviously a some what arbitrary number but the intend of ttm pool + * is to minimize page alloc cost especialy when allocating page that will be + * mark to be excluded from cpu cache mecanisms. We assume that mostly small + * buffer that are constantly allocated/deallocated might suffer from core + * memory allocation overhead as well as cache status change. This are the + * assumptions behind the 64MB value. + */ +#define MAX_POOL_SIZE (64UL << 20UL) struct ttm_mem_zone { struct kobject kobj; @@ -363,6 +373,7 @@ int ttm_mem_global_init(struct ttm_mem_global *glob) int ret; int i; struct ttm_mem_zone *zone; + unsigned long max_pool_size; spin_lock_init(&glob->lock); glob->swap_queue = create_singlethread_workqueue("ttm_swap"); @@ -393,8 +404,9 @@ int ttm_mem_global_init(struct ttm_mem_global *glob) pr_info("Zone %7s: Available graphics memory: %llu kiB\n", zone->name, (unsigned long long)zone->max_mem >> 10); } - ttm_page_alloc_init(glob, glob->zone_kernel->max_mem/(2*PAGE_SIZE)); - ttm_dma_page_alloc_init(glob, glob->zone_kernel->max_mem/(2*PAGE_SIZE)); + max_pool_size = min(glob->zone_kernel->max_mem >> 3UL, MAX_POOL_SIZE); + ttm_page_alloc_init(glob, max_pool_size / (2 * PAGE_SIZE)); + ttm_dma_page_alloc_init(glob, max_pool_size / (2 * PAGE_SIZE)); return 0; out_no_zone: ttm_mem_global_release(glob);