• A
    mm/compaction: do page isolation first in compaction · d74ec531
    Alex Shi 提交于
    mainline inclusion
    from mainline-v5.11-rc1
    commit 9df41314
    category: feature
    bugzilla: https://gitee.com/openeuler/kernel/issues/I3ZF7C?from=project-issue
    CVE: NA
    
    --------------------------------------
    
    Currently, compaction would get the lru_lock and then do page isolation
    which works fine with pgdat->lru_lock, since any page isoltion would
    compete for the lru_lock.  If we want to change to memcg lru_lock, we have
    to isolate the page before getting lru_lock, thus isoltion would block
    page's memcg change which relay on page isoltion too.  Then we could
    safely use per memcg lru_lock later.
    
    The new page isolation use previous introduced TestClearPageLRU() + pgdat
    lru locking which will be changed to memcg lru lock later.
    
    Hugh Dickins <hughd@google.com> fixed following bugs in this patch's early
    version:
    
    Fix lots of crashes under compaction load: isolate_migratepages_block()
    must clean up appropriately when rejecting a page, setting PageLRU again
    if it had been cleared; and a put_page() after get_page_unless_zero()
    cannot safely be done while holding locked_lruvec - it may turn out to be
    the final put_page(), which will take an lruvec lock when PageLRU.
    
    And move __isolate_lru_page_prepare back after get_page_unless_zero to
    make trylock_page() safe: trylock_page() is not safe to use at this time:
    its setting PG_locked can race with the page being freed or allocated
    ("Bad page"), and can also erase flags being set by one of those "sole
    owners" of a freshly allocated page who use non-atomic __SetPageFlag().
    
    Link: https://lkml.kernel.org/r/1604566549-62481-16-git-send-email-alex.shi@linux.alibaba.comSuggested-by: NJohannes Weiner <hannes@cmpxchg.org>
    Signed-off-by: NAlex Shi <alex.shi@linux.alibaba.com>
    Acked-by: NHugh Dickins <hughd@google.com>
    Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
    Acked-by: NVlastimil Babka <vbabka@suse.cz>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: Alexander Duyck <alexander.duyck@gmail.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
    Cc: "Chen, Rong A" <rong.a.chen@intel.com>
    Cc: Daniel Jordan <daniel.m.jordan@oracle.com>
    Cc: "Huang, Ying" <ying.huang@intel.com>
    Cc: Jann Horn <jannh@google.com>
    Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
    Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Cc: Kirill A. Shutemov <kirill@shutemov.name>
    Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
    Cc: Mel Gorman <mgorman@techsingularity.net>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Mika Penttilä <mika.penttila@nextfour.com>
    Cc: Minchan Kim <minchan@kernel.org>
    Cc: Shakeel Butt <shakeelb@google.com>
    Cc: Tejun Heo <tj@kernel.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
    Cc: Wei Yang <richard.weiyang@gmail.com>
    Cc: Yang Shi <yang.shi@linux.alibaba.com>
    Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: NJing Xiangfeng <jingxiangfeng@huawei.com>
    Reviewed-by: Nchenwandun <chenwandun@huawei.com>
    Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
    d74ec531
swap.h 22.1 KB