vm_stat_account
void vm_stat_account(struct mm_struct *mm, vm_flags_t flags, long npages)
{
mm->total_vm += npages;
if (is_exec_mapping(flags))
mm->exec_vm += npages;
else if (is_stack_mapping(flags))
mm->stack_vm += npages;
else if (is_data_mapping(flags))
mm->data_vm += npages;
}
最初这些page都是匿名页或者是文件页
239 /*
240 * Executable code area - executable, not writable, not stack
241 */
242 static inline bool is_exec_mapping(vm_flags_t flags) ---- 这里使用的是文件页
243 {
244 return (flags & (VM_EXEC | VM_WRITE | VM_STACK)) == VM_EXEC;
245 }
246
247 /*
248 * Stack area - atomatically grows in one direction
249 *
250 * VM_GROWSUP / VM_GROWSDOWN VMAs are always private anonymous:
251 * do_mmap() forbids all other combinations.
252 */
253 static inline bool is_stack_mapping(vm_flags_t flags) ---- 匿名页
254 {
255 return (flags & VM_STACK) == VM_STACK;
256 }
257
258 /*
259 * Data area - private, writable, not stack
260 */
261 static inline bool is_data_mapping(vm_flags_t flags) ---- 匿名页
262 {
263 return (flags & (VM_WRITE | VM_SHARED | VM_STACK)) == VM_WRITE;
264 }