Skip to content

Commit 659aa05

Browse files
AlisonSchofielddjbw
authored andcommitted
kernel/resource: Increment by align value in get_free_mem_region()
Currently get_free_mem_region() searches for available capacity in increments equal to the region size being requested. This can cause the search to take giant steps through the resource leaving needless gaps and missing available space. Specifically 'cxl create-region' fails with ERANGE even though capacity of the given size and CXL's expected 256M x InterleaveWays alignment can be satisfied. Replace the total-request-size increment with a next alignment increment so that the next possible address is always examined for availability. Fixes: 14b8058 ("resource: Introduce alloc_free_mem_region()") Reported-by: Dmytro Adamenko <dmytro.adamenko@intel.com> Reported-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Alison Schofield <alison.schofield@intel.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/20231113221324.1118092-1-alison.schofield@intel.com Cc: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent e05501e commit 659aa05

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/resource.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,8 +1844,8 @@ get_free_mem_region(struct device *dev, struct resource *base,
18441844

18451845
write_lock(&resource_lock);
18461846
for (addr = gfr_start(base, size, align, flags);
1847-
gfr_continue(base, addr, size, flags);
1848-
addr = gfr_next(addr, size, flags)) {
1847+
gfr_continue(base, addr, align, flags);
1848+
addr = gfr_next(addr, align, flags)) {
18491849
if (__region_intersects(base, addr, size, 0, IORES_DESC_NONE) !=
18501850
REGION_DISJOINT)
18511851
continue;

0 commit comments

Comments
 (0)