)]}'
{
  "commit": "04f2cbe35699d22dbf428373682ead85ca1240f5",
  "tree": "1987a2c704cc97d8adf603054c9d89d18b9b30e0",
  "parents": [
    "a1e78772d72b2616ed20e54896e68e0e7044854e"
  ],
  "author": {
    "name": "Mel Gorman",
    "email": "mel@csn.ul.ie",
    "time": "Wed Jul 23 21:27:25 2008 -0700"
  },
  "committer": {
    "name": "Linus Torvalds",
    "email": "torvalds@linux-foundation.org",
    "time": "Thu Jul 24 10:47:16 2008 -0700"
  },
  "message": "hugetlb: guarantee that COW faults for a process that called mmap(MAP_PRIVATE) on hugetlbfs will succeed\n\nAfter patch 2 in this series, a process that successfully calls mmap() for\na MAP_PRIVATE mapping will be guaranteed to successfully fault until a\nprocess calls fork().  At that point, the next write fault from the parent\ncould fail due to COW if the child still has a reference.\n\nWe only reserve pages for the parent but a copy must be made to avoid\nleaking data from the parent to the child after fork().  Reserves could be\ntaken for both parent and child at fork time to guarantee faults but if\nthe mapping is large it is highly likely we will not have sufficient pages\nfor the reservation, and it is common to fork only to exec() immediatly\nafter.  A failure here would be very undesirable.\n\nNote that the current behaviour of mainline with MAP_PRIVATE pages is\npretty bad.  The following situation is allowed to occur today.\n\n1. Process calls mmap(MAP_PRIVATE)\n2. Process calls mlock() to fault all pages and makes sure it succeeds\n3. Process forks()\n4. Process writes to MAP_PRIVATE mapping while child still exists\n5. If the COW fails at this point, the process gets SIGKILLed even though it\n   had taken care to ensure the pages existed\n\nThis patch improves the situation by guaranteeing the reliability of the\nprocess that successfully calls mmap().  When the parent performs COW, it\nwill try to satisfy the allocation without using reserves.  If that fails\nthe parent will steal the page leaving any children without a page.\nFaults from the child after that point will result in failure.  If the\nchild COW happens first, an attempt will be made to allocate the page\nwithout reserves and the child will get SIGKILLed on failure.\n\nTo summarise the new behaviour:\n\n1. If the original mapper performs COW on a private mapping with multiple\n   references, it will attempt to allocate a hugepage from the pool or\n   the buddy allocator without using the existing reserves. On fail, VMAs\n   mapping the same area are traversed and the page being COW\u0027d is unmapped\n   where found. It will then steal the original page as the last mapper in\n   the normal way.\n\n2. The VMAs the pages were unmapped from are flagged to note that pages\n   with data no longer exist. Future no-page faults on those VMAs will\n   terminate the process as otherwise it would appear that data was corrupted.\n   A warning is printed to the console that this situation occured.\n\n2. If the child performs COW first, it will attempt to satisfy the COW\n   from the pool if there are enough pages or via the buddy allocator if\n   overcommit is allowed and the buddy allocator can satisfy the request. If\n   it fails, the child will be killed.\n\nIf the pool is large enough, existing applications will not notice that\nthe reserves were a factor.  Existing applications depending on the\nno-reserves been set are unlikely to exist as for much of the history of\nhugetlbfs, pages were prefaulted at mmap(), allocating the pages at that\npoint or failing the mmap().\n\n[npiggin@suse.de: fix CONFIG_HUGETLB\u003dn build]\nSigned-off-by: Mel Gorman \u003cmel@csn.ul.ie\u003e\nAcked-by: Adam Litke \u003cagl@us.ibm.com\u003e\nCc: Andy Whitcroft \u003capw@shadowen.org\u003e\nCc: William Lee Irwin III \u003cwli@holomorphy.com\u003e\nCc: Hugh Dickins \u003chugh@veritas.com\u003e\nCc: Nick Piggin \u003cnpiggin@suse.de\u003e\nSigned-off-by: Andrew Morton \u003cakpm@linux-foundation.org\u003e\nSigned-off-by: Linus Torvalds \u003ctorvalds@linux-foundation.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "1576bbecd084575e2cb97fffe6846c2039309dd5",
      "old_mode": 33188,
      "old_path": "fs/hugetlbfs/inode.c",
      "new_id": "428eff5b73f35a399717590e8f6b6b8492b6a239",
      "new_mode": 33188,
      "new_path": "fs/hugetlbfs/inode.c"
    },
    {
      "type": "modify",
      "old_id": "185b14c9f021fb9d3fb76ae6a1296f8e71206a73",
      "old_mode": 33188,
      "old_path": "include/linux/hugetlb.h",
      "new_id": "abbc187193a1b9435b86daeb2462b4f20cc3b016",
      "new_mode": 33188,
      "new_path": "include/linux/hugetlb.h"
    },
    {
      "type": "modify",
      "old_id": "0af500db3632e809956b4acc8f8580724efa628d",
      "old_mode": 33188,
      "old_path": "mm/hugetlb.c",
      "new_id": "a2d29b84501f104227244b1a0fd9bad30da7467f",
      "new_mode": 33188,
      "new_path": "mm/hugetlb.c"
    },
    {
      "type": "modify",
      "old_id": "82f3f1c5cf171eb869269f85d590c69290040ccb",
      "old_mode": 33188,
      "old_path": "mm/memory.c",
      "new_id": "72932489a082c313998a0cebb1ce62cdd40c769a",
      "new_mode": 33188,
      "new_path": "mm/memory.c"
    }
  ]
}
