Skip to contentSkip to conversation

module: remove the SHF_ALLOC flag on the __versions section.

PATCH In review Rusty Russell 1 participant 1 message Feb 7, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 9/9 module: remove the SHF_ALLOC flag on the __versions section.

Impact: reduce kernel memory usage

This patch just takes off the SHF_ALLOC flag on __versions so we don't keep them around after module load.

This saves about 7% of module memory if CONFIG_MODVERSIONS=y.

---
 kernel/module.c |    3 +++
 1 file changed, 3 insertions(+)
kernel/module.c +3 -0
@@ -1928,6 +1928,9 @@ static noinline struct module *load_modu
 		if (strstarts(secstrings+sechdrs[i].sh_name, ".exit"))
 			sechdrs[i].sh_flags &= ~(unsigned long)SHF_ALLOC;
 #endif
+		/* Don't keep __versions around; it's just for loading. */
+		if (strcmp(secstrings + sechdrs[i].sh_name, "__versions") == 0)
+			sechdrs[i].sh_flags &= ~(unsigned long)SHF_ALLOC;
 	}
 
 	modindex = find_sec(hdr, sechdrs, secstrings,