All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yin Fengwei <fengwei.yin@intel.com>
To: linux-mm@kvack.org, akpm@linux-foundation.org,
	willy@infradead.org, kirill@shutemov.name, yuzhao@google.com,
	ryan.roberts@arm.com, ying.huang@intel.com
Cc: fengwei.yin@intel.com
Subject: [PATCH v3 0/2] Reduce lock contention related with large folio
Date: Sat, 29 Apr 2023 16:27:57 +0800	[thread overview]
Message-ID: <20230429082759.1600796-1-fengwei.yin@intel.com> (raw)

yan tried to enable the large folio for anonymous mapping [1].

Unlike large folio for page cache which doesn't trigger frequent page
allocation/free, large folio for anonymous mapping is allocated/freeed
more frequently. So large folio for anonymous mapping exposes some lock
contention.

Ryan mentioned the deferred queue lock in [1]. We also met other two
lock contention: lru lock and zone lock.

This series tries to mitigate the deferred queue lock and reduce lru
lock in some level.

The patch1 tries to reduce deferred queue lock by not acquiring queue
lock when check whether the folio is in deferred list or not. Test
page fault1 of will-it-scale showed 60% deferred queue lock contention
reduction.

The patch2 tries to reduce lru lock by allowing batched add large folio
to lru list. Test page fault1 of will-it-scale showed 20% lru lock
contention reduction.

The zone lock contention happens on large folio free path and related
with commit f26b3fa04611 "mm/page_alloc: limit number of high-order
pages on PCP during bulk free" and will not be address by this series.


[1]
https://lore.kernel.org/linux-mm/20230414130303.2345383-1-ryan.roberts@arm.com/

Changelog from v2:
  - Rebased to v6.3-rc7
  - Removed Tested-by: Ryan Roberts <ryan.roberts@arm.com> as patches got
    some updated after Ryan tested them.
  - Updated the perf data change for deferred queue lock and lru lock with
    v3.
  - recheck whether folio is in deferred_list or not after take the deferred
    queue lock as Kirill suggested.


Changelog from v1:

For patch2:
  - Add Reported-by from Huang Ying which was missed by my mistake.
  - Fix kernel panic issue. The folio_batch_add() can have folio which
    doesn't reference folio directly:
    - For mlock usage, add new interface with extra parameter nr_pages.
      And callee pass nr_pages by direct reference folio.
    - For swap, shawdow and dax entries as parameter folio, treat the
      nr_pages as 1.
    With the fix, the stress testing can run 12 hours without any issue
    while hit kernel panic in around 3 minutes.
  - Update the lock contention info in commit message.
  - Change field name from pages_nr to nr_pages as Ying's suggestion.

For this version, still use PAGEVEC_SIZE as max nr_pages in fbatch. We
can revise it after we make decision about the page order for anonymous
large folio.


Yin Fengwei (2):
  THP: avoid lock when check whether THP is in deferred list
  lru: allow large batched add large folio to lru list

 include/linux/pagevec.h | 46 ++++++++++++++++++++++++++++++++++++++---
 mm/huge_memory.c        | 17 ++++++++++-----
 mm/mlock.c              |  7 +++----
 mm/swap.c               |  3 +--
 4 files changed, 59 insertions(+), 14 deletions(-)

-- 
2.34.1



             reply	other threads:[~2023-04-29  8:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-29  8:27 Yin Fengwei [this message]
2023-04-29  8:27 ` [PATCH v3 1/2] THP: avoid lock when check whether THP is in deferred list Yin Fengwei
2023-05-04 11:48   ` kirill
2023-05-05  1:09     ` Yin, Fengwei
2023-05-29  2:58     ` Yin Fengwei
2023-05-05  0:52   ` Huang, Ying
2023-05-05  1:09     ` Yin, Fengwei
2023-04-29  8:27 ` [PATCH v3 2/2] lru: allow large batched add large folio to lru list Yin Fengwei
2023-04-29 22:35   ` Matthew Wilcox
2023-05-01  5:52     ` Yin, Fengwei
2023-05-05  5:51     ` Yin, Fengwei
2023-05-15  2:14       ` Yin, Fengwei
2023-06-20  3:22   ` Matthew Wilcox
2023-06-20  4:39     ` Yin Fengwei
2023-06-20  8:01     ` Yin Fengwei

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=20230429082759.1600796-1-fengwei.yin@intel.com \
    --to=fengwei.yin@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=kirill@shutemov.name \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=willy@infradead.org \
    --cc=ying.huang@intel.com \
    --cc=yuzhao@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.