[PATCH v3] erofs-utils: mkfs: Implement 'dsunit' alignment on blobdev
Gao Xiang
hsiangkao at linux.alibaba.com
Sat Aug 23 19:14:06 AEST 2025
On 2025/8/23 16:34, Friendy Su wrote:
> Set proper 'dsunit' to let file body align on huge page on blobdev,
>
> where 'dsunit' * 'blocksize' = huge page size (2M).
>
> When do mmap() a file mounted with dax=always, aligning on huge page
> makes kernel map huge page(2M) per page fault exception, compared with
> mapping normal page(4K) per page fault.
>
> This greatly improves mmap() performance by reducing times of page
> fault being triggered.
>
> Considering deduplication, 'chunksize' should not be smaller than
> 'dsunit', then after dedupliation, still align on dsunit.
>
> Signed-off-by: Friendy Su <friendy.su at sony.com>
> Reviewed-by: Yuezhang Mo <Yuezhang.Mo at sony.com>
> Reviewed-by: Daniel Palmer <daniel.palmer at sony.com>
> ---
> lib/blobchunk.c | 18 ++++++++++++++++++
> man/mkfs.erofs.1 | 15 +++++++++++++++
> mkfs/main.c | 12 ++++++++++++
> 3 files changed, 45 insertions(+)
>
> diff --git a/lib/blobchunk.c b/lib/blobchunk.c
> index bbc69cf..69c70e9 100644
> --- a/lib/blobchunk.c
> +++ b/lib/blobchunk.c
> @@ -309,6 +309,24 @@ int erofs_blob_write_chunked_file(struct erofs_inode *inode, int fd,
> minextblks = BLK_ROUND_UP(sbi, inode->i_size);
> interval_start = 0;
>
> + /*
> + * dsunit <= chunksize, deduplication will not cause unalignment,
> + * we can do align with confidence
> + */
> + if (sbi->bmgr->dsunit > 1 &&
> + sbi->bmgr->dsunit <= 1u << (chunkbits - sbi->blkszbits)) {
Sigh, I meant (sbi->bmgr->dsunit >= 1u << (chunkbits - sbi->blkszbits))
Let's ignore sbi->bmgr->dsunit < 1u << (chunkbits - sbi->blkszbits).
Thanks,
Gao Xiang
More information about the Linux-erofs
mailing list