• Charlie Jenkins's avatar
    riscv: mm: Use hint address in mmap if available · b5b4287a
    Charlie Jenkins authored
    On riscv it is guaranteed that the address returned by mmap is less than
    the hint address. Allow mmap to return an address all the way up to
    addr, if provided, rather than just up to the lower address space.
    
    This provides a performance benefit as well, allowing mmap to exit after
    checking that the address is in range rather than searching for a valid
    address.
    
    It is possible to provide an address that uses at most the same number
    of bits, however it is significantly more computationally expensive to
    provide that number rather than setting the max to be the hint address.
    There is the instruction clz/clzw in Zbb that returns the highest set bit
    which could be used to performantly implement this, but it would still
    be slower than the current implementation. At worst case, half of the
    address would not be able to be allocated when a hint address is
    provided.
    Signed-off-by: default avatarCharlie Jenkins <charlie@rivosinc.com>
    Link: https://lore.kernel.org/r/20240130-use_mmap_hint_address-v3-1-8a655cfa8bcb@rivosinc.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
    b5b4287a
processor.h 4.07 KB