drm/ttm: swap consecutive allocated pooled pages v4
Subsystems (3)
PATCH 1/1 drm/ttm: swap consecutive allocated pooled pages v4
When we detect consecutive allocation of pages swap them to avoid accidentally freeing them as huge page.
v2: use swap
v3: check if it's really the first allocated page
v4: don't touch the loop variable
--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_page_alloc.c +9 -2
@@ -958,8 +958,15 @@ 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) - pages[count++] = p; + first = count; +list_for_each_entry (p, &plist, lru) { +struct page *tmp = p; + +/* Swap the pages if we detect consecutive order */ +if (count > first && pages[count -1 ] == tmp -1 ) +swap (tmp, pages[count -1 ]); + pages[count++] = tmp; + }if (r) {/* If there is any pages in the list put them back to
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): 20171205125452.7546-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
Michel Dänzer
Reviewed-byQuoted 25 lines · Christian König
When we detect consecutive allocation of pages swap them to avoid accidentally freeing them as huge page.
v2: use swap
v3: check if it's really the first allocated page
v4: don't touch the loop variableSigned-off-by Christian König <[email protected]>--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/gpu/drm/ttm/ttm_page_alloc.c +2
-2@@ -958,8 +958,15 @@ 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) - pages[count++] = p; + first = count; +list_for_each_entry (p, &plist, lru) {
drivers/gpu/drm/ttm/ttm_page_alloc.c static int ttm_get_pages(struct page **pages, unsigned npages, int flags, · line 972
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_page_alloc.c +7
-0+struct page *tmp = p; + +/* Swap the pages if we detect consecutive order */ +if (count > first && pages[count -1 ] == tmp -1 ) +swap (tmp, pages[count -1 ]); + pages[count++] = tmp; + }if (r) {/* If there is any pages in the list put them back to
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
Dieter Nützel
Tested-byDieter
Am 05.12.2017 13:54, schrieb Christian König:
Quoted 35 lines
When we detect consecutive allocation of pages swap them to avoid accidentally freeing them as huge page.
v2: use swap
v3: check if it's really the first allocated page
v4: don't touch the loop variableSigned-off-by Christian König <[email protected]>--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/gpu/drm/ttm/ttm_page_alloc.c +9
-2@@ -958,8 +958,15 @@ 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) - pages[count++] = p; + first = count; +list_for_each_entry (p, &plist, lru) { +struct page *tmp = p; + +/* Swap the pages if we detect consecutive order */ +if (count > first && pages[count -1 ] == tmp -1 ) +swap (tmp, pages[count -1 ]); + pages[count++] = tmp; + }if (r) {
Quoted 1 line
/* If there is any pages in the list put them back to
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Thanks
Roger(Hongbo.He)
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Tuesday, December 05, 2017 8:55 PM
To: [email protected]; [email protected]; He, Roger <[email protected]>
Subject: [PATCH] drm/ttm: swap consecutive allocated pooled pages v4
When we detect consecutive allocation of pages swap them to avoid accidentally freeing them as huge page.
v2: use swap
v3: check if it's really the first allocated page
v4: don't touch the loop variable
--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_page_alloc.c +9 -2
@@ -958,8 +958,15 @@ 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) - pages[count++] = p; + first = count; +list_for_each_entry (p, &plist, lru) { +struct page *tmp = p; + +/* Swap the pages if we detect consecutive order */ +if (count > first && pages[count -1 ] == tmp -1 ) +swap (tmp, pages[count -1 ]); + pages[count++] = tmp; + }if (r) {/* If there is any pages in the list put them back to
--
2.11.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
kbuild test robot
build botI love your patch! Yet something to improve:
Hi Christian,
I love your patch! Yet something to improve:
[auto build test ERROR on drm/drm-next]
[also build test ERROR on v4.15-rc2 next-20171206]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Christian-K-nig/drm-ttm-swap-consecutive-allocated-pooled-pages-v4/20171206-191635 base: git://people.freedesktop.org/~airlied/linux.git drm-next config: i386-randconfig-x014-201749 (attached as .config) compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025 reproduce: # save the attached .config to linux build tree make ARCH=i386
All errors (new ones prefixed by >>):
drivers/gpu//drm/ttm/ttm_page_alloc.c: In function 'ttm_get_pages':
>> drivers/gpu//drm/ttm/ttm_page_alloc.c:924:2: error: 'first' undeclared (first use in this function)
first = count;
^~~~~drivers/gpu//drm/ttm/ttm_page_alloc.c:924:2: note: each undeclared identifier is reported only once for each function it appears in
vim +/first +924 drivers/gpu//drm/ttm/ttm_page_alloc.c
919
920 INIT_LIST_HEAD(&plist);
921 r = ttm_page_pool_get_pages(pool, &plist, flags, cstate,
922 npages - count, 0);
923
> 924 first = count;
925 list_for_each_entry(p, &plist, lru) {
926 struct page *tmp = p;
927
928 /* Swap the pages if we detect consecutive order */
929 if (count > first && pages[count - 1] == tmp - 1)
930 swap(tmp, pages[count - 1]);
931 pages[count++] = tmp;
932 }
933
934 if (r) {
935 /* If there is any pages in the list put them back to
936 * the pool.
937 */
938 pr_debug("Failed to allocate extra pages for large request\n");
939 ttm_put_pages(pages, count, flags, cstate);
940 return r;
941 }
942
943 return 0;
944 }
945
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel