Skip to content

Commit

Permalink
mm/demotion: drop memtier from memtype
Browse files Browse the repository at this point in the history
Now that we track node-specific memtier in pg_data_t, we can drop memtier
from memtype.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Aneesh Kumar K.V <[email protected]>
Reviewed-by: "Huang, Ying" <[email protected]>
Acked-by: Wei Xu <[email protected]>
Cc: Alistair Popple <[email protected]>
Cc: Bharata B Rao <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: Hesham Almatary <[email protected]>
Cc: Jagdish Gediya <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Jonathan Cameron <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Tim Chen <[email protected]>
Cc: Yang Shi <[email protected]>
Cc: SeongJae Park <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
kvaneesh authored and akpm00 committed Sep 27, 2022
1 parent 7766cf7 commit b26ac6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion include/linux/memory-tiers.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ struct memory_dev_type {
/* Nodes of same abstract distance */
nodemask_t nodes;
struct kref kref;
struct memory_tier *memtier;
};

#ifdef CONFIG_NUMA
Expand Down
16 changes: 9 additions & 7 deletions mm/memory-tiers.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,22 @@ static struct memory_tier *find_create_memory_tier(struct memory_dev_type *memty

lockdep_assert_held_once(&memory_tier_lock);

adistance = round_down(adistance, memtier_adistance_chunk_size);
/*
* If the memtype is already part of a memory tier,
* just return that.
*/
if (memtype->memtier)
return memtype->memtier;
if (!list_empty(&memtype->tier_sibiling)) {
list_for_each_entry(memtier, &memory_tiers, list) {
if (adistance == memtier->adistance_start)
return memtier;
}
WARN_ON(1);
return ERR_PTR(-EINVAL);
}

adistance = round_down(adistance, memtier_adistance_chunk_size);
list_for_each_entry(memtier, &memory_tiers, list) {
if (adistance == memtier->adistance_start) {
memtype->memtier = memtier;
list_add(&memtype->tier_sibiling, &memtier->memory_types);
return memtier;
} else if (adistance < memtier->adistance_start) {
Expand All @@ -135,7 +140,6 @@ static struct memory_tier *find_create_memory_tier(struct memory_dev_type *memty
list_add_tail(&new_memtier->list, &memtier->list);
else
list_add_tail(&new_memtier->list, &memory_tiers);
memtype->memtier = new_memtier;
list_add(&memtype->tier_sibiling, &new_memtier->memory_types);
return new_memtier;
}
Expand Down Expand Up @@ -372,7 +376,6 @@ static bool clear_node_memory_tier(int node)
node_clear(node, memtype->nodes);
if (nodes_empty(memtype->nodes)) {
list_del_init(&memtype->tier_sibiling);
memtype->memtier = NULL;
if (list_empty(&memtier->memory_types))
destroy_memory_tier(memtier);
}
Expand Down Expand Up @@ -400,7 +403,6 @@ struct memory_dev_type *alloc_memory_type(int adistance)
memtype->adistance = adistance;
INIT_LIST_HEAD(&memtype->tier_sibiling);
memtype->nodes = NODE_MASK_NONE;
memtype->memtier = NULL;
kref_init(&memtype->kref);
return memtype;
}
Expand Down

0 comments on commit b26ac6f

Please sign in to comment.