summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2019-08-09Kernel: Do some basic sanity checking on IPv4 packet headersAndreas Kling
Ignore packets that are too small, or not as large as they claim to be.
2019-08-09Kernel: Merge FooSocketHandle classes into a single SocketHandle<Foo>Andreas Kling
- IPv4SocketHandle => SocketHandle<IPv4Socket> - TCPSocketHandle => SocketHandle<TCPSocket> - UDPSocketHandle => SocketHandle<UDPSocket>
2019-08-09Kernel: Improve some network-related log messagesConrad Pankoff
2019-08-09Kernel: Support binding to INADDR_ANY (all IPs)Conrad Pankoff
2019-08-09Kernel: Implement TCP listening sockets and incoming connectionsConrad Pankoff
2019-08-09Kernel: Let pending socket queue keep socket objects alive until accept()Conrad Pankoff
2019-08-09Kernel: Use WeakPtr<NetworkAdapter> instead of NetworkAdapter* in net codeConrad Pankoff
2019-08-08Kernel: Reorder some Process members to shrink the class by 8 bytesAndreas Kling
2019-08-08Kernel: Use some more InlineLinkedList range-for iterationAndreas Kling
2019-08-08ProcFS: Remove /proc/kmalloc, that info is already in /proc/memstatAndreas Kling
2019-08-08Kernel: Use range-for with InlineLinkedListAndreas Kling
2019-08-08Kernel: Turns global Custody and Inode tables into InlineLinkedListsAndreas Kling
Yet more of this same thing. Each one of these patches has a small but noticeable impact on the steady-state kmalloc numbers. :^)
2019-08-08Kernel: Put all Regions on InlineLinkedLists (separated by user/kernel)Andreas Kling
Remove the global hash tables and replace them with InlineLinkedLists. This significantly reduces the kernel heap pressure from doing many small mmap()'s.
2019-08-08Kernel: Put all VMObjects in an InlineLinkedList instead of a HashTableAndreas Kling
Using a HashTable to track "all instances of Foo" is only useful if we actually need to look up entries by some kind of index. And since they are HashTable (not HashMap), the pointer *is* the index. Since we have the pointer, we can just use it directly. Duh. This increase sizeof(VMObject) by two pointers, but removes a global table that had an entry for every VMObject, where the cost was higher. It also avoids all the general hash tabling business when creating or destroying VMObjects. Generally we should do more of this. :^)
2019-08-08Kernel: Record network statistics and expose as JSONConrad Pankoff
This is comprised of five small changes: * Keep a counter for tx/rx packets/bytes per TCP socket * Keep a counter for tx/rx packets/bytes per network adapter * Expose that data in /proc/net_tcp and /proc/netadapters * Convert /proc/netadapters to JSON * Fix up ifconfig to read the JSON from netadapters
2019-08-08Kernel: Prevent RST spam when we get an unexpected packetConrad Pankoff
2019-08-07Kernel: Remove unused MemoryManager::remove_identity_mapping()Andreas Kling
This was not actually used and just sitting there being confusing.
2019-08-07Kernel: Always give back VM to the RangeAllocator when unmapping RegionAndreas Kling
We were only doing this in Process::deallocate_region(), which meant that kernel-only Regions never gave back their VM. With this patch, we can start reusing freed-up address space! :^)
2019-08-07Kernel: Use KBufferBuilder to build ProcFS files and backtracesAndreas Kling
This is not perfect as it uses a lot of VM, but since the buffers are supposed to be temporary it's not super terrible. This could be improved by giving back the unused VM to the kernel's RangeAllocator after finishing the buffer building.
2019-08-07JSON: Templatize the JSON serialization codeAndreas Kling
This makes it possible to use something other than a StringBuilder for serialization (and to produce something other than a String.) :^)
2019-08-07Kernel: Don't create Function objects in the scheduling codeAndreas Kling
Each Function is a heap allocation, so let's make an effort to avoid doing that during scheduling. Because of header dependencies, I had to put the runnables iteration helpers in Thread.h, which is a bit meh but at least this cuts out all the kmalloc() traffic in pick_next().
2019-08-07Kernel: Disable kmalloc backtraces during backtrace generationAndreas Kling
If kmalloc backtraces are enabled during backtracing, things don't go super well when the backtrace code calls kmalloc().. With this fixed, it's basically possible to get all kmalloc backtraces on the debugger by running (as root): sysctl kmalloc_stacks=1
2019-08-07Kernel: Use a FixedArray for VMObject::m_physical_pagesAndreas Kling
This makes VMObject 8 bytes smaller since we can use the array size as the page count. The size() is now also computed from the page count instead of being a separate value. This makes sizes always be a multiple of PAGE_SIZE, which is sane.
2019-08-07Kernel: Split VMObject into two classes: Anonymous- and InodeVMObjectAndreas Kling
InodeVMObject is a VMObject with an underlying Inode in the filesystem. AnonymousVMObject has no Inode. I'm happy that InodeVMObject::inode() can now return Inode& instead of VMObject::inode() return Inode*. :^)
2019-08-07Kernel: Remove "allow CPU caching" flag on VMObjectAndreas Kling
This wasn't really thought-through, I was just trying anything to see if it would make WindowServer faster. This doesn't seem to make much of a difference either way, so let's just not do it for now. It's easy to bring back if we think we need it in the future.
2019-08-07Kernel: Remove VMObject namesAndreas Kling
The VMObject name was always either the owning region's name, or the absolute path of the underlying inode. We can reconstitute this information if wanted, no need to keep copies of these strings around.
2019-08-07DiskDevice: Add missing override and remove unnecessary class_name()Andreas Kling
This class needs to be fixed up to not hide the read()/write() virtuals at some point.
2019-08-06Meta: Make Serenity run on Bochs once againAndreas Kling
It's now possible to run Serenity inside Bochs by executing "./run b" Note that it only works with a GRUB image (i.e ./build-image-grub.sh)
2019-08-06Kernel: Add KBufferBuilder, similar to StringBuilder but for KBufferAndreas Kling
This class works by eagerly allocating 1MB of virtual memory but only adding physical pages on demand. In other words, when you append to it, its memory usage will increase by 1 page whenever you append across a page boundary (4KB.)
2019-08-06Kernel: For signal-killed threads, dump backtrace from finalizer threadAndreas Kling
Instead of dumping the dying thread's backtrace in the signal handling code, wait until we're finalizing the thread. Since signalling happens during scheduling, the less work we do there the better. Basically the less that happens during a scheduler pass the better. :^)
2019-08-06Kernel: Refactor TCP/IP stackConrad Pankoff
This has several significant changes to the networking stack. * Significant refactoring of the TCP state machine. Right now it's probably more fragile than it used to be, but handles quite a lot more of the handshake process. * `TCPSocket` holds a `NetworkAdapter*`, assigned during `connect()` or `bind()`, whichever comes first. * `listen()` is now virtual in `Socket` and intended to be implemented in its child classes * `listen()` no longer works without `bind()` - this is a bit of a regression, but listening sockets didn't work at all before, so it's not possible to observe the regression. * A file is exposed at `/proc/net_tcp`, which is a JSON document listing the current TCP sockets with a bit of metadata. * There's an `ETHERNET_VERY_DEBUG` flag for dumping packet's content out to `kprintf`. It is, indeed, _very debug_.
2019-08-06Kernel: Make KBuffer lazily populatedAndreas Kling
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-06Kernel: Allow zero-fill page faults on kernel-only pagesAndreas Kling
We were short-circuiting the page fault handler a little too eagerly for page-not-present faults in kernel memory. If the current page directory already has up-to-date mapps for kernel memory, allow it to progress to checking for zero-fill conditions. This will enable us to have lazily populated kernel regions.
2019-08-06Kernel: Add mapping from page directory base (PDB) to PageDirectoryAndreas Kling
This allows the page fault code to find the owning PageDirectory and corresponding process for faulting regions. The mapping is implemented as a global hash map right now, which is definitely not optimal. We can come up with something better when it becomes necessary.
2019-08-06Kernel: Break region_from_vaddr() into {user,kernel}_region_from_vaddrAndreas Kling
Sometimes you're only interested in either user OR kernel regions but not both. Let's break this into two functions so the caller can choose what he's interested in.
2019-08-06Kernel: Add LogStream operator<< for VirtualAddressAndreas Kling
2019-08-06Kernel: Don't treat read faults like CoW exceptionsAndreas Kling
I'm not sure why we would have a non-readable CoW region, but I suppose we could, so let's not Copy-on-Read in those cases.
2019-08-06Kernel: Clean up the page fault handling code a bitAndreas Kling
Not using "else" after "return" unnests the code and makes it easier to follow. Also use an enum for the two different page fault types.
2019-08-06KBuffer: Add set_size() and LogStream operator<<Andreas Kling
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-06Kernel: On kernel NP fault, always copy into *active* page directoryAndreas Kling
If we were using a ProcessPagingScope to temporarily go into another process's page tables, things would fall apart when hitting a kernel NP fault, since we'd clone the kernel page directory entry into the *currently active process's* page directory rather than cloning it into the *currently active* page directory.
2019-08-05SynthFS: Remove unused create_text_file() featureAndreas Kling
We don't need to support static text files in SynthFS, it's better to always use generators for everything.
2019-08-05Kernel+LibC: Support passing O_CLOEXEC to pipe()Sergey Bugaev
In the userspace, this mimics the Linux pipe2() syscall; in the kernel, the Process::sys$pipe() now always accepts a flags argument, the no-argument pipe() syscall is now a userspace wrapper over pipe2().
2019-08-05SynthFS: Oops, fix build.Andreas Kling
2019-08-05Kernel: Use KBuffers for ProcFS and SynthFSAndreas Kling
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-05Kernel: Add a little comment header about KBufferAndreas Kling
2019-08-05Kernel: Make KBuffer a value-type wrapper around a KBufferImplAndreas Kling
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-05IPv4: Remove an unnecessary copy of each outgoing IPv4 payloadAndreas Kling
There's no need for send_ipv4() to take a ByteBuffer&&, the data is immediately cooked into a packet and transmitted. Instead, just pass it the address+length of whatever buffer we've been using locally. The more we can reduce the pressure on kmalloc the better. :^)
2019-08-05Net: Let Socket have read/write wrappers around sendto/recvfromAndreas Kling
The situations in IPv4Socket and LocalSocket were mirrors of each other where one had implemented read/write as wrappers and the other had sendto/recvfrom as wrappers. Instead of this silliness, move read and write up to the Socket base. Then mark them final, so subclasses have no choice but to implement sendto and recvfrom.
2019-08-04Net: Use KBuffers for network adapter packet queuesAndreas Kling
This further reduces pressure on the kmalloc heap. :^)
2019-08-04Kernel: Flush the TLB (page only) when copying in a new kernel mappingAndreas Kling
Not flushing the TLB here puts us in an infinite page fault loop.