On Mon, Jun 30, 2025 at 8:04 PM Christian König <[email protected]> wrote: > > On 30.06.25 06:49, Dave Airlie wrote: > > From: Dave Airlie <[email protected]> > > > > This uses the newly introduced per-node gpu tracking stats, > > to track GPU memory allocated via TTM and reclaimable memory in > > the TTM page pools. > > > > These stats will be useful later for system information and > > later when mem cgroups are integrated. > > > > Cc: Christian Koenig <[email protected]> > > Cc: Matthew Brost <[email protected]> > > Cc: Johannes Weiner <[email protected]> > > Cc: [email protected] > > Cc: Andrew Morton <[email protected]> > > Signed-off-by: Dave Airlie <[email protected]> > > > > --- > > v2: add reclaim parameters and adjust the right counters. > > --- > > drivers/gpu/drm/ttm/ttm_pool.c | 34 ++++++++++++++++++++++++++++------ > > 1 file changed, 28 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c > > index baf27c70a419..11a5777b4a85 100644 > > --- a/drivers/gpu/drm/ttm/ttm_pool.c > > +++ b/drivers/gpu/drm/ttm/ttm_pool.c > > @@ -131,6 +131,16 @@ static struct list_head shrinker_list; > > static struct shrinker *mm_shrinker; > > static DECLARE_RWSEM(pool_shrink_rwsem); > > > > +/* helper to get a current valid node id from a pool */ > > +static int ttm_pool_nid(struct ttm_pool *pool) { > > + int nid = NUMA_NO_NODE; > > + if (pool) > > + nid = pool->nid; > > + if (nid == NUMA_NO_NODE) > > + nid = numa_node_id(); > > That isn't correct. > > The NUMA node in the pool is just a hint where to allocate from, but the > memory can come from somewhere else as well. > > You need to look at the allocated page to figure out to which NUMA node that > belongs.
Indeed, I've killed this from here, using page_to_nid is correct. This helper is needed later to figure out what nid to ask the list_lru for pages from, but I've move it forward into that patch locally. Dave.
