mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: linux-kernel@vger.kernel.org, j.glisse@gmail.com,
	dri-devel@lists.freedesktop.org
Cc: bskeggs@redhat.com, thellstrom@vmware.com,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH 3/3] drm/ttm/dma: Optimize when free-ing the recycled page pool.
Date: Mon, 12 Dec 2011 15:09:29 -0500	[thread overview]
Message-ID: <1323720569-15435-4-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1323720569-15435-1-git-send-email-konrad.wilk@oracle.com>

We would free the page pool - even if it was for cached pages
(which are deleted from the pool - so there are no free pages).

Also we also missed the opportunity to batch the amount of pages
to free (similar to how ttm_page_alloc.c does it). This reintroduces
the code that was lost during rebasing.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index e57aa24..156ddcd 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -949,7 +949,7 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)
 	struct dma_page *d_page, *next;
 	enum pool_type type;
 	bool is_cached = false;
-	unsigned count = 0, i, npages;
+	unsigned count = 0, i, npages = 0;
 	unsigned long irq_flags;
 
 	type = ttm_to_type(ttm->page_flags, ttm->caching_state);
@@ -971,13 +971,16 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)
 	pool->npages_in_use -= count;
 	if (is_cached) {
 		pool->nfrees += count;
-		npages = count;
 	} else {
 		pool->npages_free += count;
 		list_splice(&ttm_dma->pages_list, &pool->free_list);
 		npages = count;
 		if (pool->npages_free > _manager->options.max_size) {
 			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);
@@ -1001,7 +1004,7 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)
 		ttm_dma->dma_address[i] = 0;
 	}
 
-	/* shrink pool if necessary */
+	/* shrink pool if necessary (only on !is_cached pools)*/
 	if (npages)
 		ttm_dma_page_pool_free(pool, npages);
 	ttm->state = tt_unpopulated;
-- 
1.7.7.3


  parent reply	other threads:[~2011-12-12 20:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-12 20:09 [PATCH] fixes to drm-next - TTM DMA code (v1) Konrad Rzeszutek Wilk
2011-12-12 20:09 ` [PATCH 1/3] drm/ttm/dma: Only call set_pages_array_wb when the page is not in WB pool Konrad Rzeszutek Wilk
2011-12-12 20:09 ` [PATCH 2/3] drm/ttm/dma: Fix accounting error when calling ttm_mem_global_free_page Konrad Rzeszutek Wilk
2011-12-21 15:17   ` Jerome Glisse
2011-12-21 15:30     ` Konrad Rzeszutek Wilk
2011-12-12 20:09 ` Konrad Rzeszutek Wilk [this message]
2011-12-21 15:22   ` [PATCH 3/3] drm/ttm/dma: Optimize when free-ing the recycled page pool Jerome Glisse
2011-12-13 16:07 ` [PATCH] fixes to drm-next - TTM DMA code (v1) Jerome Glisse
2011-12-13 16:23   ` Thomas Hellstrom
2011-12-13 16:40     ` Konrad Rzeszutek Wilk
2011-12-19 19:51       ` Thomas Hellstrom
2011-12-20 17:35         ` Konrad Rzeszutek Wilk
2012-01-05 19:37       ` Jerome Glisse
2011-12-13 22:09     ` James Simmons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1323720569-15435-4-git-send-email-konrad.wilk@oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=bskeggs@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=j.glisse@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thellstrom@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®