mirror of
https://github.com/lemonade-sdk/mac_linuxgpu.git
synced 2026-11-22 23:57:31 -10:00
On the R9700, a compute process (LSE) held 245 of the 256 MiB CPU-visible VRAM window while more than 13 GB of VRAM was free. That forced every CPU-access allocation (a dumb framebuffer, a kernel BO) to evict it. amdgpu's KFD VRAM BOs are VRAM_CLEARED and top-down. gpu_buddy's alloc_from_freetree searches top-down only in the requested tree, the clear one. When that tree has no block of the order, its fallback to the dirty tree is a plain smallest-order scan that drops GPU_BUDDY_TOPDOWN_ALLOCATION. A diagnostic build logged every top-down allocation landing in the low 256 MiB. All of them had the clear flag and a clear tree holding 0-34 MiB, for example "620800 KiB at 0x1000000; clear_avail 19 MiB -> 5 MiB, avail 30722 MiB". patches/linux/gpu-buddy-topdown-fallback.patch makes the fallback search the other tree top-down when top-down was asked for. Upstream's dirty-tracker rework of the buddy allocator removes the separate trees; drop the patch once the pin has it. test-gpu-buddy: a clear top-down request with the clear tree empty takes the highest free block (63 MiB of 64), not a low smaller-order one. The pinned allocator, with both declared patches reversed, takes the low block as a negative control.
42 lines
1.6 KiB
Diff
42 lines
1.6 KiB
Diff
gpu/buddy: honour top-down in the fallback to the other free tree
|
|
|
|
alloc_from_freetree searches top-down (get_maxblock) only in the tree the
|
|
request names: the clear tree for a GPU_BUDDY_CLEAR_ALLOCATION. When that
|
|
tree has no block of the order, it falls back to the other tree with the
|
|
plain smallest-order scan, dropping GPU_BUDDY_TOPDOWN_ALLOCATION. amdgpu's
|
|
KFD VRAM BOs are VRAM_CLEARED and top-down: with the clear tree empty they
|
|
landed in the low VRAM, the CPU-visible window of a small-BAR card (245 of
|
|
256 MiB held by one compute process with over 13 GB free), so every
|
|
CPU-access allocation had to evict them. The fallback now searches the
|
|
other tree top-down when top-down was asked for.
|
|
|
|
Drop this patch when the pin picks up the dirty-tracker rework of the
|
|
buddy allocator ("gpu/buddy: replace dual-tree/force_merge with a
|
|
decoupled dirty tracker"), which removes the separate trees.
|
|
|
|
diff --git a/drivers/gpu/buddy.c b/drivers/gpu/buddy.c
|
|
--- a/drivers/gpu/buddy.c
|
|
+++ b/drivers/gpu/buddy.c
|
|
@@ -820,11 +820,17 @@ alloc_from_freetree(struct gpu_buddy *mm,
|
|
tree = (tree == GPU_BUDDY_CLEAR_TREE) ?
|
|
GPU_BUDDY_DIRTY_TREE : GPU_BUDDY_CLEAR_TREE;
|
|
|
|
- for (tmp = order; tmp <= mm->max_order; ++tmp) {
|
|
- root = &mm->free_trees[tree][tmp];
|
|
- block = rbtree_last_free_block(root);
|
|
+ if (flags & GPU_BUDDY_TOPDOWN_ALLOCATION) {
|
|
+ block = get_maxblock(mm, order, tree);
|
|
if (block)
|
|
- break;
|
|
+ tmp = gpu_buddy_block_order(block);
|
|
+ } else {
|
|
+ for (tmp = order; tmp <= mm->max_order; ++tmp) {
|
|
+ root = &mm->free_trees[tree][tmp];
|
|
+ block = rbtree_last_free_block(root);
|
|
+ if (block)
|
|
+ break;
|
|
+ }
|
|
}
|
|
|
|
if (!block)
|