mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 23:12:08 +00:00
Kernel: Better handling of allocation failure in profiling
If we can't allocate a PerformanceEventBuffer to store the profiling events, we now fail sys$profiling_enable() and sys$perf_event() with ENOMEM instead of carrying on with a broken buffer.
This commit is contained in:
parent
e7ef729db3
commit
b425c2602c
6 changed files with 26 additions and 18 deletions
|
@ -34,8 +34,8 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
PerformanceEventBuffer::PerformanceEventBuffer()
|
||||
: m_buffer(KBuffer::try_create_with_size(4 * MiB, Region::Access::Read | Region::Access::Write, "Performance events", AllocationStrategy::AllocateNow))
|
||||
PerformanceEventBuffer::PerformanceEventBuffer(NonnullOwnPtr<KBuffer> buffer)
|
||||
: m_buffer(move(buffer))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -171,4 +171,12 @@ bool PerformanceEventBuffer::to_json(KBufferBuilder& builder, ProcessID pid, con
|
|||
return true;
|
||||
}
|
||||
|
||||
OwnPtr<PerformanceEventBuffer> PerformanceEventBuffer::try_create_with_size(size_t buffer_size)
|
||||
{
|
||||
auto buffer = KBuffer::try_create_with_size(buffer_size, Region::Access::Read | Region::Access::Write, "Performance events", AllocationStrategy::AllocateNow);
|
||||
if (!buffer)
|
||||
return {};
|
||||
return adopt_own(*new PerformanceEventBuffer(buffer.release_nonnull()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue