Linux-MM
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Linux Memory Management

  • Front Page

  • Documentation

  • Internals

  • Projects

  • Academic Research

References

  • LinuxKernelMailingLists

  • MemoryManagementLinks

Related sites

  • Kernel Newbies

  • Memory Management Forum

Wiki

  • Site Editors

  • Side Bar

  • Hosted by WikiWall

Navigation

  • RecentChanges
  • FindPage
  • HelpContents

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

LinuxMM:
  • FnAddToSwapInDetail

Under Construction

add_to_swap(), step by step

  • lives at mm/swap_state.c line 163
  • Receives two parameters: a struct page, which is the page to be swapped out; and a struct list_head, which is used only for the huge page case
  • Has two local variables: a swap_entry_t (which is a bitfield, so all "members" are extracted via macros), and an int to collect the returned error code from add_to_swap_cache().
  • Begins by asserting two conditions: that the page has been locked by the caller, and is up to date. It asserts with the BUG_ON macro, which invokes a kernel panic if the condition fails.
  • Allocates swap space for the page by calling get_swap_page(), which lives at swapfile.c line 640. Stores the handle to it in the local swap_entry_t.
  • handles the huge page case (which is beyond the scope of this article).
  • Inserts the swap entry into the kernel's swap management system by calling add_to_swap_cache(), which lives at swap_state.c line 121.
  • Marks the page as dirty, so that a kernel pdflush thread will do the actual write to disk, and exits returning 1 if it was successfully added to swap. Otherwise, if add_to_swap_cache returned an error code for an -ENOMEM allocation failure, cleans up by calling swapcache_free and exits returning 0.

Line numbers are current as of December 2013, in Linus' tree.

  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01