dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] *** fix memory leak for HUGE PAGE  ***
@ 2017-11-21  9:32 Roger He
  2017-11-21  9:32 ` [PATCH 1/4] drm/ttm: add page order in page pool Roger He
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Roger He @ 2017-11-21  9:32 UTC (permalink / raw)
  To: amd-gfx, dri-devel; +Cc: Roger He

1. add page order into pool to support gtt huge page
2. add page order support when ttm pages put
3. update memory shrinker with order handling


Roger He (4):
  drm/ttm: add page order in page pool
  drm/ttm: use NUM_PAGES_TO_ALLOC always
  drm/ttm: add page order support in ttm_pages_put
  drm/ttm: free one in huge pool even shrink request less than one
    element

 drivers/gpu/drm/ttm/ttm_page_alloc.c | 80 ++++++++++++++++++++++++++----------
 1 file changed, 59 insertions(+), 21 deletions(-)

-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread
* [PATCH 1/4] drm/ttm: add page order in page pool
@ 2017-11-22  5:36 Roger He
       [not found] ` <1511329016-552-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Roger He @ 2017-11-22  5:36 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Roger He, Christian.Koenig-5C7GfCeVMHo

to indicate page order for each element in the pool

Change-Id: Ic609925ca5d2a5d4ad49d6becf505388ce3624cf
Signed-off-by: Roger He <Hongbo.He@amd.com>
---
 drivers/gpu/drm/ttm/ttm_page_alloc.c | 42 ++++++++++++++++++++++++++----------
 1 file changed, 31 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index 72ea037..0a0c653 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -81,6 +81,7 @@ struct ttm_page_pool {
 	char			*name;
 	unsigned long		nfrees;
 	unsigned long		nrefills;
+	unsigned int		order;
 };
 
 /**
@@ -412,6 +413,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 	struct ttm_page_pool *pool;
 	int shrink_pages = sc->nr_to_scan;
 	unsigned long freed = 0;
+	unsigned int nr_free_pool;
 
 	if (!mutex_trylock(&lock))
 		return SHRINK_STOP;
@@ -421,10 +423,15 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 		unsigned nr_free = shrink_pages;
 		if (shrink_pages == 0)
 			break;
+
 		pool = &_manager->pools[(i + pool_offset)%NUM_POOLS];
 		/* OK to use static buffer since global mutex is held. */
-		shrink_pages = ttm_page_pool_free(pool, nr_free, true);
-		freed += nr_free - shrink_pages;
+		nr_free_pool = (nr_free >> pool->order);
+		if (nr_free_pool == 0)
+			continue;
+
+		shrink_pages = ttm_page_pool_free(pool, nr_free_pool, true);
+		freed += ((nr_free_pool - shrink_pages) << pool->order);
 	}
 	mutex_unlock(&lock);
 	return freed;
@@ -436,9 +443,12 @@ ttm_pool_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
 {
 	unsigned i;
 	unsigned long count = 0;
+	struct ttm_page_pool *pool;
 
-	for (i = 0; i < NUM_POOLS; ++i)
-		count += _manager->pools[i].npages;
+	for (i = 0; i < NUM_POOLS; ++i) {
+		pool = &_manager->pools[i];
+		count += (pool->npages << pool->order);
+	}
 
 	return count;
 }
@@ -932,7 +942,7 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,
 }
 
 static void ttm_page_pool_init_locked(struct ttm_page_pool *pool, gfp_t flags,
-		char *name)
+		char *name, unsigned int order)
 {
 	spin_lock_init(&pool->lock);
 	pool->fill_lock = false;
@@ -940,8 +950,18 @@ static void ttm_page_pool_init_locked(struct ttm_page_pool *pool, gfp_t flags,
 	pool->npages = pool->nfrees = 0;
 	pool->gfp_flags = flags;
 	pool->name = name;
+	pool->order = order;
 }
 
+/**
+ * Actually if TRANSPARENT_HUGEPAGE not enabled, we will not use
+ * wc_pool_huge and uc_pool_huge, so no matter whatever the page
+ * order are for those two pools
+ */
+#ifndef CONFIG_TRANSPARENT_HUGEPAGE
+#define	HPAGE_PMD_ORDER	9
+#endif
+
 int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
 {
 	int ret;
@@ -952,23 +972,23 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
 
 	_manager = kzalloc(sizeof(*_manager), GFP_KERNEL);
 
-	ttm_page_pool_init_locked(&_manager->wc_pool, GFP_HIGHUSER, "wc");
+	ttm_page_pool_init_locked(&_manager->wc_pool, GFP_HIGHUSER, "wc", 0);
 
-	ttm_page_pool_init_locked(&_manager->uc_pool, GFP_HIGHUSER, "uc");
+	ttm_page_pool_init_locked(&_manager->uc_pool, GFP_HIGHUSER, "uc", 0);
 
 	ttm_page_pool_init_locked(&_manager->wc_pool_dma32,
-				  GFP_USER | GFP_DMA32, "wc dma");
+				  GFP_USER | GFP_DMA32, "wc dma", 0);
 
 	ttm_page_pool_init_locked(&_manager->uc_pool_dma32,
-				  GFP_USER | GFP_DMA32, "uc dma");
+				  GFP_USER | GFP_DMA32, "uc dma", 0);
 
 	ttm_page_pool_init_locked(&_manager->wc_pool_huge,
 				  GFP_TRANSHUGE	& ~(__GFP_MOVABLE | __GFP_COMP),
-				  "wc huge");
+				  "wc huge", HPAGE_PMD_ORDER);
 
 	ttm_page_pool_init_locked(&_manager->uc_pool_huge,
 				  GFP_TRANSHUGE	& ~(__GFP_MOVABLE | __GFP_COMP)
-				  , "uc huge");
+				  , "uc huge", HPAGE_PMD_ORDER);
 
 	_manager->options.max_size = max_pages;
 	_manager->options.small = SMALL_ALLOCATION;
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-11-23 21:49 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-21  9:32 [PATCH 0/4] *** fix memory leak for HUGE PAGE *** Roger He
2017-11-21  9:32 ` [PATCH 1/4] drm/ttm: add page order in page pool Roger He
2017-11-21  9:52   ` Christian König
     [not found]   ` <1511256742-5601-2-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-11-23 20:07     ` kbuild test robot
2017-11-23 21:49   ` kbuild test robot
2017-11-21  9:32 ` [PATCH 2/4] drm/ttm: use NUM_PAGES_TO_ALLOC always Roger He
     [not found]   ` <1511256742-5601-3-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-11-21  9:41     ` Christian König
2017-11-21  9:32 ` [PATCH 3/4] drm/ttm: add page order support in ttm_pages_put Roger He
     [not found]   ` <1511256742-5601-4-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-11-21  9:52     ` Christian König
     [not found] ` <1511256742-5601-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-11-21  9:32   ` [PATCH 4/4] drm/ttm: free one in huge pool even shrink request less than one element Roger He
  -- strict thread matches above, loose matches on Subject: below --
2017-11-22  5:36 [PATCH 1/4] drm/ttm: add page order in page pool Roger He
     [not found] ` <1511329016-552-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-11-22  7:47   ` Christian König
     [not found]     ` <6c134a88-2322-b131-d79f-0e5e3b74cd17-5C7GfCeVMHo@public.gmane.org>
2017-11-22  8:10       ` He, Roger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox