• Michal Hocko's avatar
    mm, memory_hotplug: get rid of zonelists_mutex · b93e0f32
    Michal Hocko authored
    zonelists_mutex was introduced by commit 4eaf3f64 ("mem-hotplug: fix
    potential race while building zonelist for new populated zone") to
    protect zonelist building from races.  This is no longer needed though
    because both memory online and offline are fully serialized.  New users
    have grown since then.
    
    Notably setup_per_zone_wmarks wants to prevent from races between memory
    hotplug, khugepaged setup and manual min_free_kbytes update via sysctl
    (see cfd3da1e ("mm: Serialize access to min_free_kbytes").  Let's
    add a private lock for that purpose.  This will not prevent from seeing
    halfway through memory hotplug operation but that shouldn't be a big
    deal becuse memory hotplug will update watermarks explicitly so we will
    eventually get a full picture.  The lock just makes sure we won't race
    when updating watermarks leading to weird results.
    
    Also __build_all_zonelists manipulates global data so add a private lock
    for it as well.  This doesn't seem to be necessary today but it is more
    robust to have a lock there.
    
    While we are at it make sure we document that memory online/offline
    depends on a full serialization either via mem_hotplug_begin() or
    device_lock.
    
    Link: http://lkml.kernel.org/r/20170721143915.14161-9-mhocko@kernel.orgSigned-off-by: default avatarMichal Hocko <mhocko@suse.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Joonsoo Kim <js1304@gmail.com>
    Cc: Mel Gorman <mgorman@suse.de>
    Cc: Shaohua Li <shaohua.li@intel.com>
    Cc: Toshi Kani <toshi.kani@hpe.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: Haicheng Li <haicheng.li@linux.intel.com>
    Cc: Wu Fengguang <fengguang.wu@intel.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    b93e0f32
memory_hotplug.c 49 KB