timer: fix resource leak in finalize
authorAnatoly Burakov <anatoly.burakov@intel.com>
Fri, 5 Jul 2019 17:22:44 +0000 (18:22 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Sat, 6 Jul 2019 08:32:40 +0000 (10:32 +0200)
commitf9d6cd8bfe9e1183209098bb82542b34d23dc0ed
tree0bf9fe5d2fa2c3734eae0b301207c385890a8b3c
parentae3b4bc4fb9ca179eac5c4c9b51b4853b3afe7c7
timer: fix resource leak in finalize

Currently, whenever timer library is initialized, the memory
is leaked because there is no telling when primary or secondary
processes get to use the state, and there is no way to
initialize/deinitialize timer library state without race
conditions [1] because the data itself must live in shared memory.

Add a spinlock to the shared mem config to have a way to
exclusively initialize/deinitialize the timer library without
any races, and implement the synchronization mechanism based
on this lock in the timer library.

Also, update the API doc. Note that the behavior of the API
itself did not change - the requirement to call init in every
process was simply not documented explicitly.

[1] See the following email thread:
https://mails.dpdk.org/archives/dev/2019-May/131498.html

Fixes: c0749f7096c7 ("timer: allow management in shared memory")
Cc: stable@dpdk.org
Signed-off-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
lib/librte_eal/common/eal_common_mcfg.c
lib/librte_eal/common/eal_memcfg.h
lib/librte_eal/common/include/rte_eal_memconfig.h
lib/librte_eal/rte_eal_version.map
lib/librte_timer/rte_timer.c
lib/librte_timer/rte_timer.h