remotealloc: can_dequeue needs both domesticators

If we're running with the freelist_backward_edge mitigation turned on, then
we're going to follow the pointer, not just de-obfuscate it (in freelist's
atomic_read_next), so even if the queue heads are tame, we still need to
do this domestication.
This commit is contained in:
Nathaniel Wesley Filardo
2023-11-12 00:06:41 +00:00
committed by Nathaniel Filardo
parent fffc9453bc
commit 24b79264df
2 changed files with 21 additions and 14 deletions

View File

@@ -450,19 +450,25 @@ namespace snmalloc
*/
SNMALLOC_FAST_PATH bool has_messages()
{
auto domesticate = [local_state = backend_state_ptr()](
freelist::QueuePtr p) SNMALLOC_FAST_PATH_LAMBDA {
if constexpr (Config::Options.QueueHeadsAreTame)
{
return freelist::HeadPtr::unsafe_from(p.unsafe_ptr());
}
else
{
auto local_state = backend_state_ptr();
auto domesticate_head =
[local_state](freelist::QueuePtr p) SNMALLOC_FAST_PATH_LAMBDA {
if constexpr (Config::Options.QueueHeadsAreTame)
{
UNUSED(local_state);
return freelist::HeadPtr::unsafe_from(p.unsafe_ptr());
}
else
{
return capptr_domesticate<Config>(local_state, p);
}
};
auto domesticate_queue =
[local_state](freelist::QueuePtr p) SNMALLOC_FAST_PATH_LAMBDA {
return capptr_domesticate<Config>(local_state, p);
}
};
};
return message_queue().can_dequeue(domesticate);
return message_queue().can_dequeue(domesticate_head, domesticate_queue);
}
/**

View File

@@ -87,11 +87,12 @@ namespace snmalloc
return fnt;
}
template<typename Domesticator_head>
inline bool can_dequeue(Domesticator_head domesticate_head)
template<typename Domesticator_head, typename Domesticator_queue>
inline bool can_dequeue(
Domesticator_head domesticate_head, Domesticator_queue domesticate_queue)
{
return domesticate_head(front.load())
->atomic_read_next(key_global, domesticate_head) != nullptr;
->atomic_read_next(key_global, domesticate_queue) != nullptr;
}
/**