module: cleanup call chain.
Fold alloc_module_percpu into percpu_modalloc(). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
8d8022e8ab
commit
9eb76d7797
1 changed files with 16 additions and 19 deletions
|
@ -482,23 +482,28 @@ static inline void __percpu *mod_percpu(struct module *mod)
|
||||||
return mod->percpu;
|
return mod->percpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int percpu_modalloc(struct module *mod,
|
static int percpu_modalloc(struct module *mod, struct load_info *info)
|
||||||
unsigned long size, unsigned long align)
|
|
||||||
{
|
{
|
||||||
|
Elf_Shdr *pcpusec = &info->sechdrs[info->index.pcpu];
|
||||||
|
unsigned long align = pcpusec->sh_addralign;
|
||||||
|
|
||||||
|
if (!pcpusec->sh_size)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (align > PAGE_SIZE) {
|
if (align > PAGE_SIZE) {
|
||||||
printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
|
printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
|
||||||
mod->name, align, PAGE_SIZE);
|
mod->name, align, PAGE_SIZE);
|
||||||
align = PAGE_SIZE;
|
align = PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mod->percpu = __alloc_reserved_percpu(size, align);
|
mod->percpu = __alloc_reserved_percpu(pcpusec->sh_size, align);
|
||||||
if (!mod->percpu) {
|
if (!mod->percpu) {
|
||||||
printk(KERN_WARNING
|
printk(KERN_WARNING
|
||||||
"%s: Could not allocate %lu bytes percpu data\n",
|
"%s: Could not allocate %lu bytes percpu data\n",
|
||||||
mod->name, size);
|
mod->name, (unsigned long)pcpusec->sh_size);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
mod->percpu_size = size;
|
mod->percpu_size = pcpusec->sh_size;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,10 +568,12 @@ static inline void __percpu *mod_percpu(struct module *mod)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
static inline int percpu_modalloc(struct module *mod,
|
static int percpu_modalloc(struct module *mod, struct load_info *info)
|
||||||
unsigned long size, unsigned long align)
|
|
||||||
{
|
{
|
||||||
return -ENOMEM;
|
/* UP modules shouldn't have this section: ENOMEM isn't quite right */
|
||||||
|
if (info->sechdrs[info->index.pcpu].sh_size != 0)
|
||||||
|
return -ENOMEM;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
static inline void percpu_modfree(struct module *mod)
|
static inline void percpu_modfree(struct module *mod)
|
||||||
{
|
{
|
||||||
|
@ -2976,16 +2983,6 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
|
||||||
return mod;
|
return mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int alloc_module_percpu(struct module *mod, struct load_info *info)
|
|
||||||
{
|
|
||||||
Elf_Shdr *pcpusec = &info->sechdrs[info->index.pcpu];
|
|
||||||
if (!pcpusec->sh_size)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* We have a special allocation for this section. */
|
|
||||||
return percpu_modalloc(mod, pcpusec->sh_size, pcpusec->sh_addralign);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* mod is no longer valid after this! */
|
/* mod is no longer valid after this! */
|
||||||
static void module_deallocate(struct module *mod, struct load_info *info)
|
static void module_deallocate(struct module *mod, struct load_info *info)
|
||||||
{
|
{
|
||||||
|
@ -3260,7 +3257,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* To avoid stressing percpu allocator, do this once we're unique. */
|
/* To avoid stressing percpu allocator, do this once we're unique. */
|
||||||
err = alloc_module_percpu(mod, info);
|
err = percpu_modalloc(mod, info);
|
||||||
if (err)
|
if (err)
|
||||||
goto unlink_mod;
|
goto unlink_mod;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue