Skip to contentSkip to conversation

zsmalloc: reorganize struct size_class to pack 4 bytes hole

PATCH Sergey Senozhatsky 1 participant 1 message Dec 11, 2015 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): "000001d133d3$b75f09b0$261d1d10$@yang"@samsung.com

Sergey Senozhatsky

author Reviewed-by
#1 lore raw

Cc linux-mm and linux-kernel

Quoted 4 lines · Weijie Yang

Reoder the pages_per_zspage field in struct size_class which can eliminate the 4 bytes hole between it and stats field.

Looks good to me.

Quoted 12 lines
---
 mm/zsmalloc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
mm/zsmalloc.c +0 -0
index 9f15bdd..e7414ce 100644
@@ -213,10 +213,10 @@ struct size_class {
 	int size;
 	unsigned int index;

mm/zsmalloc.c struct size_class { · line 222

Quoted 10 lines
mm/zsmalloc.c +2 -2
 
-	/* Number of PAGE_SIZE sized pages to combine to form a 'zspage' */
-	int pages_per_zspage;
 	struct zs_size_stat stats;
 
+	/* Number of PAGE_SIZE sized pages to combine to form a 'zspage' */
+	int pages_per_zspage;
 	/* huge object: pages_per_zspage == 1 && maxobj_per_zspage == 1 */
 	bool huge;
 };

we also can re-order struct zs_pool' -- gfp_t flags' and `bool shrinker_enabled' will be fine together.

I can send a separate patch of we can fold the one below. I'm good either way.

---

mm/zsmalloc.c +5 -7
index 9f15bdd..2a3af25 100644
@@ -246,19 +246,17 @@ struct zs_pool {
 
 	struct size_class **size_class;
 	struct kmem_cache *handle_cachep;
-
-	gfp_t flags;	/* allocation flags used when growing pool */
-	atomic_long_t pages_allocated;
-
 	struct zs_pool_stats stats;
-
-	/* Compact classes */
-	struct shrinker shrinker;
+	atomic_long_t pages_allocated;
+	/* allocation flags used when growing pool */
+	gfp_t flags;
 	/*
 	 * To signify that register_shrinker() was successful
 	 * and unregister_shrinker() will not Oops.
 	 */
 	bool shrinker_enabled;
+	/* Compact classes */
+	struct shrinker shrinker;
 #ifdef CONFIG_ZSMALLOC_STAT
 	struct dentry *stat_dentry;
 #endif

--
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>