From: Mel Gorman <mgorman@techsingularity.net>
To: Wang Qing <wangqing@vivo.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"open list:MEMORY MANAGEMENT" <linux-mm@kvack.org>,
open list <linux-kernel@vger.kernel.org>,
Qiang.Zhang@windriver.com
Subject: Re: [PATCH V2] mm: add GFP_ATOMIC flag after local_lock_irqsave
Date: Tue, 6 Jul 2021 10:56:39 +0100 [thread overview]
Message-ID: <20210706095639.GS3840@techsingularity.net> (raw)
In-Reply-To: <1625563471-3873-1-git-send-email-wangqing@vivo.com>
On Tue, Jul 06, 2021 at 05:24:31PM +0800, Wang Qing wrote:
> prep_new_page() will allocate memory in some scenarios.
>
> Call Trace:
> __dump_stack lib/dump_stack.c:79 [inline]
> dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:96
> ___might_sleep.cold+0x1f1/0x237 kernel/sched/core.c:9153
> prepare_alloc_pages+0x3da/0x580 mm/page_alloc.c:5179
> __alloc_pages+0x12f/0x500 mm/page_alloc.c:5375
> alloc_pages+0x18c/0x2a0 mm/mempolicy.c:2272
> stack_depot_save+0x39d/0x4e0 lib/stackdepot.c:303
> save_stack+0x15e/0x1e0 mm/page_owner.c:120
> __set_page_owner+0x50/0x290 mm/page_owner.c:181
> prep_new_page mm/page_alloc.c:2445 [inline]
> __alloc_pages_bulk+0x8b9/0x1870 mm/page_alloc.c:5313
>
> So we add GFP_ATOMIC and remove GFP_KERNEL flag.
>
> Reported-and-tested-by: syzbot+b07d8440edb5f8988eea@syzkaller.appspotmail.com
> Signed-off-by: Wang Qing <wangqing@vivo.com>
This will pass in the wrong flags to kasan potentially and the wrong GFP
mask will be stored in page_owner->gfp_mask. If you think this is the
best approach, the flags should be set to GFP_ATOMIC at the places page
owner allocates memory (stack_depot_save?). The caveat there is that
page owner tracking may be impaired if the atomic allocations fail. That
brings us back to either disabling the bulk allocator if page owner
tracking is enabled or doing the enabling/disabling only when page owner
tracking is enabled and goto the point where pagesets.lock is taken and
PCP looked up with a comment stating that it incurs a performance
penalty that is acceptable when page owner tracking is on.
--
Mel Gorman
SUSE Labs
prev parent reply other threads:[~2021-07-06 9:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-06 9:24 Wang Qing
2021-07-06 9:56 ` Mel Gorman [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=20210706095639.GS3840@techsingularity.net \
--to=mgorman@techsingularity.net \
--cc=Qiang.Zhang@windriver.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=wangqing@vivo.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