Re: mmap() and remap_page_range()

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

 



Hi,

I was trying to understand the issue, but there is one point I didn't get:

In the char/mem.c driver code, the VM_RESERVED flag is set in the vma structure. The swap_out_pmd() function uses the PageReserved() macro, to check if a page structure's
PG_reserved flag is set. Did I overlook something, or is there any relation between a vma structure's  VM_RESERVED flag and the page structures's PG_reserved flag.

Also I noticed, that pte_remap_page_range() which is called during execution of remap_page_range() does explicitely check the PG_reserved flag of the page to be mapped (as
shown in the subsequent lines of code).

if ((!VALID_PAGE(page)) || PageReserved(page))
                         set_pte(pte, mk_pte_phys(phys_addr, prot));

So why does the memory mapping with the remap_page_range() call of the char/mem.c driver succeed although it doesn't set the reserved bit of the corresponding page
structure (but only of the corresponding vm area)?

thanks for your help
regards
Martin

Nat Ersoz wrote:

> Thanks for the response.  I think I understand now.
>
> -----Original Message-----
> From: Momchil Velikov [mailto:velco@fadata.bg]
> Sent: Tuesday, January 29, 2002 12:19 AM
> To: Nat Ersoz
> Cc: kernelnewbies@nl.linux.org
> Subject: Re: mmap() and remap_page_range()
>
> >>>>> "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/
>
> --
> 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/

--
Supercomputing System AG          email: maletinsky@scs.ch
Martin Maletinsky                 phone: +41 (0)1 445 16 05
Technoparkstrasse 1               fax:   +41 (0)1 445 16 10
CH-8005 Zurich


--
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