* [PATCH] drm/ttm: swap consecutive allocated pooled pages v4
@ 2017-12-05 12:54 Christian König
[not found] ` <20171205125452.7546-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Christian König @ 2017-12-05 12:54 UTC (permalink / raw)
To: dri-devel, amd-gfx, Hongbo.He
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
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/ttm/ttm_page_alloc.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index b6f7ce286fb1..44343a2bf55c 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -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
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/ttm: swap consecutive allocated pooled pages v4
[not found] ` <20171205125452.7546-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
@ 2017-12-05 14:57 ` Michel Dänzer
2017-12-06 8:58 ` Dieter Nützel
1 sibling, 0 replies; 5+ messages in thread
From: Michel Dänzer @ 2017-12-05 14:57 UTC (permalink / raw)
To: Christian König, Hongbo.He-5C7GfCeVMHo
Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
On 2017-12-05 01:54 PM, Christian König wrote:
> 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
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/ttm/ttm_page_alloc.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
> index b6f7ce286fb1..44343a2bf55c 100644
> --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
> +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
> @@ -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
>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] drm/ttm: swap consecutive allocated pooled pages v4
2017-12-05 12:54 [PATCH] drm/ttm: swap consecutive allocated pooled pages v4 Christian König
[not found] ` <20171205125452.7546-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
@ 2017-12-06 2:01 ` He, Roger
2017-12-06 16:34 ` kbuild test robot
2 siblings, 0 replies; 5+ messages in thread
From: He, Roger @ 2017-12-06 2:01 UTC (permalink / raw)
To: Christian König, dri-devel, amd-gfx
Reviewed-by: Roger He <Hongbo.He@amd.com>
Thanks
Roger(Hongbo.He)
-----Original Message-----
From: Christian König [mailto:ckoenig.leichtzumerken@gmail.com]
Sent: Tuesday, December 05, 2017 8:55 PM
To: dri-devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org; He, Roger <Hongbo.He@amd.com>
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
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/ttm/ttm_page_alloc.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index b6f7ce286fb1..44343a2bf55c 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -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
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/ttm: swap consecutive allocated pooled pages v4
[not found] ` <20171205125452.7546-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-12-05 14:57 ` Michel Dänzer
@ 2017-12-06 8:58 ` Dieter Nützel
1 sibling, 0 replies; 5+ messages in thread
From: Dieter Nützel @ 2017-12-06 8:58 UTC (permalink / raw)
To: Christian König
Cc: Hongbo.He-5C7GfCeVMHo, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Dieter
Am 05.12.2017 13:54, schrieb 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 variable
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/ttm/ttm_page_alloc.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c
> b/drivers/gpu/drm/ttm/ttm_page_alloc.c
> index b6f7ce286fb1..44343a2bf55c 100644
> --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
> +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
> @@ -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
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/ttm: swap consecutive allocated pooled pages v4
2017-12-05 12:54 [PATCH] drm/ttm: swap consecutive allocated pooled pages v4 Christian König
[not found] ` <20171205125452.7546-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-12-06 2:01 ` He, Roger
@ 2017-12-06 16:34 ` kbuild test robot
2 siblings, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2017-12-06 16:34 UTC (permalink / raw)
To: Christian König; +Cc: amd-gfx, Hongbo.He, kbuild-all, dri-devel
[-- Attachment #1: Type: text/plain, Size: 2022 bytes --]
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
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33290 bytes --]
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-12-06 16:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-05 12:54 [PATCH] drm/ttm: swap consecutive allocated pooled pages v4 Christian König
[not found] ` <20171205125452.7546-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-12-05 14:57 ` Michel Dänzer
2017-12-06 8:58 ` Dieter Nützel
2017-12-06 2:01 ` He, Roger
2017-12-06 16:34 ` kbuild test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.