summaryrefslogtreecommitdiff
path: root/Kernel/kmalloc.cpp
AgeCommit message (Collapse)Author
2019-07-03AK: Rename the common integer typedefs to make it obvious what they are.Andreas Kling
These types can be picked up by including <AK/Types.h>: * u8, u16, u32, u64 (unsigned) * i8, i16, i32, i64 (signed)
2019-06-09Kernel: Use the Multiboot memory map info to inform our paging setup.Andreas Kling
This makes it possible to run Serenity with more than 64 MB of RAM. Because each physical page is represented by a PhysicalPage object, and such objects are allocated using kmalloc_eternal(), more RAM means more pressure on kmalloc_eternal(), so we're gonna need a better strategy for this. But for now, let's just celebrate that we can use the 128 MB of RAM we've been telling QEMU to run with. :^)
2019-06-07Kernel: Move i386.{cpp,h} => Arch/i386/CPU.{cpp,h}Andreas Kling
There's a ton of work that would need to be done before we could spin up on another architecture, but let's at least try to separate things out a bit.
2019-06-07Kernel: Run clang-format on everything.Andreas Kling
2019-05-16Kernel: Simplify dump_backtrace() API for clients.Andreas Kling
It makes no sense that clients had to worry about whether or not KSyms were loaded.
2019-04-25Kernel: Don't count kfree(nullptr) as a call to kfree().Andreas Kling
This was causing the kmalloc/kfree call delta to accumulate errors.
2019-04-25Kernel: Dump stack trace when kmalloc() fails.Andreas Kling
2019-04-15Kernel: Make it possible to have kmalloc() dump call stacks.Andreas Kling
This can be enabled at any time using a sysctl: sysctl kmalloc_stacks=1 The stacks will go to the debugger output only.
2019-04-15Kernel+ProcessManager: Expose the number of kmalloc/kfree calls.Andreas Kling
This will be very helpful in tracking down unwanted kmalloc traffic. :^)
2019-04-06Kernel: Get rid of Kernel/types.h, separate LinearAddress/PhysicalAddress.Andreas Kling
2019-04-03Kernel: Tidy up kmalloc.cpp a tiny bit.Andreas Kling
2019-03-23Kernel: Introduce threads, and refactor everything in support of it.Andreas Kling
The scheduler now operates on threads, rather than on processes. Each process has a main thread, and can have any number of additional threads. The process exits when the main thread exits. This patch doesn't actually spawn any additional threads, it merely does all the plumbing needed to make it possible. :^)
2019-02-23LibC: Enough compat work to make binutils-2.32 build and run.Andreas Kling
2019-02-22Start fixing things up to build with a proper cross-compiler.Andreas Kling
2019-02-17Kernel: Shrink kmalloc() chunk size from 128 to 64.Andreas Kling
This sacrifices some speed for more space. I don't want to work on a new allocator right this moment, so this buys me some time.
2019-02-17Add ability to switch video modes from the system menu.Andreas Kling
I had to change PhysicalPage around a bit for this. Physical pages can now be instantiated for any arbitrary physical address without worrying that such pages end up in the kernel page allocator when released. Most of the pieces were already in place, I just glued everything together.
2019-02-15Use modern C++ attributes instead of __attribute__ voodoo.Andreas Kling
This is quite nice, although I wish [[gnu::always_inline]] implied inline. Also "gnu::" is kind of a wart, but whatcha gonna do.
2019-01-27Kernel: Unbreak symbolication yet another time.Andreas Kling
2019-01-16Tidy up memory map a bit and write out the general map in MemoryManager.Andreas Kling
There was a bug that given enough supervisor page allocation, we would eventually start dipping into the kmalloc range.
2019-01-12Paper over a race in DoubleBuffer.Andreas Kling
I'm still somewhat okay throwing InterruptDisabler at races as they screw me. Eventually I'm gonna have to devise a different strategy though.
2019-01-12Print process name and PID when kmalloc() panics.Andreas Kling
2018-12-26Add slightly better kmalloc_aligned() and kfree_aligned().Andreas Kling
Process page directories can now actually be freed. This could definitely be implemented in a nicer, less wasteful way, but this works for now. The spawn stress test can now run for a lot longer but eventually dies due to kmalloc running out of memory.
2018-12-02Make it possible to build the Kernel on a macOS host.Andreas Kling
It still requires an ELF compiler and linker, but at least it builds. I need to get rid of the "Unix" namespace. This does a lot of that.
2018-11-17Make bash-2.05b build with minimal changes.Andreas Kling
This is really neat. :^)
2018-11-12Add a braindead 10x speedup to kmalloc().Andreas Kling
Skip over entirely full buckets when scanning for a big-enough memory slot. This means I can postpone writing a better kmalloc() for a while longer! :^)
2018-11-10Merge VGA into VirtualConsole.Andreas Kling
2018-11-09Fix all current build warnings in the kernel.Andreas Kling
2018-11-09Fix some paging related bugs exposed by the spawn stress test.Andreas Kling
- Process::exec() needs to restore the original paging scope when called on a non-current process. - Add missing InterruptDisabler guards around g_processes access. - Only flush the TLB when modifying the active page tables.
2018-11-03Fix dumb-but-hard-to-find bug in paging.Andreas Kling
This was the fix: -process.m_page_directory[0] = m_kernel_page_directory[0]; -process.m_page_directory[1] = m_kernel_page_directory[1]; +process.m_page_directory->entries[0] = m_kernel_page_directory->entries[0]; +process.m_page_directory->entries[1] = m_kernel_page_directory->entries[1]; I spent a good two hours scratching my head, not being able to figure out why user process page directories felt they had ownership of page tables in the kernel page directory. It was because I was copying the entire damn kernel page directory into the process instead of only sharing the two first PDE's. Dang!
2018-11-02Implement fork()!Andreas Kling
This is quite cool! The syscall entry point plumbs the register dump down to sys$fork(), which uses it to set up the child process's TSS in order to resume execution right after the int 0x80 fork() call. :^) This works pretty well, although there is some problem with the kernel alias mappings used to clone the parent process's regions. If I disable the MM::release_page_directory() code, there's no problem. Probably there's a premature freeing of a physical page somehow.
2018-11-01Use a freelist for GDT entries.Andreas Kling
Tweak the kmalloc space layout a bit. Get the spawn stress test up and running again.
2018-11-01Implement address validation by querying the task's page directory.Andreas Kling
This is way better than walking the region lists. I suppose we could even let the hardware trigger a page fault and handle that. That'll be the next step in the evolution here I guess.
2018-11-01Give each task its own page directory.Andreas Kling
This isn't finished but I'll commit as I go. We need to get to where context switching only needs to change CR3 and everything's ready to go. My basic idea is: - The first 4 kB is off-limits. This catches null dereferences. - Up to the 4 MB mark is identity-mapped and kernel-only. - The rest is available to everyone! While the first 4 MB is only available to the kernel, it's still mapped in every process, for convenience when entering the kernel.
2018-10-31Add a kmalloc_eternal() for things that will never be destroyed.Andreas Kling
2018-10-29Fix broken SpinLock.Andreas Kling
The SpinLock was all backwards and didn't actually work. Fixing it exposed how wrong most of the locking here is. I need to come up with a better granularity here.
2018-10-27Greatly improve /proc/PID/stack by tracing the ebp frame chain.Andreas Kling
I also added a generator cache to FileHandle. This way, multiple reads to a generated file (i.e in a synthfs) can transparently handle multiple calls to read() without the contents changing between calls. The cache is discarded at EOF (or when the FileHandle is destroyed.)
2018-10-26Add a very hackish /proc/PID/stack.Andreas Kling
It walks the stack and identifies anything that looks like a kernel symbol. This could be a lot more sophisticated.
2018-10-24Add an InterruptDisabler helper class and use that for kmalloc.Andreas Kling
The naive spinlock was not nearly enough to protect kmalloc from reentrancy problems. I don't want to deal with coming up with a fancy lock for kmalloc right now, so I made an InterruptDisabler thingy instead. It does CLI and then STI iff interrupts were previously enabled.
2018-10-24Make the kmalloc global stats variable volatile.Andreas Kling
I know I'm praying for cargo here, but this does fix a weird issue where logging the sum_alloc and sum_free globals wouldn't display symmetric values all the time.
2018-10-24Add a kmalloc lock. This definitely reduces flakiness.Andreas Kling
2018-10-16Import the "gerbert" kernel I worked on earlier this year.Andreas Kling
It's a lot crappier than I remembered it. It's gonna need a lot of work.