Skip to content

Commit f1797e4

Browse files
chleroympe
authored andcommitted
powerpc/modules: Don't WARN on first module allocation attempt
module_alloc() first tries to allocate module text within 24 bits direct jump from kernel text, and tries a wider allocation if first one fails. When first allocation fails the following is observed in kernel logs: vmap allocation for size 2400256 failed: use vmalloc=<size> to increase size systemd-udevd: vmalloc error: size 2395133, vm_struct allocation failed, mode:0xcc0(GFP_KERNEL), nodemask=(null) CPU: 0 PID: 127 Comm: systemd-udevd Tainted: G W 5.15.5-gentoo-PowerMacG4 #9 Call Trace: [e2a53a50] [c0ba0048] dump_stack_lvl+0x80/0xb0 (unreliable) [e2a53a70] [c0540128] warn_alloc+0x11c/0x2b4 [e2a53b50] [c0531be8] __vmalloc_node_range+0xd8/0x64c [e2a53c10] [c00338c0] module_alloc+0xa0/0xac [e2a53c40] [c027a368] load_module+0x2ae0/0x8148 [e2a53e30] [c027fc78] sys_finit_module+0xfc/0x130 [e2a53f30] [c0035098] ret_from_syscall+0x0/0x28 ... Add __GFP_NOWARN flag to first allocation so that no warning appears when it fails. Reported-by: Erhard Furtner <[email protected]> Fixes: 2ec13df ("powerpc/modules: Load modules closer to kernel text") Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/93c9b84d6ec76aaf7b4f03468e22433a6d308674.1638267035.git.christophe.leroy@csgroup.eu
1 parent 5402e23 commit f1797e4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

arch/powerpc/kernel/module.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,17 @@ int module_finalize(const Elf_Ehdr *hdr,
9090
}
9191

9292
static __always_inline void *
93-
__module_alloc(unsigned long size, unsigned long start, unsigned long end)
93+
__module_alloc(unsigned long size, unsigned long start, unsigned long end, bool nowarn)
9494
{
9595
pgprot_t prot = strict_module_rwx_enabled() ? PAGE_KERNEL : PAGE_KERNEL_EXEC;
96+
gfp_t gfp = GFP_KERNEL | (nowarn ? __GFP_NOWARN : 0);
9697

9798
/*
9899
* Don't do huge page allocations for modules yet until more testing
99100
* is done. STRICT_MODULE_RWX may require extra work to support this
100101
* too.
101102
*/
102-
return __vmalloc_node_range(size, 1, start, end, GFP_KERNEL, prot,
103+
return __vmalloc_node_range(size, 1, start, end, gfp, prot,
103104
VM_FLUSH_RESET_PERMS | VM_NO_HUGE_VMAP,
104105
NUMA_NO_NODE, __builtin_return_address(0));
105106
}
@@ -114,13 +115,13 @@ void *module_alloc(unsigned long size)
114115

115116
/* First try within 32M limit from _etext to avoid branch trampolines */
116117
if (MODULES_VADDR < PAGE_OFFSET && MODULES_END > limit)
117-
ptr = __module_alloc(size, limit, MODULES_END);
118+
ptr = __module_alloc(size, limit, MODULES_END, true);
118119

119120
if (!ptr)
120-
ptr = __module_alloc(size, MODULES_VADDR, MODULES_END);
121+
ptr = __module_alloc(size, MODULES_VADDR, MODULES_END, false);
121122

122123
return ptr;
123124
#else
124-
return __module_alloc(size, VMALLOC_START, VMALLOC_END);
125+
return __module_alloc(size, VMALLOC_START, VMALLOC_END, false);
125126
#endif
126127
}

0 commit comments

Comments
 (0)