drm/ttm: add page order in page pool
Subsystems (3)
PATCH 1/5 drm/ttm: add page order in page pool
to indicate page order for each element in the pool
--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 42 ++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 11 deletions(-)
drivers/gpu/drm/ttm/ttm_page_alloc.c +31 -11
@@ -84,6 +84,7 @@ struct ttm_page_pool {char *name;unsigned long nfrees;unsigned long nrefills; +unsigned int order; };/**
@@ -415,6 +416,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 ;
@@ -424,10 +426,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;
@@ -439,9 +446,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; }
@@ -935,7 +945,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;
@@ -943,8 +953,18 @@ 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; } +/** +* Actually if TRANSPARENT_HUGEPAGE not enabled, we will not use +* wc_pool_huge and uc_pool_huge, so no matter whatever the page +* order are for those two pools +*/ +#ifndef CONFIG_TRANSPARENT_HUGEPAGE +#define HPAGE_PMD_ORDER 9 +#endif +int ttm_page_alloc_init (struct ttm_mem_global *glob,unsigned max_pages) {int ret;
@@ -955,23 +975,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 ;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/5 drm/ttm: add set_pages_wb for handling page order more than zero
--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/ttm/ttm_page_alloc.c +11 -0
@@ -226,6 +226,17 @@ static struct kobj_type ttm_pool_kobj_type = {static struct ttm_pool_manager *_manager;#ifndef CONFIG_X86 +static int set_pages_wb (struct page *page,int numpages) +{ +#if IS_ENABLED (CONFIG_AGP ) +int i; + +for (i =0 ; i < numpages; i++) +unmap_page_from_agp (page++); +#endif +return 0 ; +} +static int set_pages_array_wb (struct page **pages,int addrinarray) {#if IS_ENABLED (CONFIG_AGP )
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/5 drm/ttm: add page order support in ttm_pages_put
In reply to Roger He--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/gpu/drm/ttm/ttm_page_alloc.c +11 -8
@@ -299,13 +299,16 @@ static struct ttm_page_pool *ttm_get_pool(int flags, bool huge, }/* set memory back to wb and free the pages. */ -static void ttm_pages_put (struct page *pages[],unsigned npages) +static void ttm_pages_put (struct page *pages[],unsigned npages, +unsigned int order) { -unsigned i; -if (set_pages_array_wb (pages, npages)) -pr_err ("Failed to set %d pages to wb!\n" , npages); -for (i =0 ; i < npages; ++i) -__free_page (pages[i]); +unsigned int i, pages_nr = (1 << order); + +for (i =0 ; i < npages; ++i) { +if (set_pages_wb (pages[i], pages_nr)) +pr_err ("Failed to set %d pages to wb!\n" , pages_nr); +__free_pages (pages[i], order); + } } static void ttm_pool_update_free_locked(struct ttm_page_pool *pool,
@@ -368,7 +371,7 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free,*/ spin_unlock_irqrestore (&pool->lock, irq_flags); -ttm_pages_put (pages_to_free, freed_pages); +ttm_pages_put (pages_to_free, freed_pages, pool->order);if (likely (nr_free !=FREE_ALL_PAGES )) nr_free -= freed_pages;
@@ -403,7 +406,7 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free,spin_unlock_irqrestore (&pool->lock, irq_flags);if (freed_pages) -ttm_pages_put (pages_to_free, freed_pages); +ttm_pages_put (pages_to_free, freed_pages, pool->order); out:if (pages_to_free != static_buf)kfree (pages_to_free);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/5 drm/ttm: free one in huge pool even shrink request less than one element
In reply to Roger He--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_page_alloc.c +4 -2
@@ -444,11 +444,13 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) pool = &_manager->pools[(i + pool_offset)%NUM_POOLS ];/* OK to use static buffer since global mutex is held. */ nr_free_pool = (nr_free >> pool->order); -if (nr_free_pool ==0 ) -continue ; +if (!nr_free_pool && pool->order) + nr_free_pool =1 ; shrink_pages =ttm_page_pool_free (pool, nr_free_pool, true); freed += ((nr_free_pool - shrink_pages) << pool->order); +if (freed >= sc->nr_to_scan) +break ; }mutex_unlock (&lock);return freed;
Signature · 6 lines
2.7.4 _______________________________________________ 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): 1511337997-26698-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org
PATCH 5/5 drm/ttm: delete set_pages_array_wb since no one use it anymore
--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 11 ----------- 1 file changed, 11 deletions(-)
drivers/gpu/drm/ttm/ttm_page_alloc.c +0 -11
@@ -237,17 +237,6 @@ static int set_pages_wb(struct page *page, int numpages)return 0 ; } -static int set_pages_array_wb (struct page **pages,int addrinarray) -{ -#if IS_ENABLED (CONFIG_AGP ) -int i; - -for (i =0 ; i < addrinarray; i++) -unmap_page_from_agp (pages[i]); -#endif -return 0 ; -} -static int set_pages_array_wc (struct page **pages,int addrinarray) {#if IS_ENABLED (CONFIG_AGP )
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
kbuild test robot
build botThank you for the patch! Perhaps something to improve:
Hi Roger,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on drm/drm-next]
[also build test WARNING 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-035121 base: git://people.freedesktop.org/~airlied/linux.git drm-next config: i386-randconfig-x008-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=i386
All warnings (new ones prefixed by >>):
>> drivers/gpu/drm/ttm/ttm_page_alloc.c:963:0: warning: "HPAGE_PMD_ORDER" redefined
#define HPAGE_PMD_ORDER 9 In file included from include/linux/mm.h:451:0,
from include/linux/highmem.h:7,
from drivers/gpu/drm/ttm/ttm_page_alloc.c:38:
include/linux/huge_mm.h:78:0: note: this is the location of the previous definition
#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
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:
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strcpy' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:421:2: note: in expansion of macro 'if'
if (p_size == (size_t)-1 && q_size == (size_t)-1)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:411:2: note: in expansion of macro 'if'
if (p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:409:2: note: in expansion of macro 'if'
if (__builtin_constant_p(size) && p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:400:2: note: in expansion of macro 'if'
if (p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:398:2: note: in expansion of macro 'if'
if (__builtin_constant_p(size) && p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:389:2: note: in expansion of macro 'if'
if (p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:387:2: note: in expansion of macro 'if'
if (__builtin_constant_p(size) && p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:379:2: note: in expansion of macro 'if'
if (p_size < size || q_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:376:3: note: in expansion of macro 'if'
if (q_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
______f = { \
^ include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
vim +/HPAGE_PMD_ORDER +963 drivers/gpu/drm/ttm/ttm_page_alloc.c
956
957 /**
958 * Actually if TRANSPARENT_HUGEPAGE not enabled, we will not use
959 * wc_pool_huge and uc_pool_huge, so no matter whatever the page
960 * order are for those two pools
961 */
962 #ifndef CONFIG_TRANSPARENT_HUGEPAGE
> 963 #define HPAGE_PMD_ORDER 9
964 #endif
965
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx