Skip to contentSkip to conversation

zsmalloc: use class->pages_per_zspage

PATCH Superseded Minchan Kim 2 participants 4 messages Jul 15, 2015 – Jul 16, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Minchan Kim

author maintainer
#0 lore raw

PATCH 1/1 zsmalloc: use class->pages_per_zspage

There is no need to recalcurate pages_per_zspage in runtime. Just use class->pages_per_zspage to avoid unnecessary runtime overhead.

---
 mm/zsmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zsmalloc.c +1 -1
index 27b9661c8fa6..154a30e9c8a8 100644
@@ -1711,7 +1711,7 @@ static unsigned long zs_can_compact(struct size_class *class)
 	obj_wasted /= get_maxobj_per_zspage(class->size,
 			class->pages_per_zspage);
 
-	return obj_wasted * get_pages_per_zspage(class->size);
+	return obj_wasted * class->pages_per_zspage;
 }
 
 static void __zs_compact(struct zs_pool *pool, struct size_class *class)
Signature · 7 lines
1.9.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 14 lines · Minchan Kim

There is no need to recalcurate pages_per_zspage in runtime. Just use class->pages_per_zspage to avoid unnecessary runtime overhead.

---
 mm/zsmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zsmalloc.c +0 -0
index 27b9661c8fa6..154a30e9c8a8 100644

mm/zsmalloc.c static unsigned long zs_can_compact(struct size_class *class) · line 1715

Quoted 6 lines
mm/zsmalloc.c +1 -1
@@ -1711,7 +1711,7 @@ static unsigned long zs_can_compact(struct size_class *class)
 	obj_wasted /= get_maxobj_per_zspage(class->size,
 			class->pages_per_zspage);
 
-	return obj_wasted * get_pages_per_zspage(class->size);
+	return obj_wasted * class->pages_per_zspage;
 }

plus __zs_compact():

@@ -1761,8 +1761,7 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)

                putback_zspage(pool, class, dst_page);
                if (putback_zspage(pool, class, src_page) == ZS_EMPTY)
-                       pool->stats.pages_compacted +=
-                               get_pages_per_zspage(class->size);
+                       pool->stats.pages_compacted += class->pages_per_zspage;
                spin_unlock(&class->lock);
                cond_resched();
                spin_lock(&class->lock);

	-ss

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author maintainer
#2 lore raw
Quoted 35 lines · Sergey Senozhatsky
Quoted 14 lines · Minchan Kim

There is no need to recalcurate pages_per_zspage in runtime. Just use class->pages_per_zspage to avoid unnecessary runtime overhead.

---
 mm/zsmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zsmalloc.c +0 -0
index 27b9661c8fa6..154a30e9c8a8 100644

mm/zsmalloc.c static unsigned long zs_can_compact(struct size_class *class) · line 1715

Quoted 6 lines
mm/zsmalloc.c +1 -1
@@ -1711,7 +1711,7 @@ static unsigned long zs_can_compact(struct size_class *class)
 	obj_wasted /= get_maxobj_per_zspage(class->size,
 			class->pages_per_zspage);
 
-	return obj_wasted * get_pages_per_zspage(class->size);
+	return obj_wasted * class->pages_per_zspage;
 }

plus __zs_compact():

(quoted diff) +1 -2
@@ -1761,8 +1761,7 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)
 
                putback_zspage(pool, class, dst_page);
                if (putback_zspage(pool, class, src_page) == ZS_EMPTY)
-                       pool->stats.pages_compacted +=
-                               get_pages_per_zspage(class->size);
+                       pool->stats.pages_compacted += class->pages_per_zspage;
                spin_unlock(&class->lock);
                cond_resched();
                spin_lock(&class->lock);
Quoted 1 line
	-ss

Thanks. I sent a v2.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw
In reply to Minchan Kim

mm/zsmalloc.c static unsigned long zs_can_compact(struct size_class *class) · line 1717

Quoted 13 lines · Minchan Kim
mm/zsmalloc.c +1 -1
index 27b9661c8fa6..154a30e9c8a8 100644
@@ -1711,7 +1711,7 @@ static unsigned long zs_can_compact(struct size_class *class)
 	obj_wasted /= get_maxobj_per_zspage(class->size,
 			class->pages_per_zspage);
 
-	return obj_wasted * get_pages_per_zspage(class->size);
+	return obj_wasted * class->pages_per_zspage;
 }
 
 static void __zs_compact(struct zs_pool *pool, struct size_class *class)

[resending, not sure that my previous reply was delivered. connectivity problems on my side]

plus __zs_compact():

@@ -1761,8 +1761,7 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)

                putback_zspage(pool, class, dst_page);
                if (putback_zspage(pool, class, src_page) == ZS_EMPTY)
-                       pool->stats.pages_compacted +=
-                               get_pages_per_zspage(class->size);
+                       pool->stats.pages_compacted += class->pages_per_zspage;
                spin_unlock(&class->lock);
                cond_resched();
                spin_lock(&class->lock);

	-ss

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>