Skip to contentSkip to conversation

drm/ttm: fix the fix for huge compound pages

PATCH In review Christian König 3 participants 3 messages Oct 12, 2017 – Oct 13, 2017 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/ttm: fix the fix for huge compound pages

From: Christian König <[email protected]>

We don't use compound pages at the moment. Take this into account when freeing them.

---
 drivers/gpu/drm/ttm/ttm_page_alloc.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
drivers/gpu/drm/ttm/ttm_page_alloc.c +16 -5
index b6f16e7ffff3..c3be50f41461 100644
@@ -731,22 +731,33 @@ static void ttm_put_pages(struct page **pages, unsigned npages, int flags,
 		/* No pool for this memory type so free the pages */
 		i = 0;
 		while (i < npages) {
-			unsigned order;
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+			struct page *p = pages[i];
+#endif
+			unsigned order = 0, j;
 
 			if (!pages[i]) {
 				++i;
 				continue;
 			}
 
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+			for (j = 0; j < HPAGE_PMD_NR; ++j)
+				if (p++ != pages[i + j])
+				    break;
+
+			if (j == HPAGE_PMD_NR)
+				order = HPAGE_PMD_ORDER;
+#endif
+
 			if (page_count(pages[i]) != 1)
 				pr_err("Erroneous page count. Leaking pages.\n");
-			order = compound_order(pages[i]);
 			__free_pages(pages[i], order);
 
-			order = 1 << order;
-			while (order) {
+			j = 1 << order;
+			while (j) {
 				pages[i++] = NULL;
-				--order;
+				--j;
 			}
 		}
 		return;
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 20171012173028.1505-1-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#2 lore raw

Michel, gentle ping to you.

With that patch applied piglit seems to be stable on my Tonga (with a bit older Mesa).

Christian.

Am 12.10.2017 um 19:30 schrieb Christian König:

Quoted 43 lines

From: Christian König <[email protected]>

We don't use compound pages at the moment. Take this into account when freeing them.

---
  drivers/gpu/drm/ttm/ttm_page_alloc.c | 21 ++++++++++++++++-----
  1 file changed, 16 insertions(+), 5 deletions(-)
drivers/gpu/drm/ttm/ttm_page_alloc.c +13 -2
index b6f16e7ffff3..c3be50f41461 100644
@@ -731,22 +731,33 @@ static void ttm_put_pages(struct page **pages, unsigned npages, int flags,
  		/* No pool for this memory type so free the pages */
  		i = 0;
  		while (i < npages) {
-			unsigned order;
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+			struct page *p = pages[i];
+#endif
+			unsigned order = 0, j;
 
  			if (!pages[i]) {
  				++i;
  				continue;
  			}
 
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+			for (j = 0; j < HPAGE_PMD_NR; ++j)
+				if (p++ != pages[i + j])
+				    break;
+
+			if (j == HPAGE_PMD_NR)
+				order = HPAGE_PMD_ORDER;
+#endif
+
  			if (page_count(pages[i]) != 1)
  				pr_err("Erroneous page count. Leaking pages.\n");
-			order = compound_order(pages[i]);
  			__free_pages(pages[i], order);
 

drivers/gpu/drm/ttm/ttm_page_alloc.c static void ttm_put_pages(struct page **pages, unsigned npages, int flags, · line 763

Quoted 10 lines
drivers/gpu/drm/ttm/ttm_page_alloc.c +3 -3
-			order = 1 << order;
-			while (order) {
+			j = 1 << order;
+			while (j) {
  				pages[i++] = NULL;
-				--order;
+				--j;
  			}
  		}
  		return;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw
In reply to a message not in the archive
Quoted 44 lines · Christian König

From: Christian König <[email protected]>

We don't use compound pages at the moment. Take this into account when freeing them.

---
 drivers/gpu/drm/ttm/ttm_page_alloc.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
drivers/gpu/drm/ttm/ttm_page_alloc.c +13 -2
index b6f16e7ffff3..c3be50f41461 100644
@@ -731,22 +731,33 @@ static void ttm_put_pages(struct page **pages, unsigned npages, int flags,
 		/* No pool for this memory type so free the pages */
 		i = 0;
 		while (i < npages) {
-			unsigned order;
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+			struct page *p = pages[i];
+#endif
+			unsigned order = 0, j;
 
 			if (!pages[i]) {
 				++i;
 				continue;
 			}
 
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+			for (j = 0; j < HPAGE_PMD_NR; ++j)
+				if (p++ != pages[i + j])
+				    break;
+
+			if (j == HPAGE_PMD_NR)
+				order = HPAGE_PMD_ORDER;
+#endif
+
 			if (page_count(pages[i]) != 1)
 				pr_err("Erroneous page count. Leaking pages.\n");
-			order = compound_order(pages[i]);
 			__free_pages(pages[i], order);
 

drivers/gpu/drm/ttm/ttm_page_alloc.c static void ttm_put_pages(struct page **pages, unsigned npages, int flags, · line 763

Quoted 10 lines
drivers/gpu/drm/ttm/ttm_page_alloc.c +3 -3
-			order = 1 << order;
-			while (order) {
+			j = 1 << order;
+			while (j) {
 				pages[i++] = NULL;
-				--order;
+				--j;
 			}
 		}
 		return;

Maybe the shortlog could be a better summary of what the change does, but I don't have a good suggestion, so either way

Thanks Christian.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx