shmem_recalc_inode(9)
โจ NAME โจ
Okay bestie, this is shmem_recalc_inode(9) from the Kernel API Manual, and it does exactly what the name says: recalculate the block usage of an inode. Periodt. ๐
๐ธ SYNOPSIS ๐ธ
bool shmem_recalc_inode (struct inode *inode , long alloced , long
swapped );
๐ ARGUMENTS ๐
inodeโ the inode weโre recalculating, no cap.allocedโ the change in number of pages allocated toinode.swappedโ the change in number of pages swapped frominode.
๐ DESCRIPTION ๐
So hereโs the tea: we have to calculate the free blocks since the mm can drop undirtied hole pages behind our back. ๐ญ
But normally, itโs giving this exact equation:
info->alloced == inode->i_mapping->nrpages + info->swapped
So the mm freed amount is literally:
info->alloced - (inode->i_mapping->nrpages + info->swapped)
Thatโs the whole math vibe, iykyk. ๐งฎโจ
๐ซถ RETURN ๐ซถ
It returns true if swapped was incremented from 0 โ specifically for shmem_writeout. Slay. โ
๐ฅ SEE ALSO ๐ฅ
The kernel file lore lives in ./mm/shmem.c, and the squad to check out is:
shmem_writeout(9)shmem_get_folio(9)shmem_kernel_file_setup(9)shmem_file_setup(9)shmem_file_setup_with_mnt(9)shmem_zero_setup(9)shmem_zero_setup_desc(9)shmem_read_folio_gfp(9)
k bye bestie โ source/version info is ./mm, dated October 2026, mwah ๐โจ
๐ฆ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms