Skip to contentSkip to conversation

drm/ttm: Add cgroup memory accounting for GTT memory

PATCH NAK Mukul Joshi 2 participants 4 messages Jun 6, 2024 – Jun 7, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/ttm: Add cgroup memory accounting for GTT memory

Make sure we do not overflow the memory limits set for a cgroup when doing GTT memory allocations.

---
 drivers/gpu/drm/ttm/ttm_pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_pool.c +1 -1
index 6e1fd6985ffc..59e1accdef08 100644
@@ -91,7 +91,7 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
 	 */
 	if (order)
 		gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN |
-			__GFP_KSWAPD_RECLAIM;
+			__GFP_KSWAPD_RECLAIM | __GFP_ACCOUNT;
 
 	if (!pool->use_dma_alloc) {
 		p = alloc_pages_node(pool->nid, gfp_flags, order);
Signature · 1 line
2.35.1
#1 lore raw

Am 06.06.24 um 21:22 schrieb Mukul Joshi:

Quoted 2 lines

Make sure we do not overflow the memory limits set for a cgroup when doing GTT memory allocations.

NAK, That's intentionally not done like that.

Please see the cgroup discussion on memory management on the public mailing list.

Regards,
Christian.

Quoted 20 lines
---
  drivers/gpu/drm/ttm/ttm_pool.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_pool.c +1 -1
index 6e1fd6985ffc..59e1accdef08 100644
@@ -91,7 +91,7 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
  	 */
  	if (order)
  		gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN |
-			__GFP_KSWAPD_RECLAIM;
+			__GFP_KSWAPD_RECLAIM | __GFP_ACCOUNT;
 
  	if (!pool->use_dma_alloc) {
  		p = alloc_pages_node(pool->nid, gfp_flags, order);
#2 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 9 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, June 7, 2024 3:26 AM
To: Joshi, Mukul <[email protected]>; [email protected]
Cc: Kuehling, Felix <[email protected]>; Bhardwaj, Rajneesh <[email protected]>; Yang, Philip <[email protected]>
Subject: Re: [PATCH] drm/ttm: Add cgroup memory accounting for GTT memory

Quoted 9 lines

Am 06.06.24 um 21:22 schrieb Mukul Joshi:

Quoted 2 lines

Make sure we do not overflow the memory limits set for a cgroup when doing GTT memory allocations.

NAK, That's intentionally not done like that.

Please see the cgroup discussion on memory management on the public mailing list.

Can you please point us to that discussion?

Thanks,
Mukul

Quoted 26 lines

Regards,
Christian.

drivers/gpu/drm/ttm/ttm_pool.c static struct page *ttm_pool_alloc_page(struct

Quoted 13 lines
---
  drivers/gpu/drm/ttm/ttm_pool.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/ttm/ttm_pool.c index 6e1fd6985ffc..59e1accdef08 100644

drivers/gpu/drm/ttm/ttm_pool.c +0 -0
@@ -91,7 +91,7 @@ static struct page *ttm_pool_alloc_page(struct

ttm_pool *pool, gfp_t gfp_flags,

drivers/gpu/drm/ttm/ttm_pool.c static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,

Quoted 3 lines
drivers/gpu/drm/ttm/ttm_pool.c +0 -0
     */
    if (order)
            gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY |

__GFP_NOWARN |

Quoted 5 lines
drivers/gpu/drm/ttm/ttm_pool.c +1 -1
-                   __GFP_KSWAPD_RECLAIM;
+                   __GFP_KSWAPD_RECLAIM | __GFP_ACCOUNT;
 
    if (!pool->use_dma_alloc) {
            p = alloc_pages_node(pool->nid, gfp_flags, order);
#3 lore raw

Am 07.06.24 um 16:43 schrieb Joshi, Mukul:

Quoted 12 lines

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 10 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, June 7, 2024 3:26 AM
To: Joshi, Mukul <[email protected]>; [email protected]
Cc: Kuehling, Felix <[email protected]>; Bhardwaj, Rajneesh <[email protected]>; Yang, Philip <[email protected]>
Subject: Re: [PATCH] drm/ttm: Add cgroup memory accounting for GTT memory

Am 06.06.24 um 21:22 schrieb Mukul Joshi:

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

Make sure we do not overflow the memory limits set for a cgroup when doing GTT memory allocations.

NAK, That's intentionally not done like that.

Please see the cgroup discussion on memory management on the public mailing list.

Can you please point us to that discussion?

IIRC search the mailing list for mails prefixed with "drm/cgroup:".

At some point I stopped looking into this mail thread, but the idea of using __GFP_ACCOUNT was abandoned rather early in the thread.

For adding it in the TTM pool the whole idea falls apart when you consider that the process calling this is usually not the process actually using the memory.

For example when a process causes VRAM pressure it allocates memory to swap out the BOs from other processes to system memory.

Regards,
Christian.

Quoted 29 lines

Thanks,
Mukul

Quoted 25 lines

Regards,
Christian.

drivers/gpu/drm/ttm/ttm_pool.c static struct page *ttm_pool_alloc_page(struct

Quoted 12 lines
---
   drivers/gpu/drm/ttm/ttm_pool.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/ttm/ttm_pool.c index 6e1fd6985ffc..59e1accdef08 100644

drivers/gpu/drm/ttm/ttm_pool.c +0 -0
@@ -91,7 +91,7 @@ static struct page *ttm_pool_alloc_page(struct

ttm_pool *pool, gfp_t gfp_flags,

drivers/gpu/drm/ttm/ttm_pool.c static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,

Quoted 3 lines
drivers/gpu/drm/ttm/ttm_pool.c +0 -0
      */
     if (order)
             gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY |

__GFP_NOWARN |

Quoted 5 lines
drivers/gpu/drm/ttm/ttm_pool.c +1 -1
-                   __GFP_KSWAPD_RECLAIM;
+                   __GFP_KSWAPD_RECLAIM | __GFP_ACCOUNT;
 
     if (!pool->use_dma_alloc) {
             p = alloc_pages_node(pool->nid, gfp_flags, order);