<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><DIV style="LINE-HEIGHT: 1.7; FONT-FAMILY: arial; COLOR: #000000; FONT-SIZE: 14px">
<DIV>hi,</DIV>
<DIV>    all</DIV>
<DIV>    I'm confused with some code about mempool:    </DIV>
<DIV>    </DIV>
<DIV>    <SPAN style="COLOR: #880000">rte_mempool.h   ( lib/ librte_mempool ,about line 668)</SPAN> </DIV>
<DIV>    rte_mempool_mp_put_bulk();   //put serveral objects back in the mempool(multi-producers safe)</DIV>
<DIV>
<DIV>    rte_mempool_sp_put_bulk();   //put serveral objects back in the mempool(NOT multi-producers safe)</DIV>
<DIV> </DIV>
<DIV>    <SPAN style="COLOR: #880000">rte_mempool.h   ( lib/ librte_mempool ,about line 563) </SPAN></DIV>
<DIV><SPAN style="COLOR: #880000"></SPAN>    __mempool_put_bulk()</DIV>
<DIV>    { </DIV>
<DIV>         ......</DIV>
<DIV>         if(unlikely(cache_size==0 || is_mp==0))  <SPAN style="COLOR: #880000"> </SPAN></DIV>
<DIV><SPAN style="COLOR: #880000"></SPAN><SPAN style="COLOR: #880000"></SPAN>               goto ring_enqueue;</DIV>
<DIV>         ......</DIV>
<DIV>         //add in cache while there is enough room</DIV>
<DIV>        while(cache_add_count>0) {</DIV>
<DIV>             cache_objs[cache_len]=*obj_table;</DIV>
<DIV>             obj_table++;</DIV>
<DIV>             cache_len++;</DIV>
<DIV>             n--;</DIV>
<DIV>             cache_add_count--;</DIV>
<DIV>        }</DIV>
<DIV>             ......</DIV>
<DIV>       ring_enqueue:</DIV>
<DIV>        ......</DIV>
<DIV>       if(is_mp)</DIV>
<DIV>            rte_ring_mp_enqueue_bulk();</DIV>
<DIV>       else</DIV>
<DIV>            rte_ring_sp_enqueue_bulk();</DIV>
<DIV>        ......</DIV>
<DIV>    }</DIV>
<DIV> </DIV>
<DIV>    My question is :rte_mempool_mp_put_bulk() and rte_mempool_sp_put_bulk() call the same function  __mempool_put_bulk() with different "is_mp" value. If is_mp=1, that is ,multi-producer, the code will add these objects in cache while there is enough room, when two thread enqueue objects at the same time, isn't it unsafe?but the annotation show this function is "multi-producer safe".</DIV>
<DIV>    Another question: how many thread we can have on a core? just one?</DIV>
<DIV> </DIV>
<DIV>    Any help will be appreciate!</DIV>
<DIV>    Regards</DIV>
<DIV>Maria</DIV></DIV></DIV></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>