Re: What is vma->vm_pgoff

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

 



Tyler wrote:
Ketan Mukadam wrote:


Hi all,

I am trying to understand a little bit about linux VMM [Writing a device driver for linux].

What is  "unsigned long vm_pgoff;" ?

The comment in the mm.h says that
/* Offset (within vm_file) in PAGE_SIZE units, *not* PAGE_CACHE_SIZE */

But that did not made it clear....tried to 'google' it but to no avail...

can anyone explain me the use of this variable?

I think it's just the offset within the vma region (the relative adress to the beginning of the region if you want)
I guess it's only the offset in the file where the vma starts. Only a copy of the offset value passed in the mmap syscall. And it is stored in PAGE_SIZE units instead of bytes, maybe to allow mapping huge files, whose offsets in bytes would not fit in 'unsigned long' variables...

	Luciano Stertz

It is generally used in the driver's mmap implementation as following

unsigned long off = vma->vm_pgoff << PAGE_SHIFT;

This is equal to divide the offest by the number of possible pages. So we get here the offset in pages.



Thanks in advance

Regards
Ketan





--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/




--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



--
Luciano A. Stertz
luciano@xxxxxxxxxxxx
T&T Engenheiros Associados Ltda
http://www.tteng.com.br
Fone/Fax (51) 3224 8425

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[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