Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: yangge1116@126.com
Cc: stable@vger.kernel.org, 21cnbao@gmail.com,
	akpm@linux-foundation.org, baolin.wang@linux.alibaba.com,
	mgorman@techsingularity.net, liuzixing@hygon.cn
Subject: Re: [PATCH 6.1.y] mm/page_alloc: Separate THP PCP into movable and non-movable categories
Date: Tue, 2 Jul 2024 11:51:37 +0200	[thread overview]
Message-ID: <2024070229-gliding-onion-3759@gregkh> (raw)
In-Reply-To: <1719892819-2868-1-git-send-email-yangge1116@126.com>

On Tue, Jul 02, 2024 at 12:00:19PM +0800, yangge1116@126.com wrote:
> From: yangge <yangge1116@126.com>
> 
> Since commit 5d0a661d808f ("mm/page_alloc: use only one PCP list for
> THP-sized allocations") no longer differentiates the migration type of
> pages in THP-sized PCP list, it's possible that non-movable allocation
> requests may get a CMA page from the list, in some cases, it's not
> acceptable.
> 
> If a large number of CMA memory are configured in system (for example, the
> CMA memory accounts for 50% of the system memory), starting a virtual
> machine with device passthrough will get stuck.  During starting the
> virtual machine, it will call pin_user_pages_remote(..., FOLL_LONGTERM,
> ...) to pin memory.  Normally if a page is present and in CMA area,
> pin_user_pages_remote() will migrate the page from CMA area to non-CMA
> area because of FOLL_LONGTERM flag.  But if non-movable allocation
> requests return CMA memory, migrate_longterm_unpinnable_pages() will
> migrate a CMA page to another CMA page, which will fail to pass the check
> in check_and_migrate_movable_pages() and cause migration endless.
> 
> Call trace:
> pin_user_pages_remote
> --__gup_longterm_locked // endless loops in this function
> ----_get_user_pages_locked
> ----check_and_migrate_movable_pages
> ------migrate_longterm_unpinnable_pages
> --------alloc_migration_target
> 
> This problem will also have a negative impact on CMA itself.  For example,
> when CMA is borrowed by THP, and we need to reclaim it through cma_alloc()
> or dma_alloc_coherent(), we must move those pages out to ensure CMA's
> users can retrieve that contigous memory.  Currently, CMA's memory is
> occupied by non-movable pages, meaning we can't relocate them.  As a
> result, cma_alloc() is more likely to fail.
> 
> To fix the problem above, we add one PCP list for THP, which will not
> introduce a new cacheline for struct per_cpu_pages.  THP will have 2 PCP
> lists, one PCP list is used by MOVABLE allocation, and the other PCP list
> is used by UNMOVABLE allocation.  MOVABLE allocation contains GPF_MOVABLE,
> and UNMOVABLE allocation contains GFP_UNMOVABLE and GFP_RECLAIMABLE.
> 
> Link: https://lkml.kernel.org/r/1718845190-4456-1-git-send-email-yangge1116@126.com
> Fixes: 5d0a661d808f ("mm/page_alloc: use only one PCP list for THP-sized allocations")
> Signed-off-by: yangge <yangge1116@126.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Barry Song <21cnbao@gmail.com>
> Cc: Mel Gorman <mgorman@techsingularity.net>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> (cherry picked from commit bf14ed81f571f8dba31cd72ab2e50fbcc877cc31)
> Signed-off-by: yangge <yangge1116@126.com>
> ---
>  include/linux/mmzone.h | 9 ++++-----
>  mm/page_alloc.c        | 8 ++++++--
>  2 files changed, 10 insertions(+), 7 deletions(-)
> 

All now queued up, thanks.

greg k-h

      reply	other threads:[~2024-07-02  9:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01 12:29 FAILED: patch "[PATCH] mm/page_alloc: Separate THP PCP into movable and non-movable" failed to apply to 6.1-stable tree gregkh
2024-07-02  4:00 ` [PATCH 6.1.y] mm/page_alloc: Separate THP PCP into movable and non-movable categories yangge1116
2024-07-02  9:51   ` Greg KH [this message]

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=2024070229-gliding-onion-3759@gregkh \
    --to=greg@kroah.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=liuzixing@hygon.cn \
    --cc=mgorman@techsingularity.net \
    --cc=stable@vger.kernel.org \
    --cc=yangge1116@126.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