[prev in list] [next in list] [prev in thread] [next in thread] 

List:       serusers
Subject:    Re: [SR-Users] What is the alignment of shm_malloc and friends?
From:       Richard Chan <shihping.chan () gmail ! com>
Date:       2022-06-22 0:25:12
Message-ID: CAHonLzhW+fPX7yMHJU6yHQJaqvyHk6r2BmabiYvZoAVMye=RtQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hello Daniel,

On Mon, 20 Jun 2022 at 19:09, Daniel-Constantin Mierla <miconda@gmail.com>
wrote:

> Hello,
>
> iirc, the alignment is to sizeof(void*), which is 8.
>

The qm allocator naturally returns 16-byte aligned memory. However the
definition
of DBG_SR_MEMORY(from 'make cfg' with all the defaults.) causes 16 to drop
to 8.

Is this intentional?

Regards
S-P
//qm naturally aligns on 16 bytes without DBG_QM_MALLOC!

#ifdef DBG_QM_MALLOC
#if defined(__CPU_sparc64) || defined(__CPU_sparc)
/* tricky, on sun in 32 bits mode long long must be 64 bits aligned
 * but long can be 32 bits aligned => malloc should return long long
 * aligned memory */
        #define ROUNDTO         sizeof(long long)
#else
        #define ROUNDTO         sizeof(void*) /* minimum possible ROUNDTO

    * ->heavy debugging*/
#endif
#else /* DBG_QM_MALLOC */
        #define ROUNDTO         16UL /* size we round to, must be = 2^n
 and also
                                                        *
sizeof(qm_frag)+sizeof(qm_frag_end)
                                                        * must be multiple
of ROUNDTO!
                                                        */
#endif

[Attachment #5 (text/html)]

<div dir="ltr"><div dir="ltr"><div>Hello Daniel, <br></div><div><div dir="ltr" \
class="gmail_attr"><br></div><div dir="ltr" class="gmail_attr">On Mon, 20 Jun 2022 at \
19:09, Daniel-Constantin Mierla &lt;<a \
href="mailto:miconda@gmail.com">miconda@gmail.com</a>&gt; wrote:<br></div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">Hello,<br> <br>
iirc, the alignment is to sizeof(void*), which is 8.<br>
</blockquote></div><div><br></div><div>The qm allocator naturally returns 16-byte \
aligned memory. However the definition <br></div><div>of DBG_SR_MEMORY(from &#39;make \
cfg&#39; with all the defaults.) causes 16 to drop to 8.<br><br></div><div>Is this \
intentional?</div><div><br></div><div>Regards</div><div>S-P<br></div><div>//qm \
naturally aligns on 16 bytes without \
DBG_QM_MALLOC!<br></div><div><br></div><div>#ifdef DBG_QM_MALLOC<br>#if \
defined(__CPU_sparc64) || defined(__CPU_sparc)<br>/* tricky, on sun in 32 bits mode \
long long must be 64 bits aligned<br>  * but long can be 32 bits aligned =&gt; malloc \
should return long long<br>  * aligned memory */<br>            #define ROUNDTO       \
sizeof(long long)<br>#else<br>            #define ROUNDTO             sizeof(void*) \
/* minimum possible ROUNDTO<br>                                                       \
* -&gt;heavy debugging*/<br>#endif<br>#else /* DBG_QM_MALLOC */<br>            \
#define ROUNDTO             16UL /* size we round to, must be = 2^n   and also<br>    \
* sizeof(qm_frag)+sizeof(qm_frag_end)<br>                                             \
* must be multiple of ROUNDTO!<br>                                                    \
*/<br>#endif<br><br><br><br></div></div><br><div class="gmail_quote"><br></div></div>



__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic