Re: [PATCH v6 09/13] mm/demotion: Add pg_data_t member to track node memory tier details

Ying Huang
2022-06-13T07:09:17Z

On Fri, 2022-06-10 at 19:22 +0530, Aneesh Kumar K.V wrote:
> Also update different helpes to use NODE_DATA()->memtier. Since
> node specific memtier can change based on the reassignment of
> NUMA node to a different memory tiers, accessing NODE_DATA()->memtier
> needs to under an rcu read lock of memory_tier_lock.
>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> ---
>  include/linux/memory-tiers.h | 14 +++++
>  include/linux/mmzone.h | 3 ++
>  mm/memory-tiers.c | 102 ++++++++++++++++++++++++++---------
>  3 files changed, 94 insertions(+), 25 deletions(-)
>
> diff --git a/include/linux/memory-tiers.h b/include/linux/memory-tiers.h
> index 52896f5970b7..53f3e4c7cba8 100644
> --- a/include/linux/memory-tiers.h
> +++ b/include/linux/memory-tiers.h
> @@ -6,6 +6,9 @@
>
>
>  #ifdef CONFIG_TIERED_MEMORY
>
>
> +#include <linux/device.h>
> +#include <linux/nodemask.h>
> +
>  #define MEMORY_TIER_HBM_GPU 0
>  #define MEMORY_TIER_DRAM 1
>  #define MEMORY_TIER_PMEM 2
> @@ -18,13 +21,24 @@
>  #define MAX_STATIC_MEMORY_TIERS 3
>  #define MAX_MEMORY_TIERS (MAX_STATIC_MEMORY_TIERS + 2)
>
>
> +struct memory_tier {
> + struct list_head list;
> + struct device dev;
> + nodemask_t nodelist;
> + int rank;
> +};
> +

I suggest to use two data structure,

struct memory_tier {
struct list_head list;
nodemask_t nodelist;
int rank;
};

struct memory_tier_dev {
struct list_head list;
struct device dev;
struct memory_tier *tier;
};

Then we can put struct memory_tier here and still hide struct
memory_tier_dev in memory_tiers.c. In this way, we don't need to
force all struct memory_tier users to compile the entire driver core
headers. And we can separate the user space interface implementation
from the other part of the kernel.

>  extern bool numa_demotion_enabled;
>  int node_create_and_set_memory_tier(int node, int tier);
>  int next_demotion_node(int node);
>  int node_set_memory_tier(int node, int tier);
>  int node_get_memory_tier_id(int node);
>  int node_reset_memory_tier(int node, int tier);
> +struct memory_tier *node_get_memory_tier(int node);
> +void node_put_memory_tier(struct memory_tier *memtier);

I don't find caller of these 2 functions in series. Can we remove
these functions?

Best Regards,
Huang, Ying

[snip]