From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6AF5C07E9C for ; Tue, 6 Jul 2021 09:56:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 51E76619A0 for ; Tue, 6 Jul 2021 09:56:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51E76619A0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 196536B0011; Tue, 6 Jul 2021 05:56:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 147846B0036; Tue, 6 Jul 2021 05:56:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00E496B005D; Tue, 6 Jul 2021 05:56:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id D31C86B0011 for ; Tue, 6 Jul 2021 05:56:43 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3EAF118162A75 for ; Tue, 6 Jul 2021 09:56:43 +0000 (UTC) X-FDA: 78331708686.35.9CDDCE5 Received: from outbound-smtp37.blacknight.com (outbound-smtp37.blacknight.com [46.22.139.220]) by imf24.hostedemail.com (Postfix) with ESMTP id 9D0ABB00009E for ; Tue, 6 Jul 2021 09:56:42 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail03.blacknight.ie [81.17.254.16]) by outbound-smtp37.blacknight.com (Postfix) with ESMTPS id 096231B94 for ; Tue, 6 Jul 2021 10:56:41 +0100 (IST) Received: (qmail 25785 invoked from network); 6 Jul 2021 09:56:40 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.17.255]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 6 Jul 2021 09:56:40 -0000 Date: Tue, 6 Jul 2021 10:56:39 +0100 From: Mel Gorman To: Wang Qing Cc: Andrew Morton , "open list:MEMORY MANAGEMENT" , open list , Qiang.Zhang@windriver.com Subject: Re: [PATCH V2] mm: add GFP_ATOMIC flag after local_lock_irqsave Message-ID: <20210706095639.GS3840@techsingularity.net> References: <1625563471-3873-1-git-send-email-wangqing@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1625563471-3873-1-git-send-email-wangqing@vivo.com> User-Agent: Mutt/1.10.1 (2018-07-13) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.220 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net; dmarc=none X-Stat-Signature: eduok57q7x5ua4g5o341b4yaudrnwnoj X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9D0ABB00009E X-HE-Tag: 1625565402-96163 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 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