Skip to content

Conversation

@geertj
Copy link
Contributor

@geertj geertj commented Nov 22, 2025

Please see the individual commit descriptions:

  • engines/mmap: support fadvise_hint
  • engines/mmap: fix logic when "offset" > 0
  • engines/mmap: fix full/limited prep logic

@axboe
Copy link
Owner

axboe commented Nov 22, 2025

Look good to me, but can you please add your Signed-off-by to the commits? See other commits in the tree.

Previously, "fadvise_hint=0" would disable madvise hints, and any other value
including the default would set the hint according to the workload type. This
patch adds suport for explicitly setting "sequential" and "random" independent
of the workload type. Note that "reuse" is not supported for madvise().

Signed-off-by: Geert Jansen <[email protected]>
This fixes the offset/size calculation when "offset" > 0. Previously this had:

        fmd->mmap_sz = f->io_size;
        fmd->mmap_off = 0;

This is correct only when "offset" (ie f->file_offset) = 0. We can fix this by
either keeping the offset at 0, and map the entire file, or by keeping the size
at f->io_size and setting mmap_off = f->file_offset. On 64-bit there isn't much
difference but on 32-bit the second option is better as it maps less memory.
This patch therefore takes the second approach.

Signed-off-by: Geert Jansen <[email protected]>
The engine supports a "full" mode where the entire range for a job is mapped,
and a "limited" mode that tries to map less memory. This fixes a bug and
implements the following simplified logic:

- If we are on a 64-bit architecture, or if io_size <= mmap_map_size, then we
  map the entire io_size region, and re-use for all IO.
- Otherwise, we map the range for each individual IOs.

Previously, we would fallback to limited mode in case of 32-bit overflow of the
job size. That isn't strict enough as we want to stay below mmap_map_size for a
single mapping. This fixes that.

Also, in limited mode, this code previously tried to map min(io_size,
mmap_map_size) bytes, starting at the offset. This could allow a future IO use
the same mapping if happens at a higher offset. I think it's better to keep it
simple and get the consistent performance of always having one mmap per IO in
limited mode.

Signed-off-by: Geert Jansen <[email protected]>
@geertj
Copy link
Contributor Author

geertj commented Nov 23, 2025

Look good to me, but can you please add your Signed-off-by to the commits? See other commits in the tree.

@axboe done. Thanks!

@axboe axboe merged commit de3d5e6 into axboe:master Nov 24, 2025
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants