[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d7fb45a9-2d16-a2d5-59f4-f1e7a4362e33@huawei.com>
Date: Sat, 29 Jun 2024 10:09:46 +0800
From: Miaohe Lin <linmiaohe@...wei.com>
To: Rui Qi <qirui.001@...edance.com>
CC: <linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
<nao.horiguchi@...il.com>, <akpm@...ux-foundation.org>
Subject: Re: [PATCH] mm/memory-failure: allow memory allocation from emergency
reserves
On 2024/6/25 10:23, Rui Qi wrote:
> From: Rui Qi <qirui.001@...edance.com>
>
> we hope that memory errors can be successfully handled quickly, using
> __GFP_MEMALLOC can help us improve the success rate of processing
Comments of __GFP_MEMALLOC says:
* Users of this flag have to be extremely careful to not deplete the reserve
* completely and implement a throttling mechanism which controls the
* consumption of the reserve based on the amount of freed memory.
It seems there's no such throttling mechanism in memory_failure.
> under memory pressure, because to_kill struct is freed very quickly,
> so using __GFP_MEMALLOC will not exacerbate memory pressure for a long time,
> and more memory will be freed after killed task exiting, which will also
Tasks might not be killed even to_kill struct is allocated.
> reduce memory pressure.
>
> Signed-off-by: Rui Qi <qirui.001@...edance.com>
> ---
> mm/memory-failure.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 05818d09b4eb..0608383f927a 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -451,7 +451,7 @@ static void __add_to_kill(struct task_struct *tsk, struct page *p,
> {
> struct to_kill *tk;
>
> - tk = kmalloc(sizeof(struct to_kill), GFP_ATOMIC);
> + tk = kmalloc(sizeof(struct to_kill), GFP_ATOMIC | __GFP_MEMALLOC);
> if (!tk) {
> pr_err("Out of memory while machine check handling\n");
> return;
> @@ -1931,7 +1931,7 @@ static int folio_set_hugetlb_hwpoison(struct folio *folio, struct page *page)
> return -EHWPOISON;
> }
>
> - raw_hwp = kmalloc(sizeof(struct raw_hwp_page), GFP_ATOMIC);
> + raw_hwp = kmalloc(sizeof(struct raw_hwp_page), GFP_ATOMIC | __GFP_MEMALLOC);
In already hardware poisoned code path, raw_hwp can be allocated to store raw page info
without killing anything. So __GFP_MEMALLOC might not be suitable to use.
Or am I miss something?
Thanks.
.
Powered by blists - more mailing lists