>
> Thanks a lot for your replay.
> I am sorry for the bad experience in reading my last letter.
> I rewrite the letter below.
>
> The question i met is when i enabled --enable-pshared  option in compiling
>  the xenomai-v3.1.
>
> In the source code https://gitlab.denx.de/Xenomai/xenomai/-/blob/v3.1/lib/
> boilerplate/heapmem.c  line:607,notes that"overhead memory we need for
> storing our metadata as calculated by HEAPMEM_ARENA_SIZE()".
>
> To simplify the problem,I ignore the alignment.
> Since the HEAPMEM_ARENA_SIZE macro in code, we can draw the conclusion
> HEAPMEM_ARENA_SIZE(size)=__size+sizeof(struct heapmem_extent)+
> (__size/HEAPMEM_PAGE_SIZE)*HEAPMEM_PGMAP_BYTES
>
> So, the overhead i think is:
> overhead = HEAPMEM_ARENA_SIZE(size)-size = sizeof(struct heapmem_extent)+
> (__size/HEAPMEM_PAGE_SIZE)*HEAPMEM_PGMAP_BYTES
>
> Note: "__size/HEAPMEM_PAGE_SIZE" equals to
>  "__size>> HEAPMEM_PAGE_SHIFT"(which is the orignal code)
>
> If i use the representation explained in the source code(see heapmem.c,the
> representation is listed below), then
>  overhead = o = e+(a*p)/m
>  It's not equals to the calculation in the source(see heapmem.c,url list
>  above), which is
>           o = ((a * m + e * p) / (p + m))
>
>  @representation explained in source code(the whole source code is listed
>  below)
>    * o = overhead
>    * e = sizeof(heapmem_extent)
>    * p = HEAPMEM_PAGE_SIZE
>    * m = HEAPMEM_PGMAP_BYTES  =sizeof(struct heapmem_pgentry)
>
>
> @source code of macro HEAPMEM_ARENA_SIZE
> @see https://gitlab.denx.de/Xenomai/xenomai/-/blob/v3.1/include/
> boilerplate/heapmem.h line: 95-110
> #define __HEAPMEM_MAP_SIZE(__nrpages) \
> ((__nrpages) * HEAPMEM_PGMAP_BYTES)
> /*note by myslef :(__size)>>HEAPMEM_PAGE_SHIFT is the number of pages of
> memory pool
>  __HEAPMEM_MAP_SIZE((__size) >> HEAPMEM_PAGE_SHIFT)calculats the memory
> size
>  for storing the struct of heapmem_pgentry。*/
>  #define __HEAPMEM_ARENA_SIZE(__size) \
>  (__size + \
>    __align_to(sizeof(struct heapmem_extent) + \
>       __HEAPMEM_MAP_SIZE((__size) >> HEAPMEM_PAGE_SHIFT), \
>       HEAPMEM_MIN_ALIGN))
>  /*
>  * Calculate the minimal size of the memory arena needed to contain a
>  * heap of __user_size bytes, including our meta data for managing it.
>  * Usable at build time if __user_size is constant.
>  */
> #define HEAPMEM_ARENA_SIZE(__user_size)                 \
>     __HEAPMEM_ARENA_SIZE(__align_to(__user_size, HEAPMEM_PAGE_SIZE))
>
>
>

Reply via email to