Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4519380pxv; Tue, 6 Jul 2021 02:58:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjpOcLjiy2IACV2J8e9QXifOrSfbYiGmQogaTjsLF5s0aU1Ssc/RkDStJzKFo/62aziLqd X-Received: by 2002:a05:6402:48f:: with SMTP id k15mr21717965edv.262.1625565488824; Tue, 06 Jul 2021 02:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625565488; cv=none; d=google.com; s=arc-20160816; b=wTBQlQAKLH9cBGWyQC/LM53sRK0mBLIBpYE0bRBUTKmmQmOb6xiefWzzBM7y0hGDMQ qZ4QjTeQqm0COtcbsUKAJQFYi5tId+c9f5DkKfJ6cTlD8Zm2xcpc93TuJZeOwtpxeMJj ehfUIdAGtOmEF14JyjxjpXUnhVdiM4zCnnKrbEkzkw11SMtfSD7jUiB1zMJIV7re5jrT aOzR5Y0h6ZIFtkDK1wOwcPgjy8ERRQE07UcCgWnRk0Kq+E/nrOARH9VFDVzNja4qf61n ta3l/BEh76+P7R+A6IWuCDRjcsS1LTxQZ4X7gARY3EAAnHF+3W4n+fskEiCi0m1s5ipP aWAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=dOM3cKbjmkkxMSmE0gZofADw1EJU4xLt1NnxP5YLoYk=; b=b8wFaEpp8S+UGXf6NQ1KFzw9QC42V+9r8Z094fVieauaF3hAjy3v5sxFpj0Jv6i/c/ ooR54+dvAxa45WfO1dKHhbyBlMTjnHvGPbxOvVYrdMbbNYQLemR0lVHz52sX6Z3HqBmV bbA6DEXtrXzz3x89QXWaGkbQR2ot38RUCwyAH8Gwlv/W5ShXjB6OXNeLOwbvNUgAv9H8 JWP39qdIqFydixuvVL4EZmFg1I5oagSnP1mWxhFX9xf9CzA+uvgdf2kfW0JKpoPV0LBr DhbivCZFAB8gtJ3WFDX1CAP6xnIdshKv8OZ0U4AsNBdWxVqEMz9KlWppWAa+DVbV3F4I ONcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hx8si13705784ejc.522.2021.07.06.02.57.45; Tue, 06 Jul 2021 02:58:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231208AbhGFJ7U (ORCPT + 99 others); Tue, 6 Jul 2021 05:59:20 -0400 Received: from outbound-smtp08.blacknight.com ([46.22.139.13]:43235 "EHLO outbound-smtp08.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbhGFJ7U (ORCPT ); Tue, 6 Jul 2021 05:59:20 -0400 Received: from mail.blacknight.com (pemlinmail03.blacknight.ie [81.17.254.16]) by outbound-smtp08.blacknight.com (Postfix) with ESMTPS id F0F321C34FD for ; Tue, 6 Jul 2021 10:56:40 +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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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