Re: [EXTERNAL] [vpp-dev] Multi-threading locks and synchronization

2021-07-15 Thread satish amara
Thank you guidance on this topic. Is there good documentation on API usage?
VPPINFRA (Infrastructure) — Vector Packet Processor 01 documentation
(fdio-vpp.readthedocs.io)

This info is too little to understand all the semantics.

On Tue, Jul 13, 2021 at 3:39 PM Damjan Marion  wrote:

>
>
> > On 13.07.2021., at 18:41, satish amara  wrote:
> >
> > Sync is needed. It's a question about the design of packet flow in  VPP.
> Locks can be avoided if the packets in a flow are processed by the same
> thread.
>
> You can use the handoff to make sure all packets belonging to specific
> flow or session end up on the same thread.
>
> You can use bihash to store both thread_index and per-thread flow/session
> index in hash result. Bihash have per-bucket locks so it is safe to use
> single hash table from different workers.
>
> After lookup you can simply compare lookup result thread_index with
> current thread index. if they are different you simply handoff packet to
> other thread, if they are the same you continue processing packets on the
> same thread.
>
> After that you can build all your data structures as per-thread and avoid
> locking or atomics.
>
> —
> Damjan
>
>
>

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#19788): https://lists.fd.io/g/vpp-dev/message/19788
Mute This Topic: https://lists.fd.io/mt/84186832/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [EXTERNAL] [vpp-dev] Multi-threading locks and synchronization

2021-07-13 Thread Damjan Marion via lists.fd.io


> On 13.07.2021., at 18:41, satish amara  wrote:
> 
> Sync is needed. It's a question about the design of packet flow in  VPP. 
> Locks can be avoided if the packets in a flow are processed by the same 
> thread.  

You can use the handoff to make sure all packets belonging to specific flow or 
session end up on the same thread.

You can use bihash to store both thread_index and per-thread flow/session index 
in hash result. Bihash have per-bucket locks so it is safe to use single hash 
table from different workers.

After lookup you can simply compare lookup result thread_index with current 
thread index. if they are different you simply handoff packet to other thread, 
if they are the same you continue processing packets on the same thread.

After that you can build all your data structures as per-thread and avoid 
locking or atomics.

— 
Damjan



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#19761): https://lists.fd.io/g/vpp-dev/message/19761
Mute This Topic: https://lists.fd.io/mt/84186832/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-