Re: [PATCH v5 2/9] mm/demotion: Expose per node memory tier to sysfs

From: Tim Chen
Date: Wed Jun 08 2022 - 12:09:33 EST


On Wed, 2022-06-08 at 10:25 +0530, Aneesh Kumar K V wrote:
> On 6/8/22 1:45 AM, Tim Chen wrote:
> > On Fri, 2022-06-03 at 19:12 +0530, Aneesh Kumar K.V wrote:
> > >
> > > +static struct memory_tier *__node_get_memory_tier(int node)
> > > +{
> > > + struct memory_tier *memtier;
> > > +
> > > + list_for_each_entry(memtier, &memory_tiers, list) {
> >
> > We could need to map node to mem_tier quite often, if we need
> > to account memory usage at tier level. It will be more efficient
> > to have a pointer from node (pgdat) to memtier rather
> > than doing a search through the list.
> >
> >
>
> That is something I was actively trying to avoid. Currently all struct
> memory_tier references are with memory_tier_lock mutex held. That
> simplify the locking and reference counting.
>
> As of now we are able to implement all the required interfaces without
> pgdat having pointers to struct memory_tier. We can update pgdat with
> memtier details when we are implementing changes requiring those. We
> could keep additional memtier->dev reference to make sure memory tiers
> are not destroyed while other part of the kernel is referencing the
> same. But IMHO such changes should wait till we have users for the same.
>

I think we should have an efficient mapping from node to memtier from
the get go. There are many easily envisioned scenarios where
we need to map from node to memtier, which Ying pointed out.

Tim