drm/ttm: swap consecutive allocated cached pages v2
Subsystems (3)
PATCH 1/2 drm/ttm: swap consecutive allocated cached pages v2
When we detect consecutive allocation of pages swap them to avoid accidentally freeing them as huge page.
v2: use swap
--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/ttm/ttm_page_alloc.c +4 -0
@@ -921,6 +921,10 @@ 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 ) +swap (p, pages[i -1 ]); + 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): 20171204121233.9164-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
PATCH 2/2 drm/ttm: swap consecutive allocated pooled pages v2
When we detect consecutive allocation of pages swap them to avoid accidentally freeing them as huge page.
v2: use swap
--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_page_alloc.c +5 -1
@@ -953,8 +953,12 @@ 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 ) +swap (p, pages[count -1 ]); 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
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Monday, December 04, 2017 8:13 PM
To: [email protected]; [email protected]; He, Roger <[email protected]>; [email protected]
Subject: [PATCH 1/2] drm/ttm: swap consecutive allocated cached pages v2
When we detect consecutive allocation of pages swap them to avoid accidentally freeing them as huge page.
v2: use swap
--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/ttm/ttm_page_alloc.c +0 -0
@@ -921,6 +921,10 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,return -ENOMEM ; }
How about add first index as below?
first = i; //init first here
while (npages) {
p = alloc_page(gfp_flags);
if (!p) {
pr_debug("Unable to allocate page\n");
return -ENOMEM;
}
/* Swap the pages if we detect consecutive order */
if (i > first && pages[i - 1] == p - 1) //change to (i > first), because I worry if npages is 513, the first regular page is exactly consecutive with last page of huge page. Then swap them is not what I want here.
swap(p, pages[i - 1]);
pages[i++] = p;
--npages;
} pages[i++] = p;
--npages;
}
--
2.11.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx