Skip to content

Commit 3dd549a

Browse files
cmzxotehcaster
authored andcommitted
mm, slab: remove the corner case of inc_slabs_node()
We already have the inc_slabs_node() after kmem_cache_node->node[node] initialized in early_kmem_cache_node_alloc(), this special case of inc_slabs_node() can be removed. Then we don't need to consider the existence of kmem_cache_node in inc_slabs_node() anymore. Signed-off-by: Chengming Zhou <chengming.zhou@linux.dev> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
1 parent 011568e commit 3dd549a

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

mm/slub.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,16 +1498,8 @@ static inline void inc_slabs_node(struct kmem_cache *s, int node, int objects)
14981498
{
14991499
struct kmem_cache_node *n = get_node(s, node);
15001500

1501-
/*
1502-
* May be called early in order to allocate a slab for the
1503-
* kmem_cache_node structure. Solve the chicken-egg
1504-
* dilemma by deferring the increment of the count during
1505-
* bootstrap (see early_kmem_cache_node_alloc).
1506-
*/
1507-
if (likely(n)) {
1508-
atomic_long_inc(&n->nr_slabs);
1509-
atomic_long_add(objects, &n->total_objects);
1510-
}
1501+
atomic_long_inc(&n->nr_slabs);
1502+
atomic_long_add(objects, &n->total_objects);
15111503
}
15121504
static inline void dec_slabs_node(struct kmem_cache *s, int node, int objects)
15131505
{
@@ -4855,7 +4847,6 @@ static void early_kmem_cache_node_alloc(int node)
48554847
slab = new_slab(kmem_cache_node, GFP_NOWAIT, node);
48564848

48574849
BUG_ON(!slab);
4858-
inc_slabs_node(kmem_cache_node, slab_nid(slab), slab->objects);
48594850
if (slab_nid(slab) != node) {
48604851
pr_err("SLUB: Unable to allocate memory from node %d\n", node);
48614852
pr_err("SLUB: Allocating a useless per node structure in order to be able to continue\n");

0 commit comments

Comments
 (0)