mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-19 17:42:52 +00:00
Kernel: Remove big lock from sys$set_coredump_metadata
The only requirement for this syscall is to make Process::m_coredump_properties SpinlockProtected.
This commit is contained in:
parent
343aec2200
commit
1682b0b6d8
Notes:
sideshowbarker
2024-07-17 14:14:14 +09:00
Author: https://github.com/Lubrsi
Commit: 1682b0b6d8
Pull-request: https://github.com/SerenityOS/serenity/pull/13592
5 changed files with 25 additions and 18 deletions
|
@ -148,7 +148,7 @@ enum class NeedsBigProcessLock {
|
||||||
S(sched_setparam, NeedsBigProcessLock::No) \
|
S(sched_setparam, NeedsBigProcessLock::No) \
|
||||||
S(sendfd, NeedsBigProcessLock::No) \
|
S(sendfd, NeedsBigProcessLock::No) \
|
||||||
S(sendmsg, NeedsBigProcessLock::Yes) \
|
S(sendmsg, NeedsBigProcessLock::Yes) \
|
||||||
S(set_coredump_metadata, NeedsBigProcessLock::Yes) \
|
S(set_coredump_metadata, NeedsBigProcessLock::No) \
|
||||||
S(set_mmap_name, NeedsBigProcessLock::Yes) \
|
S(set_mmap_name, NeedsBigProcessLock::Yes) \
|
||||||
S(set_process_name, NeedsBigProcessLock::Yes) \
|
S(set_process_name, NeedsBigProcessLock::Yes) \
|
||||||
S(set_thread_name, NeedsBigProcessLock::Yes) \
|
S(set_thread_name, NeedsBigProcessLock::Yes) \
|
||||||
|
|
|
@ -874,15 +874,18 @@ void Process::set_dumpable(bool dumpable)
|
||||||
|
|
||||||
ErrorOr<void> Process::set_coredump_property(NonnullOwnPtr<KString> key, NonnullOwnPtr<KString> value)
|
ErrorOr<void> Process::set_coredump_property(NonnullOwnPtr<KString> key, NonnullOwnPtr<KString> value)
|
||||||
{
|
{
|
||||||
|
return m_coredump_properties.with([&](auto& coredump_properties) -> ErrorOr<void> {
|
||||||
// Write it into the first available property slot.
|
// Write it into the first available property slot.
|
||||||
for (auto& slot : m_coredump_properties) {
|
for (auto& slot : coredump_properties) {
|
||||||
if (slot.key)
|
if (slot.key)
|
||||||
continue;
|
continue;
|
||||||
slot.key = move(key);
|
slot.key = move(key);
|
||||||
slot.value = move(value);
|
slot.value = move(value);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return ENOBUFS;
|
return ENOBUFS;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> Process::try_set_coredump_property(StringView key, StringView value)
|
ErrorOr<void> Process::try_set_coredump_property(StringView key, StringView value)
|
||||||
|
|
|
@ -500,11 +500,14 @@ public:
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
ErrorOr<void> for_each_coredump_property(Callback callback) const
|
ErrorOr<void> for_each_coredump_property(Callback callback) const
|
||||||
{
|
{
|
||||||
for (auto const& property : m_coredump_properties) {
|
return m_coredump_properties.with([&](auto const& coredump_properties) -> ErrorOr<void> {
|
||||||
|
for (auto const& property : coredump_properties) {
|
||||||
if (property.key && property.value)
|
if (property.key && property.value)
|
||||||
TRY(callback(*property.key, *property.value));
|
TRY(callback(*property.key, *property.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> set_coredump_property(NonnullOwnPtr<KString> key, NonnullOwnPtr<KString> value);
|
ErrorOr<void> set_coredump_property(NonnullOwnPtr<KString> key, NonnullOwnPtr<KString> value);
|
||||||
|
@ -833,7 +836,7 @@ private:
|
||||||
OwnPtr<KString> value;
|
OwnPtr<KString> value;
|
||||||
};
|
};
|
||||||
|
|
||||||
Array<CoredumpProperty, 4> m_coredump_properties;
|
SpinlockProtected<Array<CoredumpProperty, 4>> m_coredump_properties;
|
||||||
NonnullRefPtrVector<Thread> m_threads_for_coredump;
|
NonnullRefPtrVector<Thread> m_threads_for_coredump;
|
||||||
|
|
||||||
mutable RefPtr<ProcessProcFSTraits> m_procfs_traits;
|
mutable RefPtr<ProcessProcFSTraits> m_procfs_traits;
|
||||||
|
|
|
@ -525,8 +525,9 @@ ErrorOr<void> Process::do_exec(NonnullRefPtr<OpenFileDescription> main_program_d
|
||||||
return {};
|
return {};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
for (auto& property : m_coredump_properties)
|
m_coredump_properties.for_each([](auto& property) {
|
||||||
property = {};
|
property = {};
|
||||||
|
});
|
||||||
|
|
||||||
auto* current_thread = Thread::current();
|
auto* current_thread = Thread::current();
|
||||||
current_thread->reset_signals_for_exec();
|
current_thread->reset_signals_for_exec();
|
||||||
|
|
|
@ -50,7 +50,7 @@ ErrorOr<FlatPtr> Process::sys$set_process_name(Userspace<char const*> user_name,
|
||||||
|
|
||||||
ErrorOr<FlatPtr> Process::sys$set_coredump_metadata(Userspace<Syscall::SC_set_coredump_metadata_params const*> user_params)
|
ErrorOr<FlatPtr> Process::sys$set_coredump_metadata(Userspace<Syscall::SC_set_coredump_metadata_params const*> user_params)
|
||||||
{
|
{
|
||||||
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
VERIFY_NO_PROCESS_BIG_LOCK(this)
|
||||||
auto params = TRY(copy_typed_from_user(user_params));
|
auto params = TRY(copy_typed_from_user(user_params));
|
||||||
|
|
||||||
if (params.key.length == 0 || params.key.length > 16 * KiB)
|
if (params.key.length == 0 || params.key.length > 16 * KiB)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue