Commit Graph

6 Commits

Author SHA1 Message Date
Andreas Kling
c973a51a23 Kernel: Make KBuffer lazily populated
KBuffers are now zero-filled on demand instead of up front. This means
that you can create a huge KBuffer and it will only take up VM, not
physical pages (until you access them.)
2019-08-06 15:06:31 +02:00
Andreas Kling
f58b0c245d KBuffer: Add set_size() and LogStream operator<<
It will be useful to be able to set the "public" size of a KBuffer.
It can still have a different amount of memory allocated internally.
2019-08-06 07:31:52 +02:00
Andreas Kling
79e22acb22 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. :^)
2019-08-05 11:37:48 +02:00
Andreas Kling
6b6b86fbf3 Kernel: Add a little comment header about KBuffer 2019-08-05 11:11:00 +02:00
Andreas Kling
605975adb5 Kernel: Make KBuffer a value-type wrapper around a KBufferImpl
A KBuffer always contains a valid KBufferImpl. If you need a "null"
state buffer, use Optional<KBuffer>.

This makes KBuffer very easy to work with and pass around, just like
ByteBuffer before it.
2019-08-05 11:07:45 +02:00
Andreas Kling
609495882f Kernel: Add KBuffer, a simple byte buffer backed by kernel-only memory
This memory is not accessible to userspace and comes from the kernel
page allocator, not from the kmalloc heap. This makes it ideal for
larger allocations.
2019-08-04 21:07:20 +02:00