diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-05-21 02:27:20 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-21 12:36:20 +0200 |
commit | 3d7cc471d6b798bd895a5ad74e95ee3408bc8cf5 (patch) | |
tree | 2e1c83cb4cf8f0740cad41aa17f8f4cc5b5e1875 /Kernel | |
parent | 124a523199399baca00e307bcb98e1aeec24edef (diff) | |
download | serenity-3d7cc471d6b798bd895a5ad74e95ee3408bc8cf5.zip |
Revert "Kernel: Avoid allocating under spinlock in ProcessGroup::find_or_create"
This reverts commit e95eb7a51d8295c96cddf20f116139deecbb69d4.
This is causing some sort of list corruption, as evident by #7313
I haven't been able to figure it out yet, so lets revert this change
until I can figure out what's going on.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/ProcessGroup.cpp | 17 | ||||
-rw-r--r-- | Kernel/ProcessGroup.h | 2 |
2 files changed, 2 insertions, 17 deletions
diff --git a/Kernel/ProcessGroup.cpp b/Kernel/ProcessGroup.cpp index 23c429815b..3a92151e51 100644 --- a/Kernel/ProcessGroup.cpp +++ b/Kernel/ProcessGroup.cpp @@ -30,31 +30,18 @@ RefPtr<ProcessGroup> ProcessGroup::create(ProcessGroupID pgid) RefPtr<ProcessGroup> ProcessGroup::find_or_create(ProcessGroupID pgid) { - // Avoid allocating under spinlock, this compromises by wasting the - // allocation when we race with another process to see if they have - // already created a process group. - auto process_group = adopt_ref_if_nonnull(new ProcessGroup(pgid)); ScopedSpinLock lock(g_process_groups_lock); - if (auto existing = from_pgid_nolock(pgid)) + if (auto existing = from_pgid(pgid)) return existing.release_nonnull(); - if (!process_group) - return {}; - - g_process_groups->prepend(process_group); - return process_group; + return create(pgid); } RefPtr<ProcessGroup> ProcessGroup::from_pgid(ProcessGroupID pgid) { ScopedSpinLock lock(g_process_groups_lock); - return from_pgid_nolock(pgid); -} -RefPtr<ProcessGroup> ProcessGroup::from_pgid_nolock(ProcessGroupID pgid) -{ - VERIFY(g_process_groups_lock.own_lock()); for (auto& group : *g_process_groups) { if (group.pgid() == pgid) return &group; diff --git a/Kernel/ProcessGroup.h b/Kernel/ProcessGroup.h index fac329f1ec..8ae5f295f5 100644 --- a/Kernel/ProcessGroup.h +++ b/Kernel/ProcessGroup.h @@ -40,8 +40,6 @@ private: { } - static RefPtr<ProcessGroup> from_pgid_nolock(ProcessGroupID); - ProcessGroup* m_prev { nullptr }; ProcessGroup* m_next { nullptr }; |