Skip to contentSkip to conversation

node_pagecache_reclaimable() seems not accurate

DISCUSSION Hao Lee 1 participant 1 message Jan 17, 2020 Memory management

lore
Share & tools
lore

Hao Lee

author
#0 lore raw

Hi, I have found the node_pagecache_reclaimable() function can't calculate reclaimable pages accurately.

If reclaim mode doesn't allow UNMAP and WRITE operations, this function will perform the following calculation:

reclaimable file pages = total unmapped file pages - vm_stat[NR_FILE_DIRTY]

If NR_FILE_DIRTY only counts unmapped dirty pages, the result will be unmapped clean pages. This indeed makes sense.

However, I find vm_stat[NR_FILE_DIRTY] also counts some *mapped* dirty pages. If we subtract these mapped pages from unmapped pages, I don't think this is reasonable.

This code path can account dirty pages into NR_FILE_DIRTY:

account_page_dirtied+0x0/0x2d8
mark_buffer_dirty+0x16c/0x1a0
__block_commit_write.isra.11+0xa8/0xf0
block_write_end+0x58/0xb0
generic_write_end+0x5c/0xc0
ext4_da_write_end+0x128/0x2e8 [ext4]
generic_perform_write+0x108/0x1a8
__generic_file_write_iter+0x158/0x1c8
ext4_file_write_iter+0x120/0x3e8 [ext4]
__vfs_write+0x11c/0x190
vfs_write+0xac/0x1c0
ksys_write+0x74/0xf0
__arm64_sys_write+0x24/0x30
el0_svc_common+0x78/0x130
el0_svc_handler+0x38/0x78
el0_svc+0x8/0xc

Regards,
Hao Lee