Message ID | 1511256742-5601-2-git-send-email-Hongbo.He@amd.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Am 21.11.2017 um 10:32 schrieb Roger He: > to indicate page order for each element in the pool > > Change-Id: Ic609925ca5d2a5d4ad49d6becf505388ce3624cf > Signed-off-by: Roger He <Hongbo.He@amd.com> > --- > drivers/gpu/drm/ttm/ttm_page_alloc.c | 33 ++++++++++++++++++++++----------- > 1 file changed, 22 insertions(+), 11 deletions(-) > > diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c > index 316f831..2b83c52 100644 > --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c > +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c > @@ -81,6 +81,7 @@ struct ttm_page_pool { > char *name; > unsigned long nfrees; > unsigned long nrefills; > + unsigned int order; > }; > > /** > @@ -412,6 +413,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) > struct ttm_page_pool *pool; > int shrink_pages = sc->nr_to_scan; > unsigned long freed = 0; > + unsigned int nr_free_pool; > > if (!mutex_trylock(&lock)) > return SHRINK_STOP; > @@ -421,10 +423,15 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) > unsigned nr_free = shrink_pages; > if (shrink_pages == 0) > break; > + > pool = &_manager->pools[(i + pool_offset)%NUM_POOLS]; > /* OK to use static buffer since global mutex is held. */ > - shrink_pages = ttm_page_pool_free(pool, nr_free, true); > - freed += nr_free - shrink_pages; > + nr_free_pool = (nr_free >> pool->order); > + if (nr_free_pool == 0) > + continue; > + > + shrink_pages = ttm_page_pool_free(pool, nr_free_pool, true); > + freed += ((nr_free_pool - shrink_pages) << pool->order); > } > mutex_unlock(&lock); > return freed; > @@ -436,9 +443,12 @@ ttm_pool_shrink_count(struct shrinker *shrink, struct shrink_control *sc) > { > unsigned i; > unsigned long count = 0; > + struct ttm_page_pool *pool; > > - for (i = 0; i < NUM_POOLS; ++i) > - count += _manager->pools[i].npages; > + for (i = 0; i < NUM_POOLS; ++i) { > + pool = &_manager->pools[i]; > + count += (pool->npages << pool->order); > + } > > return count; > } > @@ -933,7 +943,7 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags, > } > > static void ttm_page_pool_init_locked(struct ttm_page_pool *pool, gfp_t flags, > - char *name) > + char *name, unsigned int order) > { > spin_lock_init(&pool->lock); > pool->fill_lock = false; > @@ -941,6 +951,7 @@ static void ttm_page_pool_init_locked(struct ttm_page_pool *pool, gfp_t flags, > pool->npages = pool->nfrees = 0; > pool->gfp_flags = flags; > pool->name = name; > + pool->order = order; > } > > int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) > @@ -953,23 +964,23 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) > > _manager = kzalloc(sizeof(*_manager), GFP_KERNEL); > > - ttm_page_pool_init_locked(&_manager->wc_pool, GFP_HIGHUSER, "wc"); > + ttm_page_pool_init_locked(&_manager->wc_pool, GFP_HIGHUSER, "wc", 0); > > - ttm_page_pool_init_locked(&_manager->uc_pool, GFP_HIGHUSER, "uc"); > + ttm_page_pool_init_locked(&_manager->uc_pool, GFP_HIGHUSER, "uc", 0); > > ttm_page_pool_init_locked(&_manager->wc_pool_dma32, > - GFP_USER | GFP_DMA32, "wc dma"); > + GFP_USER | GFP_DMA32, "wc dma", 0); > > ttm_page_pool_init_locked(&_manager->uc_pool_dma32, > - GFP_USER | GFP_DMA32, "uc dma"); > + GFP_USER | GFP_DMA32, "uc dma", 0); > > ttm_page_pool_init_locked(&_manager->wc_pool_huge, > GFP_TRANSHUGE & ~(__GFP_MOVABLE | __GFP_COMP), > - "wc huge"); > + "wc huge", HPAGE_PMD_ORDER); > > ttm_page_pool_init_locked(&_manager->uc_pool_huge, > GFP_TRANSHUGE & ~(__GFP_MOVABLE | __GFP_COMP) > - , "uc huge"); > + , "uc huge", HPAGE_PMD_ORDER); HPAGE_PMD_ORDER isn't defined when huge page support isn't enabled. That's why I avoided using this here. Christian. > > _manager->options.max_size = max_pages; > _manager->options.small = SMALL_ALLOCATION;
Hi Roger, Thank you for the patch! Yet something to improve: [auto build test ERROR on drm/drm-next] [also build test ERROR on next-20171122] [cannot apply to v4.14] [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/Roger-He/drm-ttm-add-page-order-in-page-pool/20171124-032341 base: git://people.freedesktop.org/~airlied/linux.git drm-next config: x86_64-randconfig-x007-201747 (attached as .config) compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All error/warnings (new ones prefixed by >>): In file included from include/uapi/linux/stddef.h:1:0, from include/linux/stddef.h:4, from include/uapi/linux/posix_types.h:4, from include/uapi/linux/types.h:13, from include/linux/types.h:5, from include/linux/list.h:4, from drivers/gpu/drm/ttm/ttm_page_alloc.c:36: drivers/gpu/drm/ttm/ttm_page_alloc.c: In function 'ttm_page_alloc_init': >> include/linux/compiler.h:576:38: error: call to '__compiletime_assert_979' declared with attribute error: BUILD_BUG failed _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^ include/linux/compiler.h:556:4: note: in definition of macro '__compiletime_assert' prefix ## suffix(); \ ^~~~~~ include/linux/compiler.h:576:2: note: in expansion of macro '_compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:46:37: note: in expansion of macro 'compiletime_assert' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:80:21: note: in expansion of macro 'BUILD_BUG_ON_MSG' #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed") ^~~~~~~~~~~~~~~~ include/linux/huge_mm.h:248:28: note: in expansion of macro 'BUILD_BUG' #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) ^~~~~~~~~ include/linux/huge_mm.h:78:26: note: in expansion of macro 'HPAGE_PMD_SHIFT' #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) ^~~~~~~~~~~~~~~ >> drivers/gpu/drm/ttm/ttm_page_alloc.c:979:18: note: in expansion of macro 'HPAGE_PMD_ORDER' "wc huge", HPAGE_PMD_ORDER); ^~~~~~~~~~~~~~~ include/linux/compiler.h:576:38: error: call to '__compiletime_assert_983' declared with attribute error: BUILD_BUG failed _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^ include/linux/compiler.h:556:4: note: in definition of macro '__compiletime_assert' prefix ## suffix(); \ ^~~~~~ include/linux/compiler.h:576:2: note: in expansion of macro '_compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:46:37: note: in expansion of macro 'compiletime_assert' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:80:21: note: in expansion of macro 'BUILD_BUG_ON_MSG' #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed") ^~~~~~~~~~~~~~~~ include/linux/huge_mm.h:248:28: note: in expansion of macro 'BUILD_BUG' #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) ^~~~~~~~~ include/linux/huge_mm.h:78:26: note: in expansion of macro 'HPAGE_PMD_SHIFT' #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) ^~~~~~~~~~~~~~~ drivers/gpu/drm/ttm/ttm_page_alloc.c:983:20: note: in expansion of macro 'HPAGE_PMD_ORDER' , "uc huge", HPAGE_PMD_ORDER); ^~~~~~~~~~~~~~~ -- In file included from include/uapi/linux/stddef.h:1:0, from include/linux/stddef.h:4, from include/uapi/linux/posix_types.h:4, from include/uapi/linux/types.h:13, from include/linux/types.h:5, from include/linux/list.h:4, from drivers/gpu//drm/ttm/ttm_page_alloc.c:36: drivers/gpu//drm/ttm/ttm_page_alloc.c: In function 'ttm_page_alloc_init': >> include/linux/compiler.h:576:38: error: call to '__compiletime_assert_979' declared with attribute error: BUILD_BUG failed _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^ include/linux/compiler.h:556:4: note: in definition of macro '__compiletime_assert' prefix ## suffix(); \ ^~~~~~ include/linux/compiler.h:576:2: note: in expansion of macro '_compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:46:37: note: in expansion of macro 'compiletime_assert' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:80:21: note: in expansion of macro 'BUILD_BUG_ON_MSG' #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed") ^~~~~~~~~~~~~~~~ include/linux/huge_mm.h:248:28: note: in expansion of macro 'BUILD_BUG' #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) ^~~~~~~~~ include/linux/huge_mm.h:78:26: note: in expansion of macro 'HPAGE_PMD_SHIFT' #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) ^~~~~~~~~~~~~~~ drivers/gpu//drm/ttm/ttm_page_alloc.c:979:18: note: in expansion of macro 'HPAGE_PMD_ORDER' "wc huge", HPAGE_PMD_ORDER); ^~~~~~~~~~~~~~~ include/linux/compiler.h:576:38: error: call to '__compiletime_assert_983' declared with attribute error: BUILD_BUG failed _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^ include/linux/compiler.h:556:4: note: in definition of macro '__compiletime_assert' prefix ## suffix(); \ ^~~~~~ include/linux/compiler.h:576:2: note: in expansion of macro '_compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:46:37: note: in expansion of macro 'compiletime_assert' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:80:21: note: in expansion of macro 'BUILD_BUG_ON_MSG' #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed") ^~~~~~~~~~~~~~~~ include/linux/huge_mm.h:248:28: note: in expansion of macro 'BUILD_BUG' #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) ^~~~~~~~~ include/linux/huge_mm.h:78:26: note: in expansion of macro 'HPAGE_PMD_SHIFT' #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) ^~~~~~~~~~~~~~~ drivers/gpu//drm/ttm/ttm_page_alloc.c:983:20: note: in expansion of macro 'HPAGE_PMD_ORDER' , "uc huge", HPAGE_PMD_ORDER); ^~~~~~~~~~~~~~~ vim +/HPAGE_PMD_ORDER +979 drivers/gpu/drm/ttm/ttm_page_alloc.c 956 957 int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) 958 { 959 int ret; 960 961 WARN_ON(_manager); 962 963 pr_info("Initializing pool allocator\n"); 964 965 _manager = kzalloc(sizeof(*_manager), GFP_KERNEL); 966 967 ttm_page_pool_init_locked(&_manager->wc_pool, GFP_HIGHUSER, "wc", 0); 968 969 ttm_page_pool_init_locked(&_manager->uc_pool, GFP_HIGHUSER, "uc", 0); 970 971 ttm_page_pool_init_locked(&_manager->wc_pool_dma32, 972 GFP_USER | GFP_DMA32, "wc dma", 0); 973 974 ttm_page_pool_init_locked(&_manager->uc_pool_dma32, 975 GFP_USER | GFP_DMA32, "uc dma", 0); 976 977 ttm_page_pool_init_locked(&_manager->wc_pool_huge, 978 GFP_TRANSHUGE & ~(__GFP_MOVABLE | __GFP_COMP), > 979 "wc huge", HPAGE_PMD_ORDER); 980 981 ttm_page_pool_init_locked(&_manager->uc_pool_huge, 982 GFP_TRANSHUGE & ~(__GFP_MOVABLE | __GFP_COMP) 983 , "uc huge", HPAGE_PMD_ORDER); 984 985 _manager->options.max_size = max_pages; 986 _manager->options.small = SMALL_ALLOCATION; 987 _manager->options.alloc_size = NUM_PAGES_TO_ALLOC; 988 989 ret = kobject_init_and_add(&_manager->kobj, &ttm_pool_kobj_type, 990 &glob->kobj, "pool"); 991 if (unlikely(ret != 0)) { 992 kobject_put(&_manager->kobj); 993 _manager = NULL; 994 return ret; 995 } 996 997 ttm_pool_mm_shrink_init(_manager); 998 999 return 0; 1000 } 1001 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi Roger, Thank you for the patch! Yet something to improve: [auto build test ERROR on drm/drm-next] [also build test ERROR on next-20171122] [cannot apply to v4.14] [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/Roger-He/drm-ttm-add-page-order-in-page-pool/20171124-032341 base: git://people.freedesktop.org/~airlied/linux.git drm-next config: tile-allmodconfig (attached as .config) compiler: tilegx-linux-gcc (GCC) 4.6.2 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=tile All errors (new ones prefixed by >>): drivers/gpu//drm/ttm/ttm_page_alloc.c: In function 'ttm_page_alloc_init': >> drivers/gpu//drm/ttm/ttm_page_alloc.c:979:18: error: call to '__compiletime_assert_979' declared with attribute error: BUILD_BUG failed drivers/gpu//drm/ttm/ttm_page_alloc.c:983:20: error: call to '__compiletime_assert_983' declared with attribute error: BUILD_BUG failed vim +/__compiletime_assert_979 +979 drivers/gpu//drm/ttm/ttm_page_alloc.c 956 957 int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) 958 { 959 int ret; 960 961 WARN_ON(_manager); 962 963 pr_info("Initializing pool allocator\n"); 964 965 _manager = kzalloc(sizeof(*_manager), GFP_KERNEL); 966 967 ttm_page_pool_init_locked(&_manager->wc_pool, GFP_HIGHUSER, "wc", 0); 968 969 ttm_page_pool_init_locked(&_manager->uc_pool, GFP_HIGHUSER, "uc", 0); 970 971 ttm_page_pool_init_locked(&_manager->wc_pool_dma32, 972 GFP_USER | GFP_DMA32, "wc dma", 0); 973 974 ttm_page_pool_init_locked(&_manager->uc_pool_dma32, 975 GFP_USER | GFP_DMA32, "uc dma", 0); 976 977 ttm_page_pool_init_locked(&_manager->wc_pool_huge, 978 GFP_TRANSHUGE & ~(__GFP_MOVABLE | __GFP_COMP), > 979 "wc huge", HPAGE_PMD_ORDER); 980 981 ttm_page_pool_init_locked(&_manager->uc_pool_huge, 982 GFP_TRANSHUGE & ~(__GFP_MOVABLE | __GFP_COMP) 983 , "uc huge", HPAGE_PMD_ORDER); 984 985 _manager->options.max_size = max_pages; 986 _manager->options.small = SMALL_ALLOCATION; 987 _manager->options.alloc_size = NUM_PAGES_TO_ALLOC; 988 989 ret = kobject_init_and_add(&_manager->kobj, &ttm_pool_kobj_type, 990 &glob->kobj, "pool"); 991 if (unlikely(ret != 0)) { 992 kobject_put(&_manager->kobj); 993 _manager = NULL; 994 return ret; 995 } 996 997 ttm_pool_mm_shrink_init(_manager); 998 999 return 0; 1000 } 1001 --- 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 316f831..2b83c52 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -81,6 +81,7 @@ struct ttm_page_pool { char *name; unsigned long nfrees; unsigned long nrefills; + unsigned int order; }; /** @@ -412,6 +413,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) struct ttm_page_pool *pool; int shrink_pages = sc->nr_to_scan; unsigned long freed = 0; + unsigned int nr_free_pool; if (!mutex_trylock(&lock)) return SHRINK_STOP; @@ -421,10 +423,15 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) unsigned nr_free = shrink_pages; if (shrink_pages == 0) break; + pool = &_manager->pools[(i + pool_offset)%NUM_POOLS]; /* OK to use static buffer since global mutex is held. */ - shrink_pages = ttm_page_pool_free(pool, nr_free, true); - freed += nr_free - shrink_pages; + nr_free_pool = (nr_free >> pool->order); + if (nr_free_pool == 0) + continue; + + shrink_pages = ttm_page_pool_free(pool, nr_free_pool, true); + freed += ((nr_free_pool - shrink_pages) << pool->order); } mutex_unlock(&lock); return freed; @@ -436,9 +443,12 @@ ttm_pool_shrink_count(struct shrinker *shrink, struct shrink_control *sc) { unsigned i; unsigned long count = 0; + struct ttm_page_pool *pool; - for (i = 0; i < NUM_POOLS; ++i) - count += _manager->pools[i].npages; + for (i = 0; i < NUM_POOLS; ++i) { + pool = &_manager->pools[i]; + count += (pool->npages << pool->order); + } return count; } @@ -933,7 +943,7 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags, } static void ttm_page_pool_init_locked(struct ttm_page_pool *pool, gfp_t flags, - char *name) + char *name, unsigned int order) { spin_lock_init(&pool->lock); pool->fill_lock = false; @@ -941,6 +951,7 @@ static void ttm_page_pool_init_locked(struct ttm_page_pool *pool, gfp_t flags, pool->npages = pool->nfrees = 0; pool->gfp_flags = flags; pool->name = name; + pool->order = order; } int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) @@ -953,23 +964,23 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) _manager = kzalloc(sizeof(*_manager), GFP_KERNEL); - ttm_page_pool_init_locked(&_manager->wc_pool, GFP_HIGHUSER, "wc"); + ttm_page_pool_init_locked(&_manager->wc_pool, GFP_HIGHUSER, "wc", 0); - ttm_page_pool_init_locked(&_manager->uc_pool, GFP_HIGHUSER, "uc"); + ttm_page_pool_init_locked(&_manager->uc_pool, GFP_HIGHUSER, "uc", 0); ttm_page_pool_init_locked(&_manager->wc_pool_dma32, - GFP_USER | GFP_DMA32, "wc dma"); + GFP_USER | GFP_DMA32, "wc dma", 0); ttm_page_pool_init_locked(&_manager->uc_pool_dma32, - GFP_USER | GFP_DMA32, "uc dma"); + GFP_USER | GFP_DMA32, "uc dma", 0); ttm_page_pool_init_locked(&_manager->wc_pool_huge, GFP_TRANSHUGE & ~(__GFP_MOVABLE | __GFP_COMP), - "wc huge"); + "wc huge", HPAGE_PMD_ORDER); ttm_page_pool_init_locked(&_manager->uc_pool_huge, GFP_TRANSHUGE & ~(__GFP_MOVABLE | __GFP_COMP) - , "uc huge"); + , "uc huge", HPAGE_PMD_ORDER); _manager->options.max_size = max_pages; _manager->options.small = SMALL_ALLOCATION;
to indicate page order for each element in the pool Change-Id: Ic609925ca5d2a5d4ad49d6becf505388ce3624cf Signed-off-by: Roger He <Hongbo.He@amd.com> --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-)