diff options
| author | Francois Dugast <francois.dugast@intel.com> | 2026-05-22 11:25:32 +0200 |
|---|---|---|
| committer | Francois Dugast <francois.dugast@intel.com> | 2026-05-29 13:44:01 +0200 |
| commit | 25d912475e8b734ac7bf1880920b6b42514e9472 (patch) | |
| tree | eb08404ccc482092720c19b7c58f616373509f0c /include/linux/gpu_buddy.h | |
| parent | a03721ee484c6a5cbc58ece2cf6feaa2159761e7 (diff) | |
gpu/buddy: Track per-order used blocks with a scoreboard
Extend the scoreboard approach from the previous commit to used blocks,
so drm_buddy_print() can report per-order allocation pressure in O(1).
Unlike free blocks, an allocated block can leave the allocated state
through mark_free() (normal free and gpu_buddy_block_trim()) or be
consumed directly by gpu_block_free() during coalescing. Both sites are
guarded by gpu_buddy_block_is_allocated() and paired with the increment
in mark_allocated().
v3:
- Assert scoreboard is empty at fini(), as sanity check (Matthew Auld)
v2:
- Update after fix for use-after-free in split_block() call sites
- Change goto label to out_free_used_scoreboard for clarity
- Make drm_buddy_print() and gpu_buddy_print() symmetric for used and
free
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://lore.kernel.org/r/20260522092600.32818-6-francois.dugast@intel.com
Signed-off-by: Francois Dugast <francois.dugast@intel.com>
Diffstat (limited to 'include/linux/gpu_buddy.h')
| -rw-r--r-- | include/linux/gpu_buddy.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/gpu_buddy.h b/include/linux/gpu_buddy.h index a28f7d7637ca..e037714563d8 100644 --- a/include/linux/gpu_buddy.h +++ b/include/linux/gpu_buddy.h @@ -180,6 +180,14 @@ struct gpu_buddy { * called on a free block. */ u64 *free_scoreboard; + /* + * Per-order used block scoreboard: used_scoreboard[order] holds the + * number of blocks of that order currently in the allocated state. + * Incremented in mark_allocated(), decremented in mark_free() (guarded + * by gpu_buddy_block_is_allocated()) and in __gpu_buddy_free() when an + * allocated block is consumed directly during buddy coalescing. + */ + u64 *used_scoreboard; /* public: */ unsigned int n_roots; unsigned int max_order; |
