[vpp-dev] can the pointer of a used-pool-element change before it's put back ?

2020-05-06 Thread Satya Murthy
Hi,

We are seeing some issue in our plugin that seems to caused by the change of 
pointer for a pool element.

The scenario is as below. Can you please let us know , if this can really occur.

1. We have multiple workers
2. We have one global pool of  custom-structures ( this is a non-fixed pool)
3. This global pool is protected by a lock for addition and deletion.
4. However, it is not protected for reading. So, all workers refer read entries 
from this pool by using pool_elt_at_index()
5. All the workers keep on adding and deleting elements in this pool by taking 
lock.
6. What we are seeing is, the pointer returned by 
pool_elt_at_index(global_pool, index)
is getting changed in between and causing some issue in our logic.

Couple of questions we have is :
1 ) If a pool element is getting used (not-free-element),  Until that element 
is put back again into the pool, can we assume that the address of the element 
remain same and will not get  chagned by pool resizing.

2) Having pools that spans across threads will cause any issues like this while 
reading the elements ( though we protect the pool for add/del of elements using 
a spin lock) ?

--
Thanks & Regards,
Murthy
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#16254): https://lists.fd.io/g/vpp-dev/message/16254
Mute This Topic: https://lists.fd.io/mt/74034826/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [vpp-dev] can the pointer of a used-pool-element change before it's put back ?

2020-05-06 Thread Dave Wallace

From the developer documentation [0]:

"Standard programming error: memorize a pointer to the ith element of a 
vector, and then expand the vector. Vectors expand by 3/2, so such code 
may appear to work for a period of time. Correct code almost always 
memorizes vector indices which are invariant across reallocations."


"Pools
Vppinfra pools combine vectors and bitmaps to rapidly allocate and free 
fixed-size data structures with independent lifetimes. Pools are perfect 
for allocating per-session structures."


Hope this helps,
-daw-

[0] 
https://fdio-vpp.readthedocs.io/en/latest/gettingstarted/developers/infrastructure.html


On 5/6/2020 2:22 PM, Satya Murthy wrote:

Hi,

We are seeing some issue in our plugin that seems to caused by the 
change of pointer for a pool element.


The scenario is as below. Can you please let us know , if this can 
really occur.


1. We have multiple workers
2. We have one global pool of  custom-structures ( this is a non-fixed 
pool)

3. This global pool is protected by a lock for addition and deletion.
4. However, it is not protected for reading. So, all workers refer 
read entries from this pool by using pool_elt_at_index()
5. All the workers keep on adding and deleting elements in this pool 
by taking lock.
6. What we are seeing is, the pointer returned by 
pool_elt_at_index(global_pool, index)

is getting changed in between and causing some issue in our logic.

Couple of questions we have is :
1 ) If a pool element is getting used (not-free-element),  Until that 
element is put back again into the pool, can we assume that the 
address of the element remain same and will not get  chagned by pool 
resizing.


2) Having pools that spans across threads will cause any issues like 
this while reading the elements ( though we protect the pool for 
add/del of elements using a spin lock) ?


--
Thanks & Regards,
Murthy




-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#16256): https://lists.fd.io/g/vpp-dev/message/16256
Mute This Topic: https://lists.fd.io/mt/74034826/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-