Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp508380pxv; Thu, 15 Jul 2021 09:08:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+fZ/N1FWDZLI1Z62e4khLzIasHgZ0lwkOELTUFSPktKc/b9r6k0EJgY6xfvGL2knz8Zws X-Received: by 2002:a02:6f1c:: with SMTP id x28mr4664424jab.95.1626365294092; Thu, 15 Jul 2021 09:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626365294; cv=none; d=google.com; s=arc-20160816; b=0FScnj/ybWfF85pTGIXwh7NmwfhqK++/G31M8fmgWYtchbAIKz53fUNl1dCA08+2MJ v4Aie8/VVvEIKONFYH+WREpRYh6gYM6tNyt+1LfN72n/OYTqYefG/PSF3wOfnKWAjuUk mPcyQa8b4wg7Dxq50nAzzxAGAgyRmSY3oMe2HjYLCXQaEUVwKjWUbmtvk0fceyeLeAhP 7AE094t071Lw8J7D6YbF3wrLejdo7WdZp64fZU9pvpkZ5VetfAMhca+yNLzrgd3hAc8O 27NDWdUqNWbknL7TO5yGPx+tmhyNgA6g9a4Ht8VX4ogT+iUxct1AMY41ZO53maQlC5/V Kf/w== 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=KwKp5zN9Twi4WZmCxRo6dTdBWlrC6P4+SjjlKGxbG5A=; b=bRegH0xQiycaRES42hAZ/mhPAXDHA2vkI8yefX/+fyXGIry59cassVLIJG1qCIeVSR 0bMaBtOv4N/GRXPT2wtX/2lu5HOdBNI98DnbvhEHrMd/X3E5ID8pd3gzcVKqiu/BKu2D n5upxQ079K8IZTcvuSYLqQP8fhCjqoLu5XKwIfMD8VuJSadLnGGy87qDWNqwCxlKi69N iexqxkBXdVb9TkIQM1nx7TnmDmKYLeoRuDQ4s3Qiw5mbAhIZWCuCYDnS7FZinUnBXUvX 43z9i12jDrsDM//ktX6zcRKfN5uI4YvTUwoh9+3djBdoOv36H+u1ylG/dba7IceTuiZE N+aw== 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 a9si6873991ilr.103.2021.07.15.09.08.01; Thu, 15 Jul 2021 09:08:14 -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 S230170AbhGOMA1 (ORCPT + 99 others); Thu, 15 Jul 2021 08:00:27 -0400 Received: from outbound-smtp07.blacknight.com ([46.22.139.12]:51135 "EHLO outbound-smtp07.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbhGOMA0 (ORCPT ); Thu, 15 Jul 2021 08:00:26 -0400 Received: from mail.blacknight.com (pemlinmail06.blacknight.ie [81.17.255.152]) by outbound-smtp07.blacknight.com (Postfix) with ESMTPS id EE0EC1C4CFA for ; Thu, 15 Jul 2021 12:57:32 +0100 (IST) Received: (qmail 31738 invoked from network); 15 Jul 2021 11:57:32 -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); 15 Jul 2021 11:57:32 -0000 Date: Thu, 15 Jul 2021 12:57:31 +0100 From: Mel Gorman To: Yang Huan Cc: Andrew Morton , Alexander Lobakin , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel@vivo.com, syzbot+b07d8440edb5f8988eea@syzkaller.appspotmail.com, Wang Qing Subject: Re: [PATCH v2] mm/page_alloc: fix alloc_pages_bulk/set_page_owner panic on irq disabled Message-ID: <20210715115731.GS3809@techsingularity.net> References: <20210712022333.1510-1-link@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20210712022333.1510-1-link@vivo.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 12, 2021 at 10:23:32AM +0800, Yang Huan wrote: > BUG: sleeping function called from invalid context at mm/page_alloc.c:5179 > in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 1, name: swapper/0 > > __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 > > The problem is caused by set_page_owner alloc memory to save stack with > GFP_KERNEL in local_riq disabled. > So, we just can't assume that alloc flags should be same with new page, > prep_new_page should prep/trace the page gfp, but shouldn't use the same > gfp to get memory, let's depend on caller. > So, here is two gfp flags, alloc_gfp used to alloc memory, depend on > caller, page_gfp_mask is page's gfp, used to trace/prep itself > But in most situation, same is ok, in alloc_pages_bulk, use GFP_ATOMIC > is ok.(even if set_page_owner save backtrace failed, limited impact) > > v2: > - add more description. > > Fixes: 0f87d9d30f21 ("mm/page_alloc: add an array-based interface to the bulk page allocator") > Reported-by: syzbot+b07d8440edb5f8988eea@syzkaller.appspotmail.com > Suggested-by: Wang Qing > Signed-off-by: Yang Huan https://lore.kernel.org/lkml/20210713152100.10381-2-mgorman@techsingularity.net/ is now part of a series that has being sent to Linus. Hence, the Fixes part is no longer applicable and the patch will no longer be addresing an atomic sleep bug. This patch should be treated as an enhancement to allow bulk allocations when PAGE_OWNER is set. For that, it should include a note on the performance if PAGE_OWNER is used with either NFS or high-speed networking to justify the additional complexity. -- Mel Gorman SUSE Labs