diff mbox series

[2/3] mm/slub: Use node_nr_slabs() instead of slabs_node()

Message ID 20200614123923.99189-3-songmuchun@bytedance.com (mailing list archive)
State New, archived
Headers show
Series mm/slub: Fix slabs_node return value | expand

Commit Message

Muchun Song June 14, 2020, 12:39 p.m. UTC
In the some code, we already get the kmem_cache_node, so we can
use node_nr_slabs() directly instead of slabs_node(). Check the
condition of n->nr_partial can also be removed because we can get
the correct result via node_nr_slabs().

Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
 mm/slub.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Joonsoo Kim June 15, 2020, 6:15 a.m. UTC | #1
2020년 6월 14일 (일) 오후 9:39, Muchun Song <songmuchun@bytedance.com>님이 작성:
>
> In the some code, we already get the kmem_cache_node, so we can
> use node_nr_slabs() directly instead of slabs_node(). Check the
> condition of n->nr_partial can also be removed because we can get
> the correct result via node_nr_slabs().
>
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>

If appying this patch, there is no reference to slabs_node(). Please remove it.

Thanks.
Muchun Song June 15, 2020, 6:20 a.m. UTC | #2
On Mon, Jun 15, 2020 at 2:15 PM Joonsoo Kim <js1304@gmail.com> wrote:
>
> 2020년 6월 14일 (일) 오후 9:39, Muchun Song <songmuchun@bytedance.com>님이 작성:
> >
> > In the some code, we already get the kmem_cache_node, so we can
> > use node_nr_slabs() directly instead of slabs_node(). Check the
> > condition of n->nr_partial can also be removed because we can get
> > the correct result via node_nr_slabs().
> >
> > Signed-off-by: Muchun Song <songmuchun@bytedance.com>
>
> If appying this patch, there is no reference to slabs_node(). Please remove it.
>
> Thanks.

OK, Thanks. I will remove it in the next version.
diff mbox series

Patch

diff --git a/mm/slub.c b/mm/slub.c
index 1a3e6a5b7287..b73505df3de2 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3829,7 +3829,7 @@  bool __kmem_cache_empty(struct kmem_cache *s)
 	struct kmem_cache_node *n;
 
 	for_each_kmem_cache_node(s, node, n)
-		if (n->nr_partial || slabs_node(s, node))
+		if (node_nr_slabs(n))
 			return false;
 	return true;
 }
@@ -3846,7 +3846,7 @@  int __kmem_cache_shutdown(struct kmem_cache *s)
 	/* Attempt to free all objects */
 	for_each_kmem_cache_node(s, node, n) {
 		free_partial(s, n);
-		if (n->nr_partial || slabs_node(s, node))
+		if (node_nr_slabs(n))
 			return 1;
 	}
 	sysfs_slab_remove(s);
@@ -4126,7 +4126,7 @@  int __kmem_cache_shrink(struct kmem_cache *s)
 		list_for_each_entry_safe(page, t, &discard, slab_list)
 			discard_slab(s, page);
 
-		if (slabs_node(s, node))
+		if (node_nr_slabs(n))
 			ret = 1;
 	}
 
@@ -4201,7 +4201,7 @@  static void slab_mem_offline_callback(void *arg)
 			 * and offline_pages() function shouldn't call this
 			 * callback. So, we must fail.
 			 */
-			BUG_ON(slabs_node(s, offline_node));
+			BUG_ON(node_nr_slabs(n));
 
 			s->node[offline_node] = NULL;
 			kmem_cache_free(kmem_cache_node, n);