Skip to content

Commit 8040cbf

Browse files
Xiongwei Songtehcaster
authored andcommitted
slub: Don't read nr_slabs and total_objects directly
We have node_nr_slabs() to read nr_slabs, node_nr_objs() to read total_objects in a kmem_cache_node, so no need to access the two members directly. Signed-off-by: Xiongwei Song <xiongwei.song@windriver.com> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
1 parent 4f174a8 commit 8040cbf

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

mm/slub.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5156,9 +5156,9 @@ static int validate_slab_node(struct kmem_cache *s,
51565156
validate_slab(s, slab, obj_map);
51575157
count++;
51585158
}
5159-
if (count != atomic_long_read(&n->nr_slabs)) {
5159+
if (count != node_nr_slabs(n)) {
51605160
pr_err("SLUB: %s %ld slabs counted but counter=%ld\n",
5161-
s->name, count, atomic_long_read(&n->nr_slabs));
5161+
s->name, count, node_nr_slabs(n));
51625162
slab_add_kunit_errors();
51635163
}
51645164

@@ -5442,12 +5442,11 @@ static ssize_t show_slab_objects(struct kmem_cache *s,
54425442
for_each_kmem_cache_node(s, node, n) {
54435443

54445444
if (flags & SO_TOTAL)
5445-
x = atomic_long_read(&n->total_objects);
5445+
x = node_nr_objs(n);
54465446
else if (flags & SO_OBJECTS)
5447-
x = atomic_long_read(&n->total_objects) -
5448-
count_partial(n, count_free);
5447+
x = node_nr_objs(n) - count_partial(n, count_free);
54495448
else
5450-
x = atomic_long_read(&n->nr_slabs);
5449+
x = node_nr_slabs(n);
54515450
total += x;
54525451
nodes[node] += x;
54535452
}
@@ -6386,7 +6385,7 @@ static int slab_debug_trace_open(struct inode *inode, struct file *filep)
63866385
unsigned long flags;
63876386
struct slab *slab;
63886387

6389-
if (!atomic_long_read(&n->nr_slabs))
6388+
if (!node_nr_slabs(n))
63906389
continue;
63916390

63926391
spin_lock_irqsave(&n->list_lock, flags);

0 commit comments

Comments
 (0)