From patchwork Thu Jul 9 18:19:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 6758231 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 6EA129F536 for ; Thu, 9 Jul 2015 18:19:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8B18D20647 for ; Thu, 9 Jul 2015 18:19:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 214F920698 for ; Thu, 9 Jul 2015 18:19:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A9DB16ED05; Thu, 9 Jul 2015 11:19:43 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qg0-f49.google.com (mail-qg0-f49.google.com [209.85.192.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id 47BA56ED03 for ; Thu, 9 Jul 2015 11:19:41 -0700 (PDT) Received: by qgep37 with SMTP id p37so26885573qge.1 for ; Thu, 09 Jul 2015 11:19:40 -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=O1L8guhUq9eXz4ind79RX3VmhNXLO8ZN4cYgtq6pKBs=; b=P4Yaask8Uhm13QkRl2Kk3JTxHwk+P7HOrOlAtMKxg+1kh/E4BNJYgBpMJyuWsPC/AG Tz6mDx7OCnjx2lmHLcVSlc3y6ulgBL07VuQuJPTUEUdOrmPpHtuxzg2izJhPEK8LIy6l rCkurqIW8LmcpYl65q+2XzHg8dQaAHMkpm0a2YrzARI8FqS+Z/aiTaWoHgXBPXg7G87H D7aRqGtroR7iqQXQ+vldPSkx0pZc0zajSuQJE/CdmHAOGQm3M7FPoRSQDfyfzFYEMWZl Mc+PomXbGqKkUEr7Us7UoIj9Ej4L/1uEarE3pd8DmqdRva/dCKOHiis/zOzBntsYznTJ NF9g== X-Received: by 10.140.232.16 with SMTP id d16mr28068861qhc.14.1436465980554; Thu, 09 Jul 2015 11:19:40 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id e63sm4098813qga.39.2015.07.09.11.19.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jul 2015 11:19:40 -0700 (PDT) From: j.glisse@gmail.com To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/ttm: improve uncached page deallocation. Date: Thu, 9 Jul 2015 14:19:30 -0400 Message-Id: <1436465970-7262-2-git-send-email-j.glisse@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1436465970-7262-1-git-send-email-j.glisse@gmail.com> References: <1436465970-7262-1-git-send-email-j.glisse@gmail.com> MIME-Version: 1.0 Cc: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Thomas Hellstrom 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-Status: No, score=-4.4 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 Calls to set_memory_wb() incure heavy TLB flush and IPI cost. To minimize those wait until pool grow beyond batch size before draining the pool. Signed-off-by: Jérôme Glisse Reviewed-by: Mario Kleiner Reviewed-and-Tested-by: Michel Dänzer Reviewed-by: Konrad Rzeszutek Wilk Cc: Thomas Hellstrom Reviewed-by: Alex Deucher --- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c index af23080..624d941 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c @@ -963,13 +963,13 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev) } else { pool->npages_free += count; list_splice(&ttm_dma->pages_list, &pool->free_list); - if (pool->npages_free > _manager->options.max_size) { + /* + * Wait to have at at least NUM_PAGES_TO_ALLOC number of pages + * to free in order to minimize calls to set_memory_wb(). + */ + if (pool->npages_free >= (_manager->options.max_size + + NUM_PAGES_TO_ALLOC)) npages = pool->npages_free - _manager->options.max_size; - /* free at least NUM_PAGES_TO_ALLOC number of pages - * to reduce calls to set_memory_wb */ - if (npages < NUM_PAGES_TO_ALLOC) - npages = NUM_PAGES_TO_ALLOC; - } } spin_unlock_irqrestore(&pool->lock, irq_flags);