binfmt/loadable: move binary_s to stack to avoid access allocator
Improve performance by reducing allocator accesses Signed-off-by: chao an <anchao@lixiang.com>
This commit is contained in:
parent
5abcc49789
commit
c6dfdbad41
1 changed files with 10 additions and 8 deletions
|
@ -84,16 +84,22 @@ static int exec_internal(FAR const char *filename,
|
|||
irqstate_t flags;
|
||||
int pid;
|
||||
int ret;
|
||||
#ifndef CONFIG_BINFMT_LOADABLE
|
||||
struct binary_s sbin;
|
||||
|
||||
bin = &sbin;
|
||||
#else
|
||||
|
||||
/* Allocate the load information */
|
||||
|
||||
bin = kmm_zalloc(sizeof(struct binary_s));
|
||||
if (!bin)
|
||||
if (bin == NULL)
|
||||
{
|
||||
berr("ERROR: Failed to allocate binary_s\n");
|
||||
ret = -ENOMEM;
|
||||
goto errout;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Load the module into memory */
|
||||
|
||||
|
@ -154,15 +160,9 @@ static int exec_internal(FAR const char *filename,
|
|||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: Failed to schedule unload '%s': %d\n", filename, ret);
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
#else
|
||||
/* Free the binary_s structure here */
|
||||
|
||||
kmm_free(bin);
|
||||
|
||||
/* TODO: How does the module get unloaded in this case? */
|
||||
|
||||
#endif
|
||||
|
||||
sched_unlock();
|
||||
|
@ -174,8 +174,10 @@ errout_with_lock:
|
|||
leave_critical_section(flags);
|
||||
unload_module(bin);
|
||||
errout_with_bin:
|
||||
#ifdef CONFIG_BINFMT_LOADABLE
|
||||
kmm_free(bin);
|
||||
errout:
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue