linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Alex Shi <alex.shi@linux.alibaba.com>, "^["@box.kvack.org
Cc: Hugh Dickins <hughd@google.com>,
	Matthew Wilcox <willy@infradead.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	akpm@linux-foundation.org, mgorman@techsingularity.net,
	tj@kernel.org, khlebnikov@yandex-team.ru,
	daniel.m.jordan@oracle.com, yang.shi@linux.alibaba.com,
	lkp@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	cgroups@vger.kernel.org, shakeelb@google.com,
	iamjoonsoo.kim@lge.com, richard.weiyang@gmail.com
Subject: Re: [PATCH v14 07/20] mm/thp: narrow lru locking
Date: Fri, 10 Jul 2020 14:28:31 +0300	[thread overview]
Message-ID: <20200710112831.jrv4hzjzjqtxtc7u@box> (raw)
In-Reply-To: <e87f7dd1-41c4-3392-f1df-982dd28c0617@linux.alibaba.com>

On Fri, Jul 10, 2020 at 04:23:35PM +0800, Alex Shi wrote:
> 
> 
> 在 2020/7/9 下午11:48, Kirill A. Shutemov 写道:
> > On Mon, Jul 06, 2020 at 09:52:34PM -0700, Hugh Dickins wrote:
> >> On Mon, 6 Jul 2020, Matthew Wilcox wrote:
> >>> On Mon, Jul 06, 2020 at 05:15:09PM +0800, Alex Shi wrote:
> >>>> Hi Kirill & Johannes & Matthew,
> >>
> >> Adding Kirill, who was in patch's Cc list but not mail's Cc list.
> >>
> >> I asked Alex to direct this one particularly to Kirill and Johannes
> >> and Matthew because (and I regret that the commit message still does
> >> not make this at all clear) this patch changes the lock ordering:
> >> which for years has been lru_lock outside memcg move_lock outside
> >> i_pages lock, but here inverted to lru_lock inside i_pages lock.
> >>
> >> I don't see a strong reason to have them one way round or the other,
> >> and think Alex is right that they can safely be reversed here: but
> >> he doesn't actually give any reason for doing so (if cleanup, then
> >> I think the cleanup should have been taken further), and no reason
> >> for doing so as part of this series.
> > 
> > I've looked around and changing order of lru_lock wrt. i_pages lock seems
> > safe. I don't have much experience with memcg move_lock.
> 
> Hi Kirill,
> 
> Thanks for response!
> mem_cgroup_move_account(page) could not reach here since 2 blocks,
> 1, isolate_lru_page() before it will take page from lru, this compete for
>    page reclaim path, list non-null.
> 
> 2, try_lock_page in it, will guard split_huge_page(), !list.
> 
> > 
> > Alex, if you are going ahead with the patch, please document the locking
> > order. We have some locking orders listed at the beginning of filemap.c
> > and rmap.c.
> 
> Thanks for reminder!
> Hugh Dickins did this in above 2 files at the end of patchset, any comments?
> 
> diff --git a/mm/filemap.c b/mm/filemap.c
> index f0ae9a6308cb..1b42aaae4d3e 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -101,8 +101,8 @@
>   *    ->swap_lock		(try_to_unmap_one)
>   *    ->private_lock		(try_to_unmap_one)
>   *    ->i_pages lock		(try_to_unmap_one)
> - *    ->pgdat->lru_lock		(follow_page->mark_page_accessed)
> - *    ->pgdat->lru_lock		(check_pte_range->isolate_lru_page)
> + *    ->lruvec->lru_lock	(follow_page->mark_page_accessed)
> + *    ->lruvec->lru_lock	(check_pte_range->isolate_lru_page)
>   *    ->private_lock		(page_remove_rmap->set_page_dirty)
>   *    ->i_pages lock		(page_remove_rmap->set_page_dirty)
>   *    bdi.wb->list_lock		(page_remove_rmap->set_page_dirty)
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index d5e56be42f21..926d7d95dc1d 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -3057,7 +3057,7 @@ void __memcg_kmem_uncharge_page(struct page *page, int order)
>  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
>  
>  /*
> - * Because tail pages are not marked as "used", set it. We're under
> + * Because tail pages are not marked as "used", set it. Don't need
>   * lruvec->lru_lock and migration entries setup in all page mappings.
>   */
>  void mem_cgroup_split_huge_fixup(struct page *head)
> diff --git a/mm/rmap.c b/mm/rmap.c
> index 5fe2dedce1fc..7fbc382e6f9e 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -28,12 +28,12 @@
>   *           hugetlb_fault_mutex (hugetlbfs specific page fault mutex)
>   *           anon_vma->rwsem
>   *             mm->page_table_lock or pte_lock
> - *               pgdat->lru_lock (in mark_page_accessed, isolate_lru_page)
>   *               swap_lock (in swap_duplicate, swap_info_get)
>   *                 mmlist_lock (in mmput, drain_mmlist and others)
>   *                 mapping->private_lock (in __set_page_dirty_buffers)
> - *                   mem_cgroup_{begin,end}_page_stat (memcg->move_lock)
> + *                   lock_page_memcg move_lock (in __set_page_dirty_buffers)
>   *                     i_pages lock (widely used)
> + *                       lock_page_lruvec_irq lruvec->lru_lock

I think it has to be
			    lruvec->lru_lock (in lock_page_lruvec_irq)

No?

>   *                 inode->i_lock (in set_page_dirty's __mark_inode_dirty)
>   *                 bdi.wb->list_lock (in set_page_dirty's __mark_inode_dirty)
>   *                   sb_lock (within inode_lock in fs/fs-writeback.c)
> 
> > 
> > local_irq_disable() also deserves a comment.
> > 
> 
> yes, I will add a comment for this. Do you mind give reviewed-by for this patch?

Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

-- 
 Kirill A. Shutemov


  reply	other threads:[~2020-07-10 11:28 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03  5:07 [PATCH v14 00/20] per memcg lru lock Alex Shi
2020-07-03  5:07 ` [PATCH v14 01/20] mm/vmscan: remove unnecessary lruvec adding Alex Shi
2020-07-03  5:07 ` [PATCH v14 02/20] mm/page_idle: no unlikely double check for idle page counting Alex Shi
2020-07-03  5:07 ` [PATCH v14 03/20] mm/compaction: correct the comments of compact_defer_shift Alex Shi
2020-07-03  5:07 ` [PATCH v14 04/20] mm/compaction: rename compact_deferred as compact_should_defer Alex Shi
2020-07-03  5:07 ` [PATCH v14 05/20] mm/thp: move lru_add_page_tail func to huge_memory.c Alex Shi
2020-07-03  5:07 ` [PATCH v14 06/20] mm/thp: clean up lru_add_page_tail Alex Shi
2020-07-03  5:07 ` [PATCH v14 07/20] mm/thp: narrow lru locking Alex Shi
2020-07-06  9:15   ` Alex Shi
2020-07-06 11:35     ` Matthew Wilcox
2020-07-07  4:52       ` Hugh Dickins
2020-07-09 14:02         ` Alex Shi
2020-07-09 15:48         ` Kirill A. Shutemov
2020-07-10  8:23           ` Alex Shi
2020-07-10 11:28             ` Kirill A. Shutemov [this message]
2020-07-10 14:09               ` Alex Shi
2020-07-07 10:51       ` Alex Shi
2020-07-03  5:07 ` [PATCH v14 08/20] mm/memcg: add debug checking in lock_page_memcg Alex Shi
2020-07-03  5:07 ` [PATCH v14 09/20] mm/swap: fold vm event PGROTATED into pagevec_move_tail_fn Alex Shi
2020-07-03  5:07 ` [PATCH v14 10/20] mm/lru: move lru_lock holding in func lru_note_cost_page Alex Shi
2020-07-03  5:07 ` [PATCH v14 11/20] mm/lru: move lock into lru_note_cost Alex Shi
2020-07-03  5:07 ` [PATCH v14 12/20] mm/lru: introduce TestClearPageLRU Alex Shi
2020-07-03  5:07 ` [PATCH v14 13/20] mm/compaction: do page isolation first in compaction Alex Shi
2020-07-03  5:07 ` [PATCH v14 14/20] mm/mlock: reorder isolation sequence during munlock Alex Shi
2020-07-03  5:07 ` [PATCH v14 15/20] mm/swap: serialize memcg changes during pagevec_lru_move_fn Alex Shi
2020-07-03  9:13   ` Konstantin Khlebnikov
2020-07-04 11:34     ` Alex Shi
2020-07-04 11:39       ` Matthew Wilcox
2020-07-04 13:12         ` Alex Shi
2020-07-04 13:33           ` Matthew Wilcox
2020-07-04 15:47             ` Alex Shi
2020-07-03  5:07 ` [PATCH v14 16/20] mm/lru: replace pgdat lru_lock with lruvec lock Alex Shi
2020-07-03  5:07 ` [PATCH v14 17/20] mm/lru: introduce the relock_page_lruvec function Alex Shi
2020-07-03  5:07 ` [PATCH v14 18/20] mm/vmscan: use relock for move_pages_to_lru Alex Shi
2020-07-03  5:07 ` [PATCH v14 19/20] mm/pgdat: remove pgdat lru_lock Alex Shi
2020-07-03  5:07 ` [PATCH v14 20/20] mm/lru: revise the comments of lru_lock Alex Shi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200710112831.jrv4hzjzjqtxtc7u@box \
    --to=kirill@shutemov.name \
    --cc="^["@box.kvack.org \
    --cc=akpm@linux-foundation.org \
    --cc=alex.shi@linux.alibaba.com \
    --cc=cgroups@vger.kernel.org \
    --cc=daniel.m.jordan@oracle.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=khlebnikov@yandex-team.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=mgorman@techsingularity.net \
    --cc=richard.weiyang@gmail.com \
    --cc=shakeelb@google.com \
    --cc=tj@kernel.org \
    --cc=willy@infradead.org \
    --cc=yang.shi@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).