Re: mmap() and remap_page_range()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>>> "Nat" == Nat Ersoz <nat.ersoz@myrio.com> writes:
Nat> He references the char/mem.c device driver in the linux kernel,
Nat> and using that code provides an example of phsyical memory
Nat> mapping to a process virtual address.  The code I'm interested in
Nat> is attached to the bottom.  Specifically, I'm confused as to the
Nat> usage of the line of code:

Nat> 	/* Don't try to swap out physical pages.. */
vma-> vm_flags |= VM_RESERVED;

Nat> I want to do this in my own code: map a physical device page of
Nat> memory to user space, and be sure its not swapped out.  What
Nat> confuses me is that vma->vm_flags never seems to get used by any
Nat> of char/mem.c or any or Rubini's discussion examples.

Nat> Does this code actually do anything?  Can someone explain how?

It does, e.g. see swap_out_pmd below:

/* mm->page_table_lock is held. mmap_sem is not held */
static inline int swap_out_pmd(struct mm_struct * mm, struct vm_area_struct * vma, pmd_t *dir, unsigned long address, unsigned long end, int count, zone_t * classzone)
{
[...]
	do {
		if (pte_present(*pte)) {
			struct page *page = pte_page(*pte);

			if (VALID_PAGE(page) && !PageReserved(page)) {
				count -= try_to_swap_out(mm, vma, address, pte, page, classzone);
[...]
			}
		}
		address += PAGE_SIZE;
		pte++;
	} while (address && (address < end));
	mm->swap_address = address;
	return count;
}
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux