linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Haiqiang Gong (龚海强)" <Haiqiang.Gong@mediatek.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Mike Zhang (张伟伟)" <Mike.Zhang@mediatek.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>
Subject: 回复: [PATCH] mm/compaction: add check mechanism to avoid cma alloc fail
Date: Wed, 24 Jan 2024 07:20:53 +0000	[thread overview]
Message-ID: <JH0PR03MB8809FC349066C215C28DE119947B2@JH0PR03MB8809.apcprd03.prod.outlook.com> (raw)
In-Reply-To: <Za3hf6A4V5QECvDy@casper.infradead.org>

[-- Attachment #1: Type: text/html, Size: 6247 bytes --]

[-- Attachment #2: Type: text/plain, Size: 3232 bytes --]

> I don't understand.  You say that the memory isn't movable, but then you 
> say that it's migrated in.  So it was movable, but it's no longer
> movable after being moved once?  
Sorry for not expressing clearly
When doing memory migration, the kernel will determine whether the current 
page can be moved based on the refcount and mapcount of the current page.
This memory can be moved during kernel compaction. At this time, refcount 
is less than or equal to mapcount.
After this memory is kcompacted and placed in the cma buffer, under 
certain special conditions, the refcount may be greater than the mapcount
(ex:the current page is being used by fs), and then migrate will fail.

> Why would folio_mapping() be the right way to determine if memory is
> unmovable?  The vast majority of filesystem data is movable.
We found that the final problem was in the __buffer_migrate_page() 
function. This function seems to be a callback registered by fs that will 
be called during migration. The reason for migrate fail is that the 
refcount of the current page is greater than mapcount.


发件人: Matthew Wilcox <willy@infradead.org> 
发送时间: 2024年1月22日 11:31
收件人: Haiqiang Gong (龚海强) <Haiqiang.Gong@mediatek.com>
抄送: linux-kernel@vger.kernel.org; Mike Zhang (张伟伟) <Mike.Zhang@mediatek.com>; Andrew Morton <akpm@linux-foundation.org>; Matthias Brugger <matthias.bgg@gmail.com>; AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>; linux-mm@kvack.org; linux-arm-kernel@lists.infradead.org; linux-mediatek@lists.infradead.org
主题: Re: [PATCH] mm/compaction: add check mechanism to avoid cma alloc fail


External email : Please do not click links or open attachments until you have verified the sender or the content.

On Mon, Jan 22, 2024 at 10:23:17AM +0800, Haiqiang Gong wrote:
> cma alloc may fail when we doing cma alloc/free test on kernel 5.10/5.15.
> 
> We found that the next memory cannot be migrated because of the alloc of
> fs as next backtrace:
> __alloc_pages_nodemask
> pagecache_get_page
> grow_dev_page
> __getblk_gfp
> ext4_sb_breadahead_unmovable
> __ext4_get_inode_loc
> __ext4_iget
> ext4_lookup
> __lookup_slow
> walk_component
> path_lookupat
> filename_lookup
> vfs_statx
> This kind of unmovable memory is not placed in the cma buffer when kernel
> memory alloc but is migrated in by kcompactd when the kernel migration.
> It will cause memory can't be migrate when cma alloc.

I don't understand.  You say that the memory isn't movable, but then you
say that it's migrated in.  So it was movable, but it's no longer
movable after being moved once?  

> Add check mechanism in the compaction_alloc() where kcompaced alloc for
> memory. Will return NULL and give up this memory migration if the
> allocated memory is in the cma buffer and the memory is unmovable.

> +static bool forbid_move_to_cma_range(struct folio *src, struct folio *dst)
> +{
> +if (folio_mapping(src) && is_in_cma_range(dst))
> +return true;
> +
> +return false;
> +}

Why would folio_mapping() be the right way to determine if memory is
unmovable?  The vast majority of filesystem data is movable.

  parent reply	other threads:[~2024-01-24  7:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22  2:23 Haiqiang Gong
2024-01-22  3:31 ` Matthew Wilcox
2024-01-23 12:14   ` 回复: " Haiqiang Gong (龚海强)
2024-01-24  7:20   ` Haiqiang Gong (龚海强) [this message]
2024-01-24 18:40     ` Matthew Wilcox
2024-01-27 11:03       ` Haiqiang Gong (龚海强)
2024-01-27 16:23         ` Matthew Wilcox
2024-01-22  6:59 ` Baolin Wang
2024-01-24  1:41   ` 回复: " Haiqiang Gong (龚海强)
2024-01-24  7:37   ` Haiqiang Gong (龚海强)

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=JH0PR03MB8809FC349066C215C28DE119947B2@JH0PR03MB8809.apcprd03.prod.outlook.com \
    --to=haiqiang.gong@mediatek.com \
    --cc=Mike.Zhang@mediatek.com \
    --cc=akpm@linux-foundation.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=matthias.bgg@gmail.com \
    --cc=willy@infradead.org \
    /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