mbox series

[v2,0/6] lmb: miscellaneous fixes and improvements

Message ID 20250220095654.121634-1-sughosh.ganu@linaro.org
Headers show
Series lmb: miscellaneous fixes and improvements | expand

Message

Sughosh Ganu Feb. 20, 2025, 9:56 a.m. UTC
The patch series contains some fixes and improvements in the lmb
code, along with addition of corresponding test cases for the changes
made.

The lmb_reserve() function currently does not check if the requested
reservation would overlap with existing reserved regions. While some
scenarios are being handled, some corner cases still exist. These are
being handled by patch 1, along with adding test cases for these
scenarios.

Patch 2 is handling the case of reserving a new region of memory, but
that region overlaps with an existing region. The current code only
handles one particular scenario, but prints a message for the other
scenario of an encompassing overlap and returns back. The patch
handles the encompassing overlap.

Patch 3 is an improvement whereby we allow coalescing a newly reserved
region with an existing region. The current code exits this check
prematurely.

Patch 4 is removing a now superfluous check for overlapping regions
with flag other than LMB_NONE. This now gets handled at an earlier
point in lmb_reserve().

Patch 5 is clubbing the functionality to check if two regions are
adjacent, or overlap, allowing some code re-use.

Patch 6 is optimising the lmb_alloc() function by having it call
_lmb_alloc_base() directly.


Changes since V1:
* Add documentation for the lmb_can_reserve_region() function.
* Add an additional test case where a new region is being added, and
  the new region overlaps two different existing regions, with
  mismatching flags.
* Some cleanup of comments in the lib_test_lmb_overlapping_reserve()
  function.
* Use lmb_resize_regions() to fix the overlap instead of
  lmb_fix_over_lap_regions().
* Remove the now superfluous lmb_fix_over_lap_regions().
* Continue the loop only in the case where the newly added region is
  after the existing region.



Sughosh Ganu (6):
  lmb: check if a region can be reserved by lmb_reserve()
  lmb: handle scenario of encompassing overlap
  lmb: check for a region's coalescing with all existing regions
  lmb: remove superfluous address overlap check from
    lmb_add_region_flags()
  lmb: use a common function to check if regions overlap or are adjacent
  lmb: optimise the lmb allocation functions

 lib/lmb.c      | 140 +++++++++++++++++++++++++++++--------------------
 test/lib/lmb.c | 114 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 194 insertions(+), 60 deletions(-)