On 07/24/2017 07:12 PM, John Ferlan wrote:
On 07/19/2017 10:31 AM, Michal Privoznik wrote:
> We already have virRWLockInit. But this uses pthread defaults
> which prefer reader to initialize the RW lock. This may lead to
> writer starvation. Therefore we need to have the counterpart that
> prefers writers. Now, according to the
> pthread_rwlockattr_setkind_np() man page setting
> PTHREAD_RWLOCK_PREFER_WRITER_NP attribute is no-op. Therefore we
> need to use PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
> attribute. So much for good enum value names.
>
> Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
> ---
> src/libvirt_private.syms | 1 +
> src/util/virthread.c | 35 +++++++++++++++++++++++++++++++++++
> src/util/virthread.h | 1 +
> 3 files changed, 37 insertions(+)
>
This has broken the CI build, freebsd is not happy:
../../src/util/virthread.c:133:42: error: use of undeclared identifier
'PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP'
pthread_rwlockattr_setkind_np(&attr,
PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
^
1 error generated.
John
You know what my suggestion is ;-)
Actually, I don't. I am trying to search freebsd documentation on
initializing RW locks so that they prefer writers. But no luck so far.
Does anybody here on the list know? Although, for the current usage of
RW locks it's really hard to starve a writer. But if this is going to be
used more broadly it is going to be easier. On the other hand, I just
realized that while one can use mutexes + conditions (like we do for
domain jobs), using RW locks and conditions is not implemented anywhere,
so I will have to come up with some idea.
Long story short, for now we don't care if writer will starve.
Michal