Module: xenomai-3
Branch: stable-3.0.x
Commit: 7a038dfad8d1e48b065542c8cc2e39f6b5ee4f82
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7a038dfad8d1e48b065542c8cc2e39f6b5ee4f82

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sat Nov 25 11:53:06 2017 +0100

copperplate/heapobj-tlsf: fix private heap init

TLSF's init_memory_pool() wants heaps to be larger than 4k on 64bit
architectures, due to the increased size of the meta-data compared to
their 32bit counterpart (struct tlsf).

Use 8k as the minimum heap size instead of PAGE_SIZE in the pshared
case, and make sure the main pool size amounts to at least 8k in the
process-private case, so that init_memory_pool() never fails in
heapobj_pkg_init_private().

---

 lib/boilerplate/tlsf/tlsf.h    |    3 +++
 lib/copperplate/heapobj-tlsf.c |   14 ++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/lib/boilerplate/tlsf/tlsf.h b/lib/boilerplate/tlsf/tlsf.h
index 38e4243..766b992 100644
--- a/lib/boilerplate/tlsf/tlsf.h
+++ b/lib/boilerplate/tlsf/tlsf.h
@@ -21,6 +21,9 @@
 
 #include <sys/types.h>
 
+/* A basic heap size which won't be rejected by init_memory_pool(). */
+#define MIN_TLSF_HEAPSZ 8192
+
 extern size_t init_memory_pool(size_t, void *);
 extern size_t get_used_size(void *);
 extern size_t get_max_size(void *);
diff --git a/lib/copperplate/heapobj-tlsf.c b/lib/copperplate/heapobj-tlsf.c
index 3709852..2f5be4c 100644
--- a/lib/copperplate/heapobj-tlsf.c
+++ b/lib/copperplate/heapobj-tlsf.c
@@ -77,14 +77,16 @@ int heapobj_init_array_private(struct heapobj *hobj, const 
char *name,
 
 int heapobj_pkg_init_private(void)
 {
-       #ifdef CONFIG_XENO_PSHARED
-               size_t alloc_size = sysconf(_SC_PAGE_SIZE);
-       #else
-               size_t alloc_size = __copperplate_setup_data.mem_pool;
-       #endif
-       size_t available_size;
+       size_t alloc_size, available_size;
        void *mem;
 
+#ifdef CONFIG_XENO_PSHARED
+       alloc_size = MIN_TLSF_HEAPSZ;
+#else
+       alloc_size = __copperplate_setup_data.mem_pool;
+       if (alloc_size < MIN_TLSF_HEAPSZ)
+               alloc_size = MIN_TLSF_HEAPSZ;
+#endif
        /*
         * We want to know how many bytes from a memory pool TLSF will
         * use for its own internal use. We get the probe memory from


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to