From df64a297abaf382d21aedbf7bf8b8e52e1c774a5 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Sun, 10 Jun 2018 18:46:11 +0800 Subject: [PATCH] [Kernel] Remove memory ops when SLAB and module enable --- src/idle.c | 10 ++-------- src/ipc.c | 22 ++++------------------ src/mempool.c | 11 ++--------- src/module.c | 24 ------------------------ src/object.c | 10 ++-------- src/slab.c | 19 ------------------- 6 files changed, 10 insertions(+), 86 deletions(-) diff --git a/src/idle.c b/src/idle.c index 88415e4e21..f636d0fd4c 100644 --- a/src/idle.c +++ b/src/idle.c @@ -164,14 +164,8 @@ void rt_thread_idle_excute(void) rt_hw_interrupt_enable(lock); #ifdef RT_USING_HEAP -#if defined(RT_USING_MODULE) && defined(RT_USING_SLAB) - /* the thread belongs to an application module */ - if (thread->flags & RT_OBJECT_FLAG_MODULE) - rt_module_free((rt_module_t)thread->module_id, thread->stack_addr); - else -#endif - /* release thread's stack */ - RT_KERNEL_FREE(thread->stack_addr); + /* release thread's stack */ + RT_KERNEL_FREE(thread->stack_addr); /* delete thread object */ rt_object_delete((rt_object_t)thread); #endif diff --git a/src/ipc.c b/src/ipc.c index 5aed193996..055c8cb2e4 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -1380,15 +1380,8 @@ rt_err_t rt_mb_delete(rt_mailbox_t mb) /* also resume all mailbox private suspended thread */ rt_ipc_list_resume_all(&(mb->suspend_sender_thread)); -#if defined(RT_USING_MODULE) && defined(RT_USING_SLAB) - /* the mb object belongs to an application module */ - if (mb->parent.parent.flag & RT_OBJECT_FLAG_MODULE) - rt_module_free(mb->parent.parent.module_id, mb->msg_pool); - else -#endif - - /* free mailbox pool */ - RT_KERNEL_FREE(mb->msg_pool); + /* free mailbox pool */ + RT_KERNEL_FREE(mb->msg_pool); /* delete mailbox object */ rt_object_delete(&(mb->parent.parent)); @@ -1900,15 +1893,8 @@ rt_err_t rt_mq_delete(rt_mq_t mq) /* resume all suspended thread */ rt_ipc_list_resume_all(&(mq->parent.suspend_thread)); -#if defined(RT_USING_MODULE) && defined(RT_USING_SLAB) - /* the mq object belongs to an application module */ - if (mq->parent.parent.flag & RT_OBJECT_FLAG_MODULE) - rt_module_free(mq->parent.parent.module_id, mq->msg_pool); - else -#endif - - /* free message queue pool */ - RT_KERNEL_FREE(mq->msg_pool); + /* free message queue pool */ + RT_KERNEL_FREE(mq->msg_pool); /* delete message queue object */ rt_object_delete(&(mq->parent.parent)); diff --git a/src/mempool.c b/src/mempool.c index 5d80d66533..3f95279ed1 100644 --- a/src/mempool.c +++ b/src/mempool.c @@ -292,15 +292,8 @@ rt_err_t rt_mp_delete(rt_mp_t mp) rt_hw_interrupt_enable(temp); } -#if defined(RT_USING_MODULE) && defined(RT_USING_SLAB) - /* the mp object belongs to an application module */ - if (mp->parent.flag & RT_OBJECT_FLAG_MODULE) - rt_module_free(mp->parent.module_id, mp->start_address); - else -#endif - - /* release allocated room */ - rt_free(mp->start_address); + /* release allocated room */ + rt_free(mp->start_address); /* detach object */ rt_object_delete(&(mp->parent)); diff --git a/src/module.c b/src/module.c index ce9931db3c..843b3364a9 100644 --- a/src/module.c +++ b/src/module.c @@ -65,30 +65,6 @@ #define RT_USING_MODULE_PRIO (RT_THREAD_PRIORITY_MAX - 2) #endif -#ifdef RT_USING_SLAB -#define PAGE_COUNT_MAX 256 - -/* module memory allocator */ -struct rt_mem_head -{ - rt_size_t size; /* size of memory block */ - struct rt_mem_head *next; /* next valid memory block */ -}; - -struct rt_page_info -{ - rt_uint32_t *page_ptr; - rt_uint32_t npage; -}; - -static void *rt_module_malloc_page(rt_size_t npages); -static void rt_module_free_page(rt_module_t module, - void *page_ptr, - rt_size_t npages); - -static struct rt_semaphore mod_sem; -#endif - static struct rt_module_symtab *_rt_module_symtab_begin = RT_NULL; static struct rt_module_symtab *_rt_module_symtab_end = RT_NULL; diff --git a/src/object.c b/src/object.c index b2c604664c..958161e320 100644 --- a/src/object.c +++ b/src/object.c @@ -387,14 +387,8 @@ void rt_object_delete(rt_object_t object) /* unlock interrupt */ rt_hw_interrupt_enable(temp); -#if defined(RT_USING_MODULE) && defined(RT_USING_SLAB) - if (object->flag & RT_OBJECT_FLAG_MODULE) - rt_module_free((rt_module_t)object->module_id, object); - else -#endif - - /* free the memory of object */ - RT_KERNEL_FREE(object); + /* free the memory of object */ + RT_KERNEL_FREE(object); } #endif diff --git a/src/slab.c b/src/slab.c index 5e6a204896..16c68a2408 100644 --- a/src/slab.c +++ b/src/slab.c @@ -496,11 +496,6 @@ void *rt_malloc(rt_size_t size) if (size == 0) return RT_NULL; -#ifdef RT_USING_MODULE - if (rt_module_self() != RT_NULL) - return rt_module_malloc(size); -#endif - /* * Handle large allocations directly. There should not be very many of * these so performance is not a big issue. @@ -705,11 +700,6 @@ void *rt_realloc(void *ptr, rt_size_t size) return RT_NULL; } -#ifdef RT_USING_MODULE - if (rt_module_self() != RT_NULL) - return rt_module_realloc(ptr, size); -#endif - /* * Get the original allocation's zone. If the new request winds up * using the same chunk size we do not have to do anything. @@ -800,15 +790,6 @@ void rt_free(void *ptr) RT_OBJECT_HOOK_CALL(rt_free_hook, (ptr)); -#ifdef RT_USING_MODULE - if (rt_module_self() != RT_NULL) - { - rt_module_free(rt_module_self(), ptr); - - return; - } -#endif - /* get memory usage */ #if RT_DEBUG_SLAB { -- GitLab