Message ID | 20171205125452.7546-1-christian.koenig@amd.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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>
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
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
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
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(-)