Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] gpu/buddy: range-restricted alloc fails when free space exceeds range_end --
commit 2ed4c9d1a70c51390968b65e939095ce52c8ee07 Author: Arunpravin Paneer Selvam <[email protected]> gpu/buddy: add range-restricted contiguous allocation fallback A range + contiguous allocation rounds its size up to a power of two and requires a naturally aligned free block of that size. The non-range contiguous path already recovers from fragmentation via __alloc_contig_try_harder(), which is now given a range window to support the range + contiguous case. > diff --git a/drivers/gpu/buddy.c b/drivers/gpu/buddy.c > index 2f2aaadafe351..5265e1f6a3183 100644 > --- a/drivers/gpu/buddy.c > +++ b/drivers/gpu/buddy.c [ ... ] > @@ -1734,20 +1722,24 @@ static int __alloc_contig_try_harder(struct gpu_buddy > *mm, [ ... ] > if (!err) { > /* Allocate the unaligned RHS offset using round_down */ > gpu_buddy_free_list_internal(mm, blocks); > - err = __alloc_contig_aligned_retry(mm, rhs_offset, > - size, > - min_block_size, > - flags, blocks); > - if (!err) > - return 0; > - if (err != -ENOSPC) { > - gpu_buddy_free_list_internal(mm, blocks); > - return err; > + > + aligned = round_down(rhs_offset, min_block_size); > + if (aligned >= range_start && > + aligned + size <= range_end) { > + err = __gpu_buddy_alloc_range(mm, aligned, size, > + flags, NULL, > blocks); > + if (!err) > + return 0; > + if (err != -ENOSPC) { > + gpu_buddy_free_list_internal(mm, > blocks); > + return err; > + } > } > goto next; > } [Severity: High] Does this skip the left-hand side (LHS) fallback when contiguous free space exceeds range_end? If __gpu_buddy_alloc_range() succeeds at finding free space starting at rhs_offset, err is 0. If the free space extends beyond range_end, the newly added check (aligned >= range_start && aligned + size <= range_end) might fail. But since err is still 0, it hits the unconditional goto next. By skipping to next, doesn't this bypass the LHS window-sliding logic below? If there was valid free space to the left of rhs_offset that perfectly fits the window, it appears it would be ignored, causing the allocator to return -ENOSPC despite sufficient space existing within the requested range. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
