Re: mmap how does kernel know a page is mmaped

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

 



On Thu, 25 Jul 2013 14:33:21 -0400, Greg Freemyer said:

> There are 3 situations I can think of offhand, but I don't know which
> one you are interested in:
>
> 1) Userspace does a read/write to a data page that is not memory
> resident and the page is backed by a mmap'ed file.
>
> 2) Userspace does a read/write to a data page that is memory resident
>
> 3) The kernel decides a memory page is needed for another use and
> needs to be sync'ed to disk if any data updates are not to be lost.

And here, the kernel can cheat some more and re-use existing code.  There's 2
parts to it:

A) Writeback a page - which can be done the exact same way that any other page
gets written back to disk.  Only difference is writing to an offset in a file
as opposed to an offset in a swap space.  And if you consider the case of doing
a 'swapon' on a regular disk file, there's no real difference between "write
page 38F3E to block 3 of swap space on file /foo/bar/swap3" and "write page
38F3E to block 3 of file /foo/bar/swap3".

Similarly, the retrieval of a non-resident page backed by an mmap file is
pretty much the same as retrieving a non-resident page backed by swap space.

B) Possibly invalidate the mapping, because the page frame is needed.
At which point, future references to that page end up in case (1) above.



Attachment: pgp81Ide9w6bF.pgp
Description: PGP signature

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[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