mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 18:37:36 +00:00
Kernel: Use KBuffers for ProcFS and SynthFS
Instead of generating ByteBuffers and keeping those lying around, have these filesystems generate KBuffers instead. These are way less spooky to leave around for a while. Since FileDescription will keep a generated file buffer around until userspace has read the whole thing, this prevents trivially exhausting the kmalloc heap by opening many files in /proc for example. The code responsible for generating each /proc file is not perfectly efficient and many of them still use ByteBuffers internally but they at least go away when we return now. :^)
This commit is contained in:
parent
6b6b86fbf3
commit
79e22acb22
7 changed files with 58 additions and 43 deletions
|
@ -65,11 +65,16 @@ public:
|
|||
|
||||
const KBufferImpl& impl() const { return m_impl; }
|
||||
|
||||
KBuffer(NonnullRefPtr<KBufferImpl>&& impl)
|
||||
: m_impl(move(impl))
|
||||
KBuffer(const ByteBuffer& buffer)
|
||||
: m_impl(KBufferImpl::copy(buffer.data(), buffer.size()))
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
explicit KBuffer(NonnullRefPtr<KBufferImpl>&& impl)
|
||||
: m_impl(move(impl))
|
||||
{
|
||||
}
|
||||
|
||||
NonnullRefPtr<KBufferImpl> m_impl;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue