Memory de-duplication in the Linux kernel -


Can anyone explain me the algorithm included in memory de-duplication in the Linux kernel

It is difficult to understand and implement it. Can anyone explain this in simple steps?

The article you linked appears to be quite straightforward.

  1. The application advises the kernel (by using madvise () syscall) some areas of that memory may have duplicate pages.
  2. KSMD adds pages in this area to "unstable list" (tree actually, for ease of viewing later). "Volatile" means that pages are still likely to change.
  3. Checksum is calculated in the "volatile" list for each page The code will scan all the pages in the KSMD list and see if the checksum had changed. If it is really different every time, then nothing should be done (the page is still "unstable".)
  4. After the notice of some scanned KSMD , that the checksum page for some particular was stopped changing between iterations (the page was "static"), this "stable" list Can be kept on.
  5. KSMD will scan all existing pages in the "Fixed" list to see if there is already a page that matches the contents of the candidate's page. If such a page is found, then the candidate's page is abandoned, and the current page is read only after the "steady" list (and the relevant reference number for the static page has increased).
  6. If you now find pages in the "Fixed" list, then the candidate page is marked as "Read only" and is moved from "Unstable" to a constant from the list.
  7. If the app will hit a "security error" inside the kernel on the "Fixed" page, invite ksmd to check if the error control page is on the "Stable" list. If so, it will make a written copy of that page and bring it back to the "volatile" list, removes the "static" page from the address of the application and the reference number of the "static" page (if it is counted at this level, "Freeze" page is free).

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -