)]}'
{
  "commit": "f1dd2cd13c4bbbc9a7c4617b3b034fa643de98fe",
  "tree": "0d2a224cf6ae6ed6da10070c8503ab0fa4d1878a",
  "parents": [
    "d336e94e448a514607551026f0624329b6af52c5"
  ],
  "author": {
    "name": "Michal Hocko",
    "email": "mhocko@suse.com",
    "time": "Thu Jul 06 15:38:11 2017 -0700"
  },
  "committer": {
    "name": "Linus Torvalds",
    "email": "torvalds@linux-foundation.org",
    "time": "Thu Jul 06 16:24:32 2017 -0700"
  },
  "message": "mm, memory_hotplug: do not associate hotadded memory to zones until online\n\nThe current memory hotplug implementation relies on having all the\nstruct pages associate with a zone/node during the physical hotplug\nphase (arch_add_memory-\u003e__add_pages-\u003e__add_section-\u003e__add_zone).  In the\nvast majority of cases this means that they are added to ZONE_NORMAL.\nThis has been so since 9d99aaa31f59 (\"[PATCH] x86_64: Support memory\nhotadd without sparsemem\") and it wasn\u0027t a big deal back then because\nmovable onlining didn\u0027t exist yet.\n\nMuch later memory hotplug wanted to (ab)use ZONE_MOVABLE for movable\nonlining 511c2aba8f07 (\"mm, memory-hotplug: dynamic configure movable\nmemory and portion memory\") and then things got more complicated.\nRather than reconsidering the zone association which was no longer\nneeded (because the memory hotplug already depended on SPARSEMEM) a\nconvoluted semantic of zone shifting has been developed.  Only the\ncurrently last memblock or the one adjacent to the zone_movable can be\nonlined movable.  This essentially means that the online type changes as\nthe new memblocks are added.\n\nLet\u0027s simulate memory hot online manually\n  $ echo 0x100000000 \u003e /sys/devices/system/memory/probe\n  $ grep . /sys/devices/system/memory/memory32/valid_zones\n  Normal Movable\n\n  $ echo $((0x100000000+(128\u003c\u003c20))) \u003e /sys/devices/system/memory/probe\n  $ grep . /sys/devices/system/memory/memory3?/valid_zones\n  /sys/devices/system/memory/memory32/valid_zones:Normal\n  /sys/devices/system/memory/memory33/valid_zones:Normal Movable\n\n  $ echo $((0x100000000+2*(128\u003c\u003c20))) \u003e /sys/devices/system/memory/probe\n  $ grep . /sys/devices/system/memory/memory3?/valid_zones\n  /sys/devices/system/memory/memory32/valid_zones:Normal\n  /sys/devices/system/memory/memory33/valid_zones:Normal\n  /sys/devices/system/memory/memory34/valid_zones:Normal Movable\n\n  $ echo online_movable \u003e /sys/devices/system/memory/memory34/state\n  $ grep . /sys/devices/system/memory/memory3?/valid_zones\n  /sys/devices/system/memory/memory32/valid_zones:Normal\n  /sys/devices/system/memory/memory33/valid_zones:Normal Movable\n  /sys/devices/system/memory/memory34/valid_zones:Movable Normal\n\nThis is an awkward semantic because an udev event is sent as soon as the\nblock is onlined and an udev handler might want to online it based on\nsome policy (e.g.  association with a node) but it will inherently race\nwith new blocks showing up.\n\nThis patch changes the physical online phase to not associate pages with\nany zone at all.  All the pages are just marked reserved and wait for\nthe onlining phase to be associated with the zone as per the online\nrequest.  There are only two requirements\n\n\t- existing ZONE_NORMAL and ZONE_MOVABLE cannot overlap\n\n\t- ZONE_NORMAL precedes ZONE_MOVABLE in physical addresses\n\nthe latter one is not an inherent requirement and can be changed in the\nfuture.  It preserves the current behavior and made the code slightly\nsimpler.  This is subject to change in future.\n\nThis means that the same physical online steps as above will lead to the\nfollowing state: Normal Movable\n\n  /sys/devices/system/memory/memory32/valid_zones:Normal Movable\n  /sys/devices/system/memory/memory33/valid_zones:Normal Movable\n\n  /sys/devices/system/memory/memory32/valid_zones:Normal Movable\n  /sys/devices/system/memory/memory33/valid_zones:Normal Movable\n  /sys/devices/system/memory/memory34/valid_zones:Normal Movable\n\n  /sys/devices/system/memory/memory32/valid_zones:Normal Movable\n  /sys/devices/system/memory/memory33/valid_zones:Normal Movable\n  /sys/devices/system/memory/memory34/valid_zones:Movable\n\nImplementation:\nThe current move_pfn_range is reimplemented to check the above\nrequirements (allow_online_pfn_range) and then updates the respective\nzone (move_pfn_range_to_zone), the pgdat and links all the pages in the\npfn range with the zone/node.  __add_pages is updated to not require the\nzone and only initializes sections in the range.  This allowed to\nsimplify the arch_add_memory code (s390 could get rid of quite some of\ncode).\n\ndevm_memremap_pages is the only user of arch_add_memory which relies on\nthe zone association because it only hooks into the memory hotplug only\nhalf way.  It uses it to associate the new memory with ZONE_DEVICE but\ndoesn\u0027t allow it to be {on,off}lined via sysfs.  This means that this\nparticular code path has to call move_pfn_range_to_zone explicitly.\n\nThe original zone shifting code is kept in place and will be removed in\nthe follow up patch for an easier review.\n\nPlease note that this patch also changes the original behavior when\nofflining a memory block adjacent to another zone (Normal vs.  Movable)\nused to allow to change its movable type.  This will be handled later.\n\n[richard.weiyang@gmail.com: simplify zone_intersects()]\n  Link: http://lkml.kernel.org/r/20170616092335.5177-1-richard.weiyang@gmail.com\n[richard.weiyang@gmail.com: remove duplicate call for set_page_links]\n  Link: http://lkml.kernel.org/r/20170616092335.5177-2-richard.weiyang@gmail.com\n[akpm@linux-foundation.org: remove unused local `i\u0027]\nLink: http://lkml.kernel.org/r/20170515085827.16474-12-mhocko@kernel.org\nSigned-off-by: Michal Hocko \u003cmhocko@suse.com\u003e\nSigned-off-by: Wei Yang \u003crichard.weiyang@gmail.com\u003e\nTested-by: Dan Williams \u003cdan.j.williams@intel.com\u003e\nTested-by: Reza Arbab \u003carbab@linux.vnet.ibm.com\u003e\nAcked-by: Heiko Carstens \u003cheiko.carstens@de.ibm.com\u003e # For s390 bits\nAcked-by: Vlastimil Babka \u003cvbabka@suse.cz\u003e\nCc: Martin Schwidefsky \u003cschwidefsky@de.ibm.com\u003e\nCc: Andi Kleen \u003cak@linux.intel.com\u003e\nCc: Andrea Arcangeli \u003caarcange@redhat.com\u003e\nCc: Balbir Singh \u003cbsingharora@gmail.com\u003e\nCc: Daniel Kiper \u003cdaniel.kiper@oracle.com\u003e\nCc: David Rientjes \u003crientjes@google.com\u003e\nCc: Igor Mammedov \u003cimammedo@redhat.com\u003e\nCc: Jerome Glisse \u003cjglisse@redhat.com\u003e\nCc: Joonsoo Kim \u003cjs1304@gmail.com\u003e\nCc: Mel Gorman \u003cmgorman@suse.de\u003e\nCc: Tobias Regnery \u003ctobias.regnery@gmail.com\u003e\nCc: Toshi Kani \u003ctoshi.kani@hpe.com\u003e\nCc: Vitaly Kuznetsov \u003cvkuznets@redhat.com\u003e\nCc: Xishi Qiu \u003cqiuxishi@huawei.com\u003e\nCc: Yasuaki Ishimatsu \u003cisimatu.yasuaki@jp.fujitsu.com\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": "39e2aeb4669daa2277072e63ff53b57da3d79652",
      "old_mode": 33188,
      "old_path": "arch/ia64/mm/init.c",
      "new_id": "80db57d063d03bdf4c9fc2a46148967ca518dc16",
      "new_mode": 33188,
      "new_path": "arch/ia64/mm/init.c"
    },
    {
      "type": "modify",
      "old_id": "e6b2e6618b6c5115da85cb7adc627d5843274ad1",
      "old_mode": 33188,
      "old_path": "arch/powerpc/mm/mem.c",
      "new_id": "72c46eb532151402ac34b352dd2e057ef73f7960",
      "new_mode": 33188,
      "new_path": "arch/powerpc/mm/mem.c"
    },
    {
      "type": "modify",
      "old_id": "a3d549966b6a4d8a57e1710686ec818290b8c243",
      "old_mode": 33188,
      "old_path": "arch/s390/mm/init.c",
      "new_id": "bfa918e3592be0f34e24a1d6d177bba3fad6a71b",
      "new_mode": 33188,
      "new_path": "arch/s390/mm/init.c"
    },
    {
      "type": "modify",
      "old_id": "a9d57f75ae8c4f3e4b7380534d1215cd7a5e1c4c",
      "old_mode": 33188,
      "old_path": "arch/sh/mm/init.c",
      "new_id": "3813a610a2bb73b0e6ecba10296c4a0eb7f1c00c",
      "new_mode": 33188,
      "new_path": "arch/sh/mm/init.c"
    },
    {
      "type": "modify",
      "old_id": "94594b88914443f7fff9e1690fe94ce271c579de",
      "old_mode": 33188,
      "old_path": "arch/x86/mm/init_32.c",
      "new_id": "a424066d05526851e2643b575ffe6345e3a36df1",
      "new_mode": 33188,
      "new_path": "arch/x86/mm/init_32.c"
    },
    {
      "type": "modify",
      "old_id": "9d64291459b638a69954b48d06c9d68637c9e2d7",
      "old_mode": 33188,
      "old_path": "arch/x86/mm/init_64.c",
      "new_id": "06afa84ac0a0100f8221907359ebe07f092d0861",
      "new_mode": 33188,
      "new_path": "arch/x86/mm/init_64.c"
    },
    {
      "type": "modify",
      "old_id": "1e884d82af6fcfebe02db0e20564d1c9ce50e71f",
      "old_mode": 33188,
      "old_path": "drivers/base/memory.c",
      "new_id": "b86fda30ce62bc3ac1bda245baac7198a28743d7",
      "new_mode": 33188,
      "new_path": "drivers/base/memory.c"
    },
    {
      "type": "modify",
      "old_id": "a61aede1b3911f3102f98c7060e1c95a374c4c8e",
      "old_mode": 33188,
      "old_path": "include/linux/memory_hotplug.h",
      "new_id": "8a07a49fd8dc2280fc228ec6b0091c7e8df848e4",
      "new_mode": 33188,
      "new_path": "include/linux/memory_hotplug.h"
    },
    {
      "type": "modify",
      "old_id": "2aaf7e08c5a85feb4403da19a68383be882c2c77",
      "old_mode": 33188,
      "old_path": "include/linux/mmzone.h",
      "new_id": "abc1641011f209dfca81c89d004413d68be07e13",
      "new_mode": 33188,
      "new_path": "include/linux/mmzone.h"
    },
    {
      "type": "modify",
      "old_id": "23a6483c3666e35fec7f927d2f6cd4a2e38dbe81",
      "old_mode": 33188,
      "old_path": "kernel/memremap.c",
      "new_id": "281eb478856a952348c1074af42d9da33a8e0438",
      "new_mode": 33188,
      "new_path": "kernel/memremap.c"
    },
    {
      "type": "modify",
      "old_id": "b2ebe9ad7f6cd2e73f90be6ac70c54cca08ef074",
      "old_mode": 33188,
      "old_path": "mm/memory_hotplug.c",
      "new_id": "9438ffe24cb29d82a2192055bf33d30844079976",
      "new_mode": 33188,
      "new_path": "mm/memory_hotplug.c"
    },
    {
      "type": "modify",
      "old_id": "9d7fd666015ee04eddb410a55a466673ba37c8ce",
      "old_mode": 33188,
      "old_path": "mm/sparse.c",
      "new_id": "7b4be3fd5cac074177b7f17ebdeb12dfa56d22e5",
      "new_mode": 33188,
      "new_path": "mm/sparse.c"
    }
  ]
}
