Skip to contentSkip to conversation

mm/slub.c: pack red_left_pad with another int to save a word

PATCH New [email protected] 1 participant 1 message Jul 6, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 22/108 mm/slub.c: pack red_left_pad with another int to save a word

From: Wei Yang <[email protected]>
Subject: mm/slub.c: pack red_left_pad with another int to save a word

Patch series "try to save some memory for kmem_cache in some cases", v2.

kmem_cache is a frequently used data in kernel. During the code reading, I found maybe we could save some space in some cases.

1. On 64bit arch, type int will occupy a word if it doesn't sit well.

2. cpu_slab->partial is just used when CONFIG_SLUB_CPU_PARTIAL is set

3. cpu_partial is just used when CONFIG_SLUB_CPU_PARTIAL is set, while just save some space on 32bit arch.

This patch (of 3):

On 64bit arch, struct is 8-bytes aligned, so int will occupy a word if it doesn't sit well.

This patch pack red_left_pad with reserved to save 8 bytes for struct kmem_cache on a 64bit arch.

---

 include/linux/slub_def.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/slub_def.h renamed from include/linux/slub_def.h~mm-slub-pack-red_left_pad-with-another-int-to-save-a-word +1 -1
diff -puN include/linux/slub_def.h~mm-slub-pack-red_left_pad-with-another-int-to-save-a-word include/linux/slub_def.h
@@ -79,9 +79,9 @@ struct kmem_cache {
 	int inuse;		/* Offset to metadata */
 	int align;		/* Alignment */
 	int reserved;		/* Reserved bytes at the end of slabs */
+	int red_left_pad;	/* Left redzone padding size */
 	const char *name;	/* Name (only for display!) */
 	struct list_head list;	/* List of slab caches */
-	int red_left_pad;	/* Left redzone padding size */
 #ifdef CONFIG_SYSFS
 	struct kobject kobj;	/* For sysfs */
 	struct work_struct kobj_remove_work;

_