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...@sony.com>
Reviewed-by: Yuezhang Mo <yuezhang...@sony.com>
Reviewed-by: Daniel Palmer <daniel.pal...@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