drm/ttm: swap consecutive allocated cached pages
Subsystems (3)
PATCH 1/2 drm/ttm: swap consecutive allocated cached pages
When we detect consecutive allocation of pages swap them to avoid accidentally freeing them as huge page.
--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/ttm/ttm_page_alloc.c +8 -0
@@ -921,6 +921,14 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,return -ENOMEM ; } +/* Swap the pages if we detect consecutive order */ +if (i && pages[i -1 ] == p -1 ) { +struct page *tmp = p; + + p = pages[i -1 ]; + pages[i -1 ] = tmp; + } + pages[i++] = p; --npages; }
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): 20171204114224.27712-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
PATCH 2/2 drm/ttm: swap consecutive allocated pooled pages
When we detect consecutive allocation of pages swap them to avoid accidentally freeing them as huge page.
--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_page_alloc.c +9 -1
@@ -957,8 +957,16 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags, r =ttm_page_pool_get_pages (pool, &plist, flags, cstate, npages - count,0 ); -list_for_each_entry (p, &plist, lru) +list_for_each_entry (p, &plist, lru) { +/* Swap the pages if we detect consecutive order */ +if (count && pages[count -1 ] == p -1 ) { +struct page *tmp = p; + + p = pages[count -1 ]; + pages[count -1 ] = tmp; + } pages[count++] = p; + }if (r) {/* If there is any pages in the list put them back to
Signature · 6 lines
2.11.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 14 lines · Christian König
When we detect consecutive allocation of pages swap them to avoid accidentally freeing them as huge page.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/gpu/drm/ttm/ttm_page_alloc.c +0
-0@@ -921,6 +921,14 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,return -ENOMEM ;
drivers/gpu/drm/ttm/ttm_page_alloc.c static int ttm_get_pages(struct page **pages, unsigned npages, int flags, · line 931
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_page_alloc.c +8
-0} +/* Swap the pages if we detect consecutive order */ +if (i && pages[i -1 ] == p -1 ) { +struct page *tmp = p; + + p = pages[i -1 ]; + pages[i -1 ] = tmp; + } +
Should be (something like):
if (i && pages[i - 1] == p - 1) swap(pages[i - 1], p);
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 04.12.2017 um 12:51 schrieb Michel Dänzer:
Quoted 27 lines · Christian König
Quoted 14 lines
When we detect consecutive allocation of pages swap them to avoid accidentally freeing them as huge page.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/gpu/drm/ttm/ttm_page_alloc.c +0
-0@@ -921,6 +921,14 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,return -ENOMEM ;drivers/gpu/drm/ttm/ttm_page_alloc.c static int ttm_get_pages(struct page **pages, unsigned npages, int flags, · line 931
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_page_alloc.c +8
-0} +/* Swap the pages if we detect consecutive order */ +if (i && pages[i -1 ] == p -1 ) { +struct page *tmp = p; + + p = pages[i -1 ]; + pages[i -1 ] = tmp; + } +Should be (something like):
Quoted 2 lines
if (i && pages[i - 1] == p - 1) swap(pages[i - 1], p);
Good point, updates patches send out a few seconds ago.
Please review,
Christian.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel