drm/ttm: use compound pages for THP
Subsystems (3)
PATCH 1/1 drm/ttm: use compound pages for THP
Compound page metadata is necessary for page reference counting to work properly on pages besides the head page. Without it, put_page corresponding to the last outstanding get_page call on a tail page will end up freeing that page, even if the bo still references the page.
--- drivers/gpu/drm/ttm/ttm_pool.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/ttm/ttm_pool.c +0 -1
@@ -83,7 +83,6 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags, gfp_flags |=GFP_TRANSHUGE_LIGHT | __GFP_NORETRY | __GFP_KSWAPD_RECLAIM; gfp_flags &= ~__GFP_MOVABLE; - gfp_flags &= ~__GFP_COMP; }if (!pool->use_dma_alloc) {
Signature · 6 lines
2.30.0.284.gd98b1dd5eaa7-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
NAKAm 13.01.21 um 09:47 schrieb David Stevens:
Quoted 4 lines
Compound page metadata is necessary for page reference counting to work properly on pages besides the head page. Without it,
put_pagecorresponding to the last outstandingget_pagecall on a tail page will end up freeing that page, even if the bo still references the page.
NAK, I should add a comment since I can't count any more how many times people came up with this.
Calling put_page() on a TTM allocated page is strictly illegal in the first place since they are not reference counted.
Please don't tell me somebody once more tried to mmap() pages from a DMA-buf created sg_table into a process address space?
Regards,
Christian.
Quoted 11 lines
Signed-off-by David Stevens <[email protected]>--- drivers/gpu/drm/ttm/ttm_pool.c | 1 - 1 file changed, 1 deletion(-)drivers/gpu/drm/ttm/ttm_pool.c +0
-0
drivers/gpu/drm/ttm/ttm_pool.c static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags, · line 88
Quoted 7 lines
drivers/gpu/drm/ttm/ttm_pool.c +0
-1@@ -83,7 +83,6 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags, gfp_flags |=GFP_TRANSHUGE_LIGHT | __GFP_NORETRY | __GFP_KSWAPD_RECLAIM; gfp_flags &= ~__GFP_MOVABLE; - gfp_flags &= ~__GFP_COMP; }if (!pool->use_dma_alloc) {
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Christian König
Am 13.01.21 um 09:47 schrieb David Stevens:
Quoted 4 lines
Compound page metadata is necessary for page reference counting to work properly on pages besides the head page. Without it,
put_pagecorresponding to the last outstandingget_pagecall on a tail page will end up freeing that page, even if the bo still references the page.
Quoted 8 lines
NAK, I should add a comment since I can't count any more how many times people came up with this.
Calling
put_page()on a TTM allocated page is strictly illegal in the first place since they are not reference counted.Please don't tell me somebody once more tried to
mmap()pages from a DMA-buf createdsg_tableinto a process address space?
I ran into this on a system using the currently in development virtio-gpu blob resources [1]. The implementation passes dma buffers allocated by the host gpu to KVM_SET_USER_MEMORY_REGION, so the guest can directly access the buffers without the need for an intermediate copy.
[1] https://patchwork.kernel.org/project/dri-devel/cover/[email protected]/
Quoted 20 lines
Regards,
Christian.Quoted 17 lines
Signed-off-by David Stevens <[email protected]>--- drivers/gpu/drm/ttm/ttm_pool.c | 1 - 1 file changed, 1 deletion(-)drivers/gpu/drm/ttm/ttm_pool.c +0
-1@@ -83,7 +83,6 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags, gfp_flags |=GFP_TRANSHUGE_LIGHT | __GFP_NORETRY | __GFP_KSWAPD_RECLAIM; gfp_flags &= ~__GFP_MOVABLE; - gfp_flags &= ~__GFP_COMP; }
Quoted 2 lines
drivers/gpu/drm/ttm/ttm_pool.c static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags, · line 88
Quoted 1 line
drivers/gpu/drm/ttm/ttm_pool.c +0
-0if (!pool->use_dma_alloc) {
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 13.01.21 um 10:33 schrieb David Stevens:
Quoted 13 lines
Quoted 11 lines · Christian König
Am 13.01.21 um 09:47 schrieb David Stevens:
Quoted 4 lines
Compound page metadata is necessary for page reference counting to work properly on pages besides the head page. Without it,
put_pagecorresponding to the last outstandingget_pagecall on a tail page will end up freeing that page, even if the bo still references the page.NAK, I should add a comment since I can't count any more how many times people came up with this.
Calling
put_page()on a TTM allocated page is strictly illegal in the first place since they are not reference counted.
Quoted 7 lines
Quoted 2 lines
Please don't tell me somebody once more tried to
mmap()pages from a DMA-buf createdsg_tableinto a process address space?I ran into this on a system using the currently in development virtio-gpu blob resources [1]. The implementation passes dma buffers allocated by the host gpu to
KVM_SET_USER_MEMORY_REGION, so the guest can directly access the buffers without the need for an intermediate copy.
Yeah, that is completely illegal. They risk memory corruption with that.
You should probably report back to the author of those patches and not that the dma_buf_mmap() functions need to be used for this use case.
Regards,
Christian.
Quoted 22 lines
Quoted 19 lines
Regards,
Christian.Quoted 16 lines
Signed-off-by David Stevens <[email protected]>--- drivers/gpu/drm/ttm/ttm_pool.c | 1 - 1 file changed, 1 deletion(-)drivers/gpu/drm/ttm/ttm_pool.c +0
-1@@ -83,7 +83,6 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags, gfp_flags |=GFP_TRANSHUGE_LIGHT | __GFP_NORETRY | __GFP_KSWAPD_RECLAIM; gfp_flags &= ~__GFP_MOVABLE; - gfp_flags &= ~__GFP_COMP; }
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/ttm/ttm_pool.c static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags, · line 88
Quoted 1 line
drivers/gpu/drm/ttm/ttm_pool.c +0
-0if (!pool->use_dma_alloc) {
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel