Skip to content
This repository has been archived by the owner on Dec 3, 2022. It is now read-only.

Latest commit

 

History

History
129 lines (81 loc) · 3.72 KB

vma-funcs.md

File metadata and controls

129 lines (81 loc) · 3.72 KB

VMA Functions

Contents

Memory Descriptor

VMA Helpers

  • vma_is_anonymous() - Determines if the specified VMA is anonymous (i.e. does not map a file.)

Function Descriptions

allocate_mm()

void *allocate_mm(void)

allocate_mm() simply allocates a new struct mm_struct from the slab allocator via kmem_cache_alloc().

NOTE: Macro, inferring function signature.

Arguments

N/A

Returns

A pointer to the newly allocated struct mm_struct.


free_mm()

void free_mm(struct mm_struct *mm)

free_mm() frees the specified struct mm_struct from the slab allocator via kmem_cache_free().

NOTE: Macro, inferring function signature.

Arguments

Returns

N/A


copy_mm()

int copy_mm(unsigned long clone_flags, struct task_struct *tsk)

copy_mm() copies the current task's struct mm_struct to the specified struct task_struct, resetting statistics as it does so.

The bulk of the actual duplication is performed by dup_mm() and dup_mmap() which copy the page tables too.

There are some exceptions:

  1. If clone_flags & CLONE_VM then the current task's struct mm_struct is shared rather than copied.

  2. If this is a kernel thread, i.e. there is no current->mm available, the copy is aborted.

Arguments

  • clone_flags - The clone flags associated with the copy, if it's the case that clone_flags & CLONE_VM, then the struct mm_struct is not copied and is instead shared.

  • tsk - The task whose mm field we want to assign a copy of the current task's struct mm_struct to.

Returns

0 if successful, error code otherwise.


vma_is_anonymous()

bool vma_is_anonymous(struct vm_area_struct *vma)

vma_is_anonymous() determines whether the specified VMA (i.e. struct vm_area_struct) is anonymous - an anonymous VMA is one that does not map a file but rather simply represents an area of memory unassociated with any file.

The function simply tests whether the VMA's vm_ops fields is null - if so, no operations are specified and so the VMA is anonymous, otherwise it is not.

Arguments

  • vma - The VMA whose anonymity we wish to determine.

Returns

true if the VMA is anonymous, otherwise false.