Thread (66 messages) 66 messages, 4 authors, 2020-07-21

Re: [PATCH v16 13/22] mm/lru: introduce TestClearPageLRU

From: Alex Shi <hidden>
Date: 2020-07-19 11:24:18
Also in: linux-mm, lkml


在 2020/7/19 下午12:45, Alex Shi 写道:
quoted
quoted
quoted
It might make it more readable to pull in the later patch that
modifies isolate_lru_pages that has it using TestClearPageLRU.
As to this change, It has to do in this patch, since any TestClearPageLRU may
cause lru bit miss in the lru list, so the precondication check has to
removed here.
So I think some of my cognitive dissonance is from the fact that you
really are doing two different things here. You aren't really
implementing the full TestClearPageLRU until patch 15. So this patch
is doing part of 2a and 2b, and then patch 15 is following up and
completing the 2a cases. I still think it might make more sense to
pull out the pieces related to 2b and move them into a patch before
this with documentation explaining that there should be no competition
for the LRU flag because the page has transitioned to a reference
count of zero. Then take the remaining bits and combine them with
patch 15 since the description for the two is pretty similar.

As to the patch split suggest, actually, Hugh and I talked about a few weeks 
ago when he give me these changes. We both thought keep these changes in this
patch looks better at that time.
If it make you confuse, don't know a changed commit log make it better?

Thanks
Alex

    mm/lru: introduce TestClearPageLRU

    Currently lru_lock still guards both lru list and page's lru bit, that's
    ok. but if we want to use specific lruvec lock on the page, we need to
    pin down the page's lruvec/memcg during locking. Just taking lruvec
    lock first may be undermined by the page's memcg charge/migration. To
    fix this problem, we could take out the page's lru bit clear and use
    it as pin down action to block the memcg changes. That's the reason
    for new atomic func TestClearPageLRU. So now isolating a page need both
    actions: TestClearPageLRU and hold the lru_lock.

    This patch combines PageLRU check and ClearPageLRU into a macro func
    TestClearPageLRU. This function will be used as page isolation
    precondition to prevent other isolations some where else.
    Then there are may non PageLRU page on lru list, need to remove BUG
    checking accordingly.

    There 2 rules for lru bit:
    1, the lru bit still indicate if a page on lru list, just
    in some temporary moment(isolating), the page may have no lru bit when
    it's on lru list.  but the page still must be on lru list when the
    lru bit is set.
    2, have to remove lru bit before delete it from lru list.

    Hugh Dickins pointed that when a page is in freeing path and no one is
    possible to take it, non atomic lru bit clearing is better, like in
    __page_cache_release and release_pages.
    ANd no need get_page() before lru bit clear in isolate_lru_page,
    since it '(1) Must be called with an elevated refcount on the page'.

    As Andrew Morton mentioned this change would dirty cacheline for page
    isn't on LRU. But the lost would be acceptable with Rong Chen
    [off-list ref] report:
    https://lkml.org/lkml/2020/3/4/173

    Suggested-by: Johannes Weiner [off-list ref]
    Signed-off-by: Alex Shi [off-list ref]
    Cc: Hugh Dickins [off-list ref]
    Cc: Johannes Weiner [off-list ref]
    Cc: Michal Hocko [off-list ref]
    Cc: Vladimir Davydov [off-list ref]
    Cc: Andrew Morton [off-list ref]
    Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
    Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
    Cc: linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help