From patchwork Tue Jul 6 03:29:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Qiang" X-Patchwork-Id: 12359715 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=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 6DEE9C07E99 for ; Tue, 6 Jul 2021 03:29:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AB7F261353 for ; Tue, 6 Jul 2021 03:29:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB7F261353 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=windriver.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6FA6E6B0011; Mon, 5 Jul 2021 23:29:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 684706B0036; Mon, 5 Jul 2021 23:29:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 488186B005D; Mon, 5 Jul 2021 23:29:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id 164E06B0011 for ; Mon, 5 Jul 2021 23:29:21 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7DAFC22ADC for ; Tue, 6 Jul 2021 03:29:20 +0000 (UTC) X-FDA: 78330732480.01.15BC421 Received: from mx0b-0064b401.pphosted.com (mx0b-0064b401.pphosted.com [205.220.178.238]) by imf18.hostedemail.com (Postfix) with ESMTP id 1BCA6400208C for ; Tue, 6 Jul 2021 03:29:18 +0000 (UTC) Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1663TELN020284; Tue, 6 Jul 2021 03:29:17 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2049.outbound.protection.outlook.com [104.47.66.49]) by mx0a-0064b401.pphosted.com with ESMTP id 39keq6gxrr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Jul 2021 03:29:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NL7Y+BASmQ5zbq8vxw1tLEailMKMB1jia8Ho/imsC2btR8rYN1k93kQVDJWVXt1vzZb+y5TRH9YP7jvS4bMwrPehlm0ziVEa8okPEaZNmheAHMRapqri1ln7J7vDY+tYZVUDxQunHhkVKjvPW6ugNW22dkB9nq71FK27Q7YIE+UJeEqu+1Sj3r6XYkKkvoGBXsalCsKUMyHXqK7xDiQM51uUJnSt2zLxMzM873YPRTRI1vaC9pKthXAwK46348i47FD0fRDUcH+6GlSPVWv2ep73RErQhRqS6vM7785ct9132NBv0Q51/Nj3mewVbOzOcf57jeK5HzPZqWNJy1KGOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AR9+qThdM+NBgFft6Q2FLOOogLTH7x2kfcVXqmqfR54=; b=AgMHpEi41p2Nz5Z6K88+WUuPE65FstzxD3jYK1FHq91xvWlDgYhzQAnwGKdF7QLRvgi9hQ9NxfsTKjBtwrSZWd2N013GKLlfwbL9hLujOIY7fhWI4lY6NR4FA4QK6haOd4h/Wcf+KAcQSj/YPXHG2eWe70owZXrhYrFlWvjq9VM6u962mQw3Y1Gv/lVlHrMjMoKauMH2UXtqsCgd0KHlsqkARKanGLu0DuQowIuYz8xQMirDUWqVfPUCAJGHfu7BXUhtoMqMPmhId3oE7AvGSUAJ1oD+Wu+Uz1Ew8tanUblaEidip4ANj+90lNti71s8JrCxgWSzn5MaTDGK788AGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriversystems.onmicrosoft.com; s=selector2-windriversystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AR9+qThdM+NBgFft6Q2FLOOogLTH7x2kfcVXqmqfR54=; b=lpsnFbhUpZZW/HrHjV2oiavqRvLheiOXtiqF7xRYsoFdNmG3AN4poMIt54TnueJRowpUuYWfxsKPxwO4pYaDSeogt6Y2hbji7bikNbIwBZjJWdV+5XveIpMghIH1YUIZ8ygmkb6ypVRMfF28ugJj7CtBTsQ8BVXRe2ttPa9cc7A= Received: from BL1PR11MB5478.namprd11.prod.outlook.com (2603:10b6:208:31d::12) by MN2PR11MB4662.namprd11.prod.outlook.com (2603:10b6:208:263::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.31; Tue, 6 Jul 2021 03:29:15 +0000 Received: from BL1PR11MB5478.namprd11.prod.outlook.com ([fe80::a140:b563:8725:5c2b]) by BL1PR11MB5478.namprd11.prod.outlook.com ([fe80::a140:b563:8725:5c2b%8]) with mapi id 15.20.4287.033; Tue, 6 Jul 2021 03:29:15 +0000 From: qiang.zhang@windriver.com To: mgorman@techsingularity.net, akpm@linux-foundation.org, alobakin@pm.me Cc: songmuchun@bytedance.com, wangqing@vivo.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm/page_alloc: Fix sleeping function called in case of irqsdisable. Date: Tue, 6 Jul 2021 11:29:07 +0800 Message-Id: <20210706032907.1276-1-qiang.zhang@windriver.com> X-Mailer: git-send-email 2.17.1 X-Originating-IP: [60.247.85.82] X-ClientProxiedBy: SLXP216CA0058.KORP216.PROD.OUTLOOK.COM (2603:1096:100:5::20) To BL1PR11MB5478.namprd11.prod.outlook.com (2603:10b6:208:31d::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pek-qzhang2-d1.wrs.com (60.247.85.82) by SLXP216CA0058.KORP216.PROD.OUTLOOK.COM (2603:1096:100:5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23 via Frontend Transport; Tue, 6 Jul 2021 03:29:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b7f58ceb-602d-4f9c-258b-08d9402e3b2a X-MS-TrafficTypeDiagnostic: MN2PR11MB4662: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Lo2uOhmIS6KKiKHH9bF1vUBihkaTvTKl0GrOMrU1pG6HgsZG/vvIfeKoX5NGUhbyAiU1bw8vUnSCxLqmF8MYepi6b48JRbGlGMS/e5s7WI3prGIpzWcfNHPSsWeY3fMdgQVkcnp4vEd6+qCQ3jO5tVwp5oj3TQp4KNb8tXGLkeMfOYoOcLLfDUQdqXPblbnUIlQVdgFXKMmYcIvHt01U+h/R2SCLrIJQrSCy8U1NLFz8j4JTUr+73k25UDAVzsyoh0cstSiygt7+TpFEAOkriGAn2kkzhHSp0CEg+gojOQdHYWgoVmXSEZJs7Nl4cG+Rf1m4lRIHo6BtURbDqh9IZFC4BIYHw95Mu6v/f1qyk/51FWuH2/YShLZfnwTVgkDskk4abbChivtddi3LVTqP7d4tAq7thLNP1L90T3Er+hL0Vk6I77oM2beu2kOVi1b2Yd3wOhj+bDdOBJp6AQRukb7BnmaK36PETz0jpV1y1i6m6KFbRrGm03NlyWIBQB+FXdFE8btVtGEAyd/zHPpugRTzkY0+MGyVMN1s04jq9JhowDTmpHhnJpyeScqeeHBHrWNSk60eQ7iQZ0RvReIfaGya+WTemgmMLe47StTFFOSJf6fi5EXFLNDQLkrWmt5zRiXn1JCBIgHz+XkrKstSAkxuKsjcsGPSbgyB9CNmoOmpOpw6IUWlrTmJrloupNY1u8RwoUJE1RBcqDlzQqw43g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL1PR11MB5478.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(39850400004)(366004)(136003)(346002)(376002)(83380400001)(36756003)(2616005)(956004)(38350700002)(38100700002)(86362001)(2906002)(1076003)(66476007)(52116002)(66556008)(6486002)(478600001)(66946007)(6666004)(316002)(6506007)(4326008)(8936002)(26005)(186003)(6512007)(9686003)(5660300002)(16526019)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eV/o3V4wyDlTVGyI8D35kkb+TcxuWLPBb3tevG38MlFOJ4bIWYBXX+PEq12VvzDhS7yGAD2W76UNS43MMSqaBNM7DwnYyBY3egUhMv61trBmfy7LiwTjpC013T4O9bk01k3IbP6mWuqji3CNquOsVgdNqqgNzMqeYVsqxpA7r3yhxWVaMXNf4IKkgqV2ZT5C1JEREsVFwXXZ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QoMDM8gqA942bQey1XvXyM3X33SXvHhY226W+m3+iH+5fVUS6HX90z1XusU X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7f58ceb-602d-4f9c-258b-08d9402e3b2a X-MS-Exchange-CrossTenant-AuthSource: BL1PR11MB5478.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 03:29:15.6629 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: B7QR6cpI2vogZ7L19QGOhAceearTI2gujBdz00zanfcNYH3pfcz3Xoax2pnyMaNaf50/L+1aqbJuxCi5Awvao+UhOFZ6IvODpTGQLJvzuGY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4662 X-Proofpoint-GUID: VhApMXyWa5cr9WLlGl05q1rnVj51icaY X-Proofpoint-ORIG-GUID: VhApMXyWa5cr9WLlGl05q1rnVj51icaY X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-07-06_01:2021-07-02,2021-07-06 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 suspectscore=0 clxscore=1011 bulkscore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=940 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107060014 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=windriversystems.onmicrosoft.com header.s=selector2-windriversystems-onmicrosoft-com header.b=lpsnFbhU; dmarc=pass (policy=none) header.from=windriver.com; spf=pass (imf18.hostedemail.com: domain of "prvs=28210c7fa5=qiang.zhang@windriver.com" designates 205.220.178.238 as permitted sender) smtp.mailfrom="prvs=28210c7fa5=qiang.zhang@windriver.com" X-Rspamd-Server: rspam02 X-Stat-Signature: 7od5y4zxycgatmq99fhwt1ijjo11metw X-Rspamd-Queue-Id: 1BCA6400208C X-HE-Tag: 1625542158-776019 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: From: Zqiang 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_page_interleave+0x1e/0x200 mm/mempolicy.c:2147 alloc_pages+0x238/0x2a0 mm/mempolicy.c:2270 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 alloc_pages_bulk_array_node include/linux/gfp.h:557 [inline] vm_area_alloc_pages mm/vmalloc.c:2775 [inline] __vmalloc_area_node mm/vmalloc.c:2845 [inline] __vmalloc_node_range+0x39d/0x960 mm/vmalloc.c:2947 __vmalloc_node mm/vmalloc.c:2996 [inline] vzalloc+0x67/0x80 mm/vmalloc.c:3066 If the PAGE_OWNER is enabled, in __set_page_owner(), the pages will be allocated to save calltrace info, due to the allocated action is executed under irq disable(pagesets.lock be held), if the gfp variable contains the flag that causes sleep, will trigger above information. the prep_new_page() is not need to disable irq for protection, fix it through enable irq before call prep_new_page(). Fixes: 0f87d9d30f21 ("mm/page_alloc: add an array-based interface to the bulk page allocator") Reported-by: syzbot+0123a2b8f9e623d5b443@syzkaller.appspotmail.com Signed-off-by: Zqiang --- mm/page_alloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d6e94cc8066c..8d7f0f5ce891 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5309,12 +5309,14 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, } nr_account++; + local_unlock_irqrestore(&pagesets.lock, flags); prep_new_page(page, 0, gfp, 0); if (page_list) list_add(&page->lru, page_list); else page_array[nr_populated] = page; nr_populated++; + local_lock_irqsave(&pagesets.lock, flags); } local_unlock_irqrestore(&pagesets.lock, flags);