Jon Kohler has uploaded this change for review. (
https://review.gerrithub.io/c/ffilz/nfs-ganesha/+/1176505?usp=email )
Change subject: use may_write == false in nfs4_State_Get_Pointer
......................................................................
use may_write == false in nfs4_State_Get_Pointer
nfs4_State_Get_Pointer suffers from writer lock contention on the
hashtable_getlatch() calls, as it uses may_write == true to procure
the latch and subsequently increment the state_t refcount. This lock
contention appears to get worse with the glibc libpthread implementation
in el8 and higher; however, this contention points out an opportunity
for optimization.
nfs4_State_Get_Pointer is not mutating set or delete into the hashtable
data structures but rather using that as a means to do an atomic
increment on the state_t reference. Given that the state_t reference
has its own thread safety design, switch the hashtable_getlatch() to
may_write == false and modify hashtable_getlatch() to allow may_write &&
latch together.
This allows getlatch to return with the read lock held, guaranteeing
that no writers can come along and invalidate the state that was
retrieved.
Furthermore, all mutations (i.e. decrements) to state_t refcount are
protected by the higher order calls to getlatch with may_write == true,
which gaurantees that the follow on read and decrement of the refcount
can be done in a thread safe manner.
Change-Id: I47d59e2e31420d425eee0d5cdcbf65f8a8caa87e
Change-Id: Ie36c71bcdcfab237536f6a6c94fcfe18d0af9d3d
Signed-off-by: Jon Kohler <jon(a)nutanix.com>
---
M src/SAL/nfs4_state_id.c
M src/hashtable/hashtable.c
2 files changed, 17 insertions(+), 6 deletions(-)
git pull ssh://review.gerrithub.io:29418/ffilz/nfs-ganesha refs/changes/05/1176505/1
--
To view, visit
https://review.gerrithub.io/c/ffilz/nfs-ganesha/+/1176505?usp=email
To unsubscribe, or for help writing mail filters, visit
https://review.gerrithub.io/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: ffilz/nfs-ganesha
Gerrit-Branch: next
Gerrit-Change-Id: Ie36c71bcdcfab237536f6a6c94fcfe18d0af9d3d
Gerrit-Change-Number: 1176505
Gerrit-PatchSet: 1
Gerrit-Owner: Jon Kohler <jon(a)nutanix.com>