From patchwork Wed Jul 8 18:16:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 6750501 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 D94FF9F2F0 for ; Wed, 8 Jul 2015 18:16:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0A72920613 for ; Wed, 8 Jul 2015 18:16:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 17CE72060F for ; Wed, 8 Jul 2015 18:16:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5730B6EBBF; Wed, 8 Jul 2015 11:16:54 -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 ESMTPS id E08686EBC2 for ; Wed, 8 Jul 2015 11:16:52 -0700 (PDT) Received: by qgef3 with SMTP id f3so54148737qge.0 for ; Wed, 08 Jul 2015 11:16:52 -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=dHtluqRAFth+jM9GrCXpTHz/CXc4PkGRlS1L7M1U4MQ=; b=pcJ9vT6zLH5nh60VqcZknmWxqSd3BRbgvkHzbuJ7Mdj22g5iPE9wsflh4XBnoyDAGg rDYRTUKg6Y6UZe71DfCbOOP5udg2mFHP1xRGnw+zvO9eAd5oVFkNdUUciJhxgY+m35Ud rxJtWsVlOecw/HQrxSwTOmHBB7QltMZxF9FlqIN9Srt9LsJ5h9YQyCK8JUAvj7Uwzpwv yt0DvhqHKtm0UFAURPbkNceawidZ6eZifgwybN+2orOEJhM1QyCFPwHKSVpshc0y8zeP B+juQRiXPS+cjsg93nBer94ONQW94d/8PTq9JjkkgBh6uyLf7xYOAMfQ8i9GWdpdBBQD aNWA== X-Received: by 10.140.23.5 with SMTP id 5mr18004475qgo.106.1436379412137; Wed, 08 Jul 2015 11:16:52 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id g33sm1903400qgg.4.2015.07.08.11.16.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jul 2015 11:16:51 -0700 (PDT) From: j.glisse@gmail.com To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/ttm: improve uncached page deallocation. Date: Wed, 8 Jul 2015 14:16:37 -0400 Message-Id: <1436379397-7897-2-git-send-email-j.glisse@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1436379397-7897-1-git-send-email-j.glisse@gmail.com> References: <1436379397-7897-1-git-send-email-j.glisse@gmail.com> MIME-Version: 1.0 Cc: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Konrad Rzeszutek Wilk , =?UTF-8?q?Michel=20D=C3=A4nzer?= , 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.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 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 Cc: Michel Dänzer Cc: Thomas Hellstrom Cc: Konrad Rzeszutek Wilk Reviewed-by: Konrad Rzeszutek Wilk --- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c index 0194a93..8028dd6 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c @@ -953,7 +953,12 @@ 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; } spin_unlock_irqrestore(&pool->lock, irq_flags);