Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2501481yba; Mon, 6 May 2019 07:08:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwd35YWRpb6pecLTLZeBo/ZD6CRmpsrZIDXWgDrEsJsAA1++2Xl8mejO9V6x7pMLnI/55PE X-Received: by 2002:a65:43c3:: with SMTP id n3mr31752563pgp.375.1557151711344; Mon, 06 May 2019 07:08:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557151711; cv=none; d=google.com; s=arc-20160816; b=ZPD9gb1vpO21DKDyO23AWiezicY27IJZCPVhqkHsluX6up55IwrHt/+OE447kJ7yWZ NBTjOG7aL9Z/VoniotW0tnOOvBzE79XaSex/ylcNMv6wu3F0OsJBFloTH/k+fZ7twwKq pcw4iLvo7GBtTikLU2HV6VwAbgM6vsRWJSYC5ApZr3aAKWdsoL2P4y1hvJrTe8l42tvr GnqKf4BW06vC9aX+XMSWmlziRdsMKWKVlRMg8797eeybyA3ezFni3b0YkUem9yD3ArWQ KUl2lj9XdviUiTAX/TBwhUTWpEBevKv1W4nZ4KqIYo4sIWLWYDtl6cO1q0F3jcXsjpiA 5RoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:references:cc:to:from :subject; bh=yhwjf/lGP+BLE1UxuYYhtDwb96UANfQX0fYvudzfvco=; b=topa9cZkqxrrYFnVHrDTcmuJuzPJjF13DLfVcRwF+AGZ4CQOFE8EC39epZfwRW7LTP XyVyDqXX9oA7TUgDMvpnUUeqg1uMh8Th5Od6r1oCNupbkI11N1qbvMAX5WAfCnnhjkVL G2MVJoBn3d64M87uNczfCjx0Xxzj9w0hXfCrM6eNMlQpBjFuMBTuZ8HK9zdGIfftBRhX m9oNMMral9p0wgl5GINv5R1wDGuknIGZ81rpFdhhbrw/PO0bjGn8mBaAxNB1XdoG8lKY D3PuoHLYKPbWUKMDylJTr5uIkHjzotTJucGHwrMmPztS+hRe+vjFOLXt75INwdiRbpd+ R/iw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v24si14618298pff.230.2019.05.06.07.08.12; Mon, 06 May 2019 07:08:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726347AbfEFOGv (ORCPT + 99 others); Mon, 6 May 2019 10:06:51 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7172 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725852AbfEFOGv (ORCPT ); Mon, 6 May 2019 10:06:51 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B5049A20A38C0258464B; Mon, 6 May 2019 22:06:47 +0800 (CST) Received: from [127.0.0.1] (10.184.225.177) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Mon, 6 May 2019 22:06:39 +0800 Subject: [PATCH v2] mm/hugetlb: Don't put_page in lock of hugetlb_lock From: Zhiqiang Liu To: , , , CC: , , , "Zhoukang (A)" , Mingfangsen , , References: <12a693da-19c8-dd2c-ea6a-0a5dc9d2db27@huawei.com> Message-ID: Date: Mon, 6 May 2019 22:06:38 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <12a693da-19c8-dd2c-ea6a-0a5dc9d2db27@huawei.com> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.184.225.177] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kai Shen spinlock recursion happened when do LTP test: #!/bin/bash ./runltp -p -f hugetlb & ./runltp -p -f hugetlb & ./runltp -p -f hugetlb & ./runltp -p -f hugetlb & ./runltp -p -f hugetlb & The dtor returned by get_compound_page_dtor in __put_compound_page may be the function of free_huge_page which will lock the hugetlb_lock, so don't put_page in lock of hugetlb_lock. BUG: spinlock recursion on CPU#0, hugemmap05/1079 lock: hugetlb_lock+0x0/0x18, .magic: dead4ead, .owner: hugemmap05/1079, .owner_cpu: 0 Call trace: dump_backtrace+0x0/0x198 show_stack+0x24/0x30 dump_stack+0xa4/0xcc spin_dump+0x84/0xa8 do_raw_spin_lock+0xd0/0x108 _raw_spin_lock+0x20/0x30 free_huge_page+0x9c/0x260 __put_compound_page+0x44/0x50 __put_page+0x2c/0x60 alloc_surplus_huge_page.constprop.19+0xf0/0x140 hugetlb_acct_memory+0x104/0x378 hugetlb_reserve_pages+0xe0/0x250 hugetlbfs_file_mmap+0xc0/0x140 mmap_region+0x3e8/0x5b0 do_mmap+0x280/0x460 vm_mmap_pgoff+0xf4/0x128 ksys_mmap_pgoff+0xb4/0x258 __arm64_sys_mmap+0x34/0x48 el0_svc_common+0x78/0x130 el0_svc_handler+0x38/0x78 el0_svc+0x8/0xc Fixes: 9980d744a0 ("mm, hugetlb: get rid of surplus page accounting tricks") Signed-off-by: Kai Shen Signed-off-by: Feilong Lin Reported-by: Wang Wang Acked-by: Michal Hocko --- v1->v2: add Acked-by: Michal Hocko mm/hugetlb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 6cdc7b2..c1e7b81 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1574,8 +1574,9 @@ static struct page *alloc_surplus_huge_page(struct hstate *h, gfp_t gfp_mask, */ if (h->surplus_huge_pages >= h->nr_overcommit_huge_pages) { SetPageHugeTemporary(page); + spin_unlock(&hugetlb_lock); put_page(page); - page = NULL; + return NULL; } else { h->surplus_huge_pages++; h->surplus_huge_pages_node[page_to_nid(page)]++; -- 1.8.3.1