I have identified that the function do_swap_page in mm/memory.c is used to swap IN pages in the Linux kernel. However, the input parameters of this function contains one pte_t* and one pte_t. What is the difference between the use of these two parameters? Any help would be appreciated.
static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long address, pte_t *page_table, pmd_t *pmd,
unsigned int flags, pte_t orig_pte)
With 4.4 do_swap_page
still has many parameters: http://lxr.free-electrons.com/source/mm/memory.c?v=4.4#L2439
2446 static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
2447 unsigned long address, pte_t *page_table, pmd_t *pmd,
2448 unsigned int flags, pte_t orig_pte)
and it is called from handle_pte_fault
function http://lxr.free-electrons.com/source/mm/memory.c?v=4.4#L3257
3272 static int handle_pte_fault(struct mm_struct *mm,
3273 struct vm_area_struct *vma, unsigned long address,
3274 pte_t *pte, pmd_t *pmd, unsigned int flags)
3275 {
3276 pte_t entry;
3287 entry = *pte;
3289 if (!pte_present(entry)) {
3298 return do_swap_page(mm, vma, address,
3299 pte, pmd, flags, entry);
So, second pte_t orig_pte
is just copy of original pte, and pte_t *page_table
is the pointer to the pte entry which will be modified with new pte (actual code will be something like *page_table = pte
):
2560 pte = mk_pte(page, vma->vm_page_prot);
2570 set_pte_at(mm, address, page_table, pte);