Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LRU/reclamation work #120

Merged
merged 24 commits into from
Jul 9, 2024
Merged

LRU/reclamation work #120

merged 24 commits into from
Jul 9, 2024

Conversation

heatd
Copy link
Owner

@heatd heatd commented May 13, 2024

No description provided.

heatd added 4 commits May 17, 2024 03:07
Completely rework slab cache shrinking to safe, (hopefully)
correct code. Also makes the cache_list_lock a mutex.

Signed-off-by: Pedro Falcato <[email protected]>
Add memory barriers for inter-process synchronization and their
implementations on x86, riscv and arm64.

Signed-off-by: Pedro Falcato <[email protected]>
We needed to order the previous sub_fetch(RELEASE) and load(ACQUIRE),
because ACQUIRE loads do not order against prior loads and stores (i.e
they're permeable in one direction). Use an smp_mb() for this ordering
(wmb and rmb won't do), and relax the sub_fetch.

Signed-off-by: Pedro Falcato <[email protected]>
heatd added 4 commits May 31, 2024 03:28
kasan: Add extern "C" to kasan_flush_quarantine
preempt.h: Add CDECLS
rwlock: Add CDECLS

Signed-off-by: Pedro Falcato <[email protected]>
Signed-off-by: Pedro Falcato <[email protected]>
Allocate the symtab using vmalloc. Using kmalloc provoked some really
large slabs to be present for the whole of the kernel's lifetime, since
boot. This reduces memory consumption quite a bit.

Signed-off-by: Pedro Falcato <[email protected]>
This stops infinite busy loops due to faulty logic.

Signed-off-by: Pedro Falcato <[email protected]>
@heatd heatd force-pushed the pedro/lru branch 2 times, most recently from 5f319ad to 9f0f762 Compare May 31, 2024 02:30
We accidentally didn't increment the refcount when duplicating the file
descriptor, which caused a use after free.

Signed-off-by: Pedro Falcato <[email protected]>
Add a very basic LRU queue. Right now it does no LRU (i.e it just takes
the first page in the queue), but it's a good first start and survives
basic memory reclaim tests (dd if=bigfile of=/dev/null for instance).

Signed-off-by: Pedro Falcato <[email protected]>
Fix error reporting after the printk rework.

Signed-off-by: Pedro Falcato <[email protected]>
heatd added 13 commits June 23, 2024 00:16
Add LRU-2Q page reclamation. This algorithm keeps two page queues
Active and Inactive (known as Am and A1 in the original literature). We
progressively promote pages from (inactive, unreferenced) -> (inactive,
referenced) -> (active, unreferenced) -> (active, referenced). This
gives us some sort of scan resistence.

We try to keep the inactive list as at least 25% of the LRU'd page
cache. It's worth noting that we have some shortcuts for page
activation:
 - Executable or actively shared (refs > 1) pages get activated
   immediately
 - Single-referenced pages get activated or referenced (as needed)

Some of the logic and heuristics were derived from [1].
Also add a way to harvest A bits from ptes to x86 and riscv (and stubbed
in arm64).

[1] https://lpc.events/event/11/contributions/896/attachments/793/1493/slides-r2.pdf

Signed-off-by: Pedro Falcato <[email protected]>
Add a simple flock(2) implementation. It's not perfect (and doesn't yet
support NFS flock(2) as-is), but it does the job for simple usage.

Signed-off-by: Pedro Falcato <[email protected]>
Signed-off-by: Pedro Falcato <[email protected]>
Fix mknod. We were accidentally doing the S_BADFMT check wrong.

Signed-off-by: Pedro Falcato <[email protected]>
chroot had a conflict in rv64.

Signed-off-by: Pedro Falcato <[email protected]>
Add dec-and-test operation. Meant for counters actionable on counter =
0, such as the preempt counter.

Signed-off-by: Pedro Falcato <[email protected]>
Generates better code. Also has a little fixup when it comes to branch
annotations, which generates cleaner looking code.

Signed-off-by: Pedro Falcato <[email protected]>
Add a mapcount counter to struct page, by slashing unsigned long
refcount in 2 (2^32 should work for all refcounts). We maintain this
mapcount when mapping/unmapping, which then reclaim easily uses to check
if it can reclaim this page (or if it's pinned by someone else). This
change required some consolidation of file mapping paths in filemap.cpp,
and of changing all "pmap" implementations. ARM64 was not changed, but
builds.

Signed-off-by: Pedro Falcato <[email protected]>
Account tmpfs memory and show it in sysinfo.

Signed-off-by: Pedro Falcato <[email protected]>
Use a normal fstab format (and use mntent.h while we're at it) to be
compatible with other tooling.

Signed-off-by: Pedro Falcato <[email protected]>
@heatd heatd merged commit 4304cae into master Jul 9, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant