mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:07:34 +00:00
Everywhere: Deprecate dbg().
This commit is contained in:
parent
d7345cf560
commit
1c1e577a5e
5 changed files with 51 additions and 48 deletions
12
AK/Debug.h
12
AK/Debug.h
|
@ -573,3 +573,15 @@ constexpr bool debug_lock_restore = true;
|
||||||
#else
|
#else
|
||||||
constexpr bool debug_lock_restore = false;
|
constexpr bool debug_lock_restore = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef FUTEXQUEUE_DEBUG
|
||||||
|
constexpr bool debug_futex_queue = true;
|
||||||
|
#else
|
||||||
|
constexpr bool debug_futex_queue = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef FUTEX_DEBUG
|
||||||
|
constexpr bool debug_futex = true;
|
||||||
|
#else
|
||||||
|
constexpr bool debug_futex = false;
|
||||||
|
#endif
|
||||||
|
|
|
@ -149,7 +149,10 @@ KernelLogStream klog()
|
||||||
#else
|
#else
|
||||||
DebugLogStream klog()
|
DebugLogStream klog()
|
||||||
{
|
{
|
||||||
|
# pragma GCC diagnostic push
|
||||||
|
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
return dbg();
|
return dbg();
|
||||||
|
# pragma GCC diagnostic pop
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ inline const LogStream& operator<<(const LogStream& stream, bool value)
|
||||||
return stream << (value ? "true" : "false");
|
return stream << (value ? "true" : "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugLogStream dbg();
|
[[deprecated("Plase use dbgln in AK/Format.h instead.")]] DebugLogStream dbg();
|
||||||
|
|
||||||
#ifdef KERNEL
|
#ifdef KERNEL
|
||||||
KernelLogStream klog();
|
KernelLogStream klog();
|
||||||
|
|
|
@ -24,11 +24,10 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/Debug.h>
|
||||||
#include <Kernel/FutexQueue.h>
|
#include <Kernel/FutexQueue.h>
|
||||||
#include <Kernel/Thread.h>
|
#include <Kernel/Thread.h>
|
||||||
|
|
||||||
//#define FUTEXQUEUE_DEBUG
|
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
bool FutexQueue::should_add_blocker(Thread::Blocker& b, void* data)
|
bool FutexQueue::should_add_blocker(Thread::Blocker& b, void* data)
|
||||||
|
@ -36,9 +35,9 @@ bool FutexQueue::should_add_blocker(Thread::Blocker& b, void* data)
|
||||||
ASSERT(data != nullptr); // Thread that is requesting to be blocked
|
ASSERT(data != nullptr); // Thread that is requesting to be blocked
|
||||||
ASSERT(m_lock.is_locked());
|
ASSERT(m_lock.is_locked());
|
||||||
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
|
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
|
||||||
#ifdef FUTEXQUEUE_DEBUG
|
|
||||||
dbg() << "FutexQueue @ " << this << ": should block thread " << *static_cast<Thread*>(data);
|
dbgln<debug_futex_queue>("FutexQueue @ {}: should block thread {}", this, *static_cast<Thread*>(data));
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,17 +45,16 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
|
||||||
{
|
{
|
||||||
is_empty_target = false;
|
is_empty_target = false;
|
||||||
ScopedSpinLock lock(m_lock);
|
ScopedSpinLock lock(m_lock);
|
||||||
#ifdef FUTEXQUEUE_DEBUG
|
|
||||||
dbg() << "FutexQueue @ " << this << ": wake_n_requeue(" << wake_count << ", " << requeue_count << ")";
|
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue({}, {})", this, wake_count, requeue_count);
|
||||||
#endif
|
|
||||||
u32 did_wake = 0, did_requeue = 0;
|
u32 did_wake = 0, did_requeue = 0;
|
||||||
do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
|
do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
|
||||||
ASSERT(data);
|
ASSERT(data);
|
||||||
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
|
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
|
||||||
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
|
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
|
||||||
#ifdef FUTEXQUEUE_DEBUG
|
|
||||||
dbg() << "FutexQueue @ " << this << ": wake_n_requeue unblocking " << *static_cast<Thread*>(data);
|
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue unblocking {}", this, *static_cast<Thread*>(data));
|
||||||
#endif
|
|
||||||
ASSERT(did_wake < wake_count);
|
ASSERT(did_wake < wake_count);
|
||||||
if (blocker.unblock()) {
|
if (blocker.unblock()) {
|
||||||
if (++did_wake >= wake_count)
|
if (++did_wake >= wake_count)
|
||||||
|
@ -70,9 +68,8 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
|
||||||
auto blockers_to_requeue = do_take_blockers(requeue_count);
|
auto blockers_to_requeue = do_take_blockers(requeue_count);
|
||||||
if (!blockers_to_requeue.is_empty()) {
|
if (!blockers_to_requeue.is_empty()) {
|
||||||
if (auto* target_futex_queue = get_target_queue()) {
|
if (auto* target_futex_queue = get_target_queue()) {
|
||||||
#ifdef FUTEXQUEUE_DEBUG
|
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue requeueing {} blockers to {}", this, blockers_to_requeue.size(), target_futex_queue);
|
||||||
dbg() << "FutexQueue @ " << this << ": wake_n_requeue requeueing " << blockers_to_requeue.size() << " blockers to " << target_futex_queue;
|
|
||||||
#endif
|
|
||||||
// While still holding m_lock, notify each blocker
|
// While still holding m_lock, notify each blocker
|
||||||
for (auto& info : blockers_to_requeue) {
|
for (auto& info : blockers_to_requeue) {
|
||||||
ASSERT(info.blocker->blocker_type() == Thread::Blocker::Type::Futex);
|
ASSERT(info.blocker->blocker_type() == Thread::Blocker::Type::Futex);
|
||||||
|
@ -94,9 +91,7 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
|
||||||
target_futex_queue->do_append_blockers(move(blockers_to_requeue));
|
target_futex_queue->do_append_blockers(move(blockers_to_requeue));
|
||||||
is_empty_target = target_futex_queue->is_empty_locked();
|
is_empty_target = target_futex_queue->is_empty_locked();
|
||||||
} else {
|
} else {
|
||||||
#ifdef FUTEXQUEUE_DEBUG
|
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue could not get target queue to requeue {} blockers", this, blockers_to_requeue.size());
|
||||||
dbg() << "FutexQueue @ " << this << ": wake_n_requeue could not get target queue to requeueing " << blockers_to_requeue.size() << " blockers";
|
|
||||||
#endif
|
|
||||||
do_append_blockers(move(blockers_to_requeue));
|
do_append_blockers(move(blockers_to_requeue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,17 +104,14 @@ u32 FutexQueue::wake_n(u32 wake_count, const Optional<u32>& bitset, bool& is_emp
|
||||||
if (wake_count == 0)
|
if (wake_count == 0)
|
||||||
return 0; // should we assert instead?
|
return 0; // should we assert instead?
|
||||||
ScopedSpinLock lock(m_lock);
|
ScopedSpinLock lock(m_lock);
|
||||||
#ifdef FUTEXQUEUE_DEBUG
|
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n({})", this, wake_count);
|
||||||
dbg() << "FutexQueue @ " << this << ": wake_n(" << wake_count << ")";
|
|
||||||
#endif
|
|
||||||
u32 did_wake = 0;
|
u32 did_wake = 0;
|
||||||
do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
|
do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
|
||||||
ASSERT(data);
|
ASSERT(data);
|
||||||
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
|
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
|
||||||
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
|
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
|
||||||
#ifdef FUTEXQUEUE_DEBUG
|
|
||||||
dbg() << "FutexQueue @ " << this << ": wake_n unblocking " << *static_cast<Thread*>(data);
|
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n unblocking {}", this, *static_cast<Thread*>(data));
|
||||||
#endif
|
|
||||||
ASSERT(did_wake < wake_count);
|
ASSERT(did_wake < wake_count);
|
||||||
if (bitset.has_value() ? blocker.unblock_bitset(bitset.value()) : blocker.unblock()) {
|
if (bitset.has_value() ? blocker.unblock_bitset(bitset.value()) : blocker.unblock()) {
|
||||||
if (++did_wake >= wake_count)
|
if (++did_wake >= wake_count)
|
||||||
|
@ -135,17 +127,13 @@ u32 FutexQueue::wake_n(u32 wake_count, const Optional<u32>& bitset, bool& is_emp
|
||||||
u32 FutexQueue::wake_all(bool& is_empty)
|
u32 FutexQueue::wake_all(bool& is_empty)
|
||||||
{
|
{
|
||||||
ScopedSpinLock lock(m_lock);
|
ScopedSpinLock lock(m_lock);
|
||||||
#ifdef FUTEXQUEUE_DEBUG
|
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_all", this);
|
||||||
dbg() << "FutexQueue @ " << this << ": wake_all";
|
|
||||||
#endif
|
|
||||||
u32 did_wake = 0;
|
u32 did_wake = 0;
|
||||||
do_unblock([&](Thread::Blocker& b, void* data, bool&) {
|
do_unblock([&](Thread::Blocker& b, void* data, bool&) {
|
||||||
ASSERT(data);
|
ASSERT(data);
|
||||||
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
|
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
|
||||||
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
|
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
|
||||||
#ifdef FUTEXQUEUE_DEBUG
|
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_all unblocking", this, *static_cast<Thread*>(data));
|
||||||
dbg() << "FutexQueue @ " << this << ": wake_all unblocking " << *static_cast<Thread*>(data);
|
|
||||||
#endif
|
|
||||||
if (blocker.unblock(true)) {
|
if (blocker.unblock(true)) {
|
||||||
did_wake++;
|
did_wake++;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -24,13 +24,12 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/Debug.h>
|
||||||
#include <AK/Singleton.h>
|
#include <AK/Singleton.h>
|
||||||
#include <AK/Time.h>
|
#include <AK/Time.h>
|
||||||
#include <Kernel/Process.h>
|
#include <Kernel/Process.h>
|
||||||
#include <Kernel/VM/MemoryManager.h>
|
#include <Kernel/VM/MemoryManager.h>
|
||||||
|
|
||||||
//#define FUTEX_DEBUG
|
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
static SpinLock<u8> g_global_futex_lock;
|
static SpinLock<u8> g_global_futex_lock;
|
||||||
|
@ -40,9 +39,10 @@ FutexQueue::FutexQueue(FlatPtr user_address_or_offset, VMObject* vmobject)
|
||||||
: m_user_address_or_offset(user_address_or_offset)
|
: m_user_address_or_offset(user_address_or_offset)
|
||||||
, m_is_global(vmobject != nullptr)
|
, m_is_global(vmobject != nullptr)
|
||||||
{
|
{
|
||||||
#ifdef FUTEX_DEBUG
|
dbgln<debug_futex>("Futex @ {}{}",
|
||||||
dbg() << "Futex @ " << this << (m_is_global ? " (global)" : "(local)");
|
this,
|
||||||
#endif
|
m_is_global ? " (global)" : " (local)");
|
||||||
|
|
||||||
if (m_is_global) {
|
if (m_is_global) {
|
||||||
// Only register for global futexes
|
// Only register for global futexes
|
||||||
m_vmobject = vmobject->make_weak_ptr();
|
m_vmobject = vmobject->make_weak_ptr();
|
||||||
|
@ -56,9 +56,9 @@ FutexQueue::~FutexQueue()
|
||||||
if (auto vmobject = m_vmobject.strong_ref())
|
if (auto vmobject = m_vmobject.strong_ref())
|
||||||
vmobject->unregister_on_deleted_handler(*this);
|
vmobject->unregister_on_deleted_handler(*this);
|
||||||
}
|
}
|
||||||
#ifdef FUTEX_DEBUG
|
dbgln<debug_futex>("~Futex @ {}{}",
|
||||||
dbg() << "~Futex @ " << this << (m_is_global ? " (global)" : "(local)");
|
this,
|
||||||
#endif
|
m_is_global ? " (global)" : " (local)");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FutexQueue::vmobject_deleted(VMObject& vmobject)
|
void FutexQueue::vmobject_deleted(VMObject& vmobject)
|
||||||
|
@ -68,9 +68,9 @@ void FutexQueue::vmobject_deleted(VMObject& vmobject)
|
||||||
// to make sure we have at last a reference until we're done
|
// to make sure we have at last a reference until we're done
|
||||||
NonnullRefPtr<FutexQueue> own_ref(*this);
|
NonnullRefPtr<FutexQueue> own_ref(*this);
|
||||||
|
|
||||||
#ifdef FUTEX_DEBUG
|
dbgln<debug_futex>("Futex::vmobject_deleted @ {}{}",
|
||||||
dbg() << "Futex::vmobject_deleted @ " << this << (m_is_global ? " (global)" : "(local)");
|
this,
|
||||||
#endif
|
m_is_global ? " (global)" : " (local)");
|
||||||
|
|
||||||
// Because this is called from the VMObject's destructor, getting a
|
// Because this is called from the VMObject's destructor, getting a
|
||||||
// strong_ref in this function is unsafe!
|
// strong_ref in this function is unsafe!
|
||||||
|
@ -83,12 +83,12 @@ void FutexQueue::vmobject_deleted(VMObject& vmobject)
|
||||||
|
|
||||||
bool did_wake_all;
|
bool did_wake_all;
|
||||||
auto wake_count = wake_all(did_wake_all);
|
auto wake_count = wake_all(did_wake_all);
|
||||||
#ifdef FUTEX_DEBUG
|
|
||||||
if (wake_count > 0)
|
if constexpr (debug_futex) {
|
||||||
dbg() << "Futex: @ " << this << " unblocked " << wake_count << " waiters due to vmobject free";
|
if (wake_count > 0)
|
||||||
#else
|
dbgln("Futex @ {} unblocked {} waiters due to vmobject free", this, wake_count);
|
||||||
(void)wake_count;
|
}
|
||||||
#endif
|
|
||||||
ASSERT(did_wake_all); // No one should be left behind...
|
ASSERT(did_wake_all); // No one should be left behind...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ int Process::sys$futex(Userspace<const Syscall::SC_futex_params*> user_params)
|
||||||
if (!user_value.has_value())
|
if (!user_value.has_value())
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
if (user_value.value() != params.val) {
|
if (user_value.value() != params.val) {
|
||||||
dbg() << "futex wait: EAGAIN. user value: " << (void*)user_value.value() << " @ " << (void*)params.userspace_address << " != val: " << params.val;
|
dbgln("futex wait: EAGAIN. user value: {:p} @ {:p} != val: {}", user_value.value(), params.userspace_address, params.val);
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
atomic_thread_fence(AK::MemoryOrder::memory_order_acquire);
|
atomic_thread_fence(AK::MemoryOrder::memory_order_acquire);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue