From patchwork Wed Mar 31 03:41:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 12174303 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.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, 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 E313AC433DB for ; Wed, 31 Mar 2021 03:42:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 89C8261954 for ; Wed, 31 Mar 2021 03:42:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89C8261954 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7D54E6B0083; Tue, 30 Mar 2021 23:42:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 788AC6B0087; Tue, 30 Mar 2021 23:42:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C5DB6B0088; Tue, 30 Mar 2021 23:42:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id 219F26B0083 for ; Tue, 30 Mar 2021 23:42:34 -0400 (EDT) Received: from smtpin37.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D42A61DE7 for ; Wed, 31 Mar 2021 03:42:33 +0000 (UTC) X-FDA: 77978772186.37.8F059BE Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by imf01.hostedemail.com (Postfix) with ESMTP id E9FA45001526 for ; Wed, 31 Mar 2021 03:42:32 +0000 (UTC) Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12V3fcCr158760; Wed, 31 Mar 2021 03:42:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=ACpChQM95ueVORwk8vKkG+h8QzE08ollJKkIPrZEYb4=; b=nsgNN7bREA36yZuu/bF8CShAUr97nbkPWxerDbqeq9534qc8l/3QEqt6M+Nx2eLEdG+9 h5JFJ1nO35xn0aplcE6P1wBGiEPgxt4nMbooJL5NbIp95rpKt7UgfWHOObLwXIVB0t7i k4AsaulN5rCBV4VPW5TLTf68f9J5WLTDXJdsZQHAuQhigufoI+F6OLUa0HwMlrTU0rcY EvCs8gCLBDGJLjXpW0l4Ol7nG8ectpmma6vxUyQeDYa+mW7NOOedA/LFhuf03yeqpPuL XnXWX9tvI/z84cdGd3oTJ3VgaENlJDDN9DJRT/6XNuY+1ZQzQukp4qKIKn/Xy0VocfSY ZA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 37mafv0rkj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Mar 2021 03:42:18 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12V3ebft133184; Wed, 31 Mar 2021 03:42:17 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2045.outbound.protection.outlook.com [104.47.66.45]) by userp3020.oracle.com with ESMTP id 37mac4wb6h-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Mar 2021 03:42:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e+w5oZTXuaJT7pZF23qXTAiRPKEkgrz4AwsAJTl4A9A/eItCwGgXRdp0Ybl2jtZMMbvv8/GETAnNuAE8mUKS29dZ4e4Rwnw/mdIyPgM/+rz0HPc6B/n+z6J3tHv5tfgntj6QWfl3Z+bfzCZDh3xRGYMevcd/LvhqOWS2w9RDMv/oyms9HdsbuDKHB9NcQrT/SVbUlOMaB7suBSxouTThreB262rXeLIh/2PnFokg0huqRyfpTQyvGlQsFdFrJ9Bf2S//AUiMdri1uGiVXa0Fo8ZnH7JuyOg4dXptXP2/qB0Z91Gx59EuXzw9FU4R67P/nOhkKZsV6NzljS7p/bnRVA== 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=ACpChQM95ueVORwk8vKkG+h8QzE08ollJKkIPrZEYb4=; b=XVs4Z0W75gCn1L0rdbVzulQ65Apd35eoU5N5tG8mdbIi5gqEqE5rM/goVIa6Y6kGavP5UQOy+DxwFFBOIT+D3hFA/s9fyOvYFjeG31P/sBY88OAUYWL218kqOv2BjPnRx064qpBxQOomOXWdX11IdbgPBaJcLiK24IeKH4dqWFelgCbmRBnsg6BNgHsf3cW1X12Tfq7R0ecJBW9XbZDloYCw+I3nzPzkcBRkhFE4JRlFDF2HJ5hSNalmclZ/6JwywY87ncq+3Jl4X+gO3B20BvVJ1vvFzoRRL5YPQ2tGx2JEUoXGn+iQKQ39MVkV189Gdq0P0FNzwCflI7oL+MBx4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ACpChQM95ueVORwk8vKkG+h8QzE08ollJKkIPrZEYb4=; b=PFfZI11QmxJ6WqX+XujbTyaJCtG8xlp9MwmiWZUMIi9/hOEcPio1eW8DY1ybI7hBOCJ/waNZKWOr3iWUwI6ZsgeI6t6s3lo/IIAxbYoJgWCH8dpbOGx7Ig0Yd9gGwjbm2wCAW4ux1ABuZMyCMfMuIZKfgoZgujlMY2GCxB/Bz/o= Authentication-Results: kvack.org; dkim=none (message not signed) header.d=none;kvack.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by SJ0PR10MB4462.namprd10.prod.outlook.com (2603:10b6:a03:2d7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26; Wed, 31 Mar 2021 03:42:16 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::980e:61ba:57d2:47ee]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::980e:61ba:57d2:47ee%8]) with mapi id 15.20.3977.033; Wed, 31 Mar 2021 03:42:16 +0000 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Roman Gushchin , Michal Hocko , Shakeel Butt , Oscar Salvador , David Hildenbrand , Muchun Song , David Rientjes , Miaohe Lin , Peter Zijlstra , Matthew Wilcox , HORIGUCHI NAOYA , "Aneesh Kumar K . V" , Waiman Long , Peter Xu , Mina Almasry , Hillf Danton , Joonsoo Kim , Barry Song , Will Deacon , Andrew Morton , Mike Kravetz Subject: [PATCH v3 8/8] hugetlb: add lockdep_assert_held() calls for hugetlb_lock Date: Tue, 30 Mar 2021 20:41:48 -0700 Message-Id: <20210331034148.112624-9-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210331034148.112624-1-mike.kravetz@oracle.com> References: <20210331034148.112624-1-mike.kravetz@oracle.com> X-Originating-IP: [50.38.35.18] X-ClientProxiedBy: CO2PR04CA0202.namprd04.prod.outlook.com (2603:10b6:104:5::32) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from monkey.oracle.com (50.38.35.18) by CO2PR04CA0202.namprd04.prod.outlook.com (2603:10b6:104:5::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.26 via Frontend Transport; Wed, 31 Mar 2021 03:42:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 66141ccb-c9cc-4ddd-eca9-08d8f3f6fa59 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4462: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DYRidwm8/qVAH26RbfgSBPUZbbHlIMqlI45Puest0uVkwDnlP+k6I07PzT9bssqJiW+/d7JAwDRi2fU0t1ugystnnFZhxpax3/wgw8X605w+CXk5uBwyTDiiJzustN4uTBYvFhb9H/ZU8+GTpNIDyxdibejsLtneQOr87hWQ2eirjVCV02CICPdpvv/D4JHZNAhnE850ow14D+iJtBPEaHWpdrRETAie+o0nTSw/UlJph4olTAmujBGRgMddootpl6hIk09bFkVqSzSU53fIkaarFodZlP1kDgZCzBmNlDytnrmKX0TQnvnrsP9cd96VOswf77UdExnQeGsh0UkdmAonCtg9fVd2rmorhg7bmLJU8G/Iuo/ILbDfTbLM/z1XOCo0v8qx0EWENGFLF7M95OI7nmKcE29w/QzuXPeS77MPI/X5dzICWFUlZNQ5GC7INX2q3CXfi0X2cGdy1Rhpi53wKvmPQkFkvZvIHdzGtOq8Ix/w5nzWgfPTOF6IZmco6qdxuR9dUd/EXTf5jBL7tJHRt8piqLRsm3lmcDtUOC66AkrW74c6dis/87wiQFzZB9sigtTR37A2Vn7R6pvRo91oVZbQmuDw1frE5ZEC11FOkIQLcbAEbkiyyGiw7gYk7+8CmfPRDddmjCLSlJJB4A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4196.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(376002)(396003)(346002)(136003)(366004)(86362001)(36756003)(83380400001)(316002)(52116002)(7696005)(66946007)(54906003)(66476007)(66556008)(44832011)(7416002)(4326008)(8676002)(1076003)(8936002)(6666004)(956004)(2616005)(16526019)(6486002)(26005)(107886003)(2906002)(5660300002)(478600001)(38100700001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ncJAgvieI3PnTt+vEYMzLQvlohzzjbC/bj2CnZkxBi/Hs0mtNiMx+l+eERxhG0UKhVSeYQdHn88XEUssfrXPibLZMdWQv3CrcEyo0z4QCSd2G4Vuh0V9wjqTcJ+TOmYx20UuKva+hWWAP6pm9zJxI0/7pkrYoW0btPrziZaIjl/wNPdAYn5Rv//XQVx2h2zRV+2o5nPPQhbhjptSvMoIR+6aL6DLxJvaFEkjD/G22gqy9jyFXmobW0xU6ox/SIl9PZBoC7Ff3NA9fGmKPE5nElD6ZlUem8t/THMR5qVB7sE0nUwmL5vfp2SOQrZppQnw9Y6/WkVnM9Gsjh7w/FBvDf1H2z0jzkgO1P12ga7IDH/bZYRgkr+O+PSmGD4Ig9ZScYY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prd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2021 03:42:16.2309 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 57X+JdLthOLexHSBVmvWaz6l+BeLelDhTt3DZ2nel9zXBjYPNVMAmKfJKjfUZrG4e2mj2hj47q87zPMaaNaXpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4462 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9939 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103300000 definitions=main-2103310025 X-Proofpoint-ORIG-GUID: D9qyPm0UK6kOCRsNSWIXPt8eNutY2G3i X-Proofpoint-GUID: D9qyPm0UK6kOCRsNSWIXPt8eNutY2G3i X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9939 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 adultscore=0 impostorscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103300000 definitions=main-2103310025 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: E9FA45001526 X-Stat-Signature: 4krupg16s1ircqr7mi4fgdparkqdhfxc Received-SPF: none (oracle.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=aserp2130.oracle.com; client-ip=141.146.126.79 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617162152-203032 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: After making hugetlb lock irq safe and separating some functionality done under the lock, add some lockdep_assert_held to help verify locking. Signed-off-by: Mike Kravetz Acked-by: Michal Hocko Reviewed-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/hugetlb.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 0bd4dc04df0f..c22111f3da20 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1068,6 +1068,8 @@ static void __enqueue_huge_page(struct list_head *list, struct page *page) static void enqueue_huge_page(struct hstate *h, struct page *page) { int nid = page_to_nid(page); + + lockdep_assert_held(&hugetlb_lock); __enqueue_huge_page(&h->hugepage_freelists[nid], page); h->free_huge_pages++; h->free_huge_pages_node[nid]++; @@ -1078,6 +1080,7 @@ static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid) struct page *page; bool pin = !!(current->flags & PF_MEMALLOC_PIN); + lockdep_assert_held(&hugetlb_lock); list_for_each_entry(page, &h->hugepage_freelists[nid], lru) { if (pin && !is_pinnable_page(page)) continue; @@ -1346,6 +1349,7 @@ static void remove_hugetlb_page(struct hstate *h, struct page *page, { int nid = page_to_nid(page); + lockdep_assert_held(&hugetlb_lock); if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) return; @@ -1701,6 +1705,7 @@ static struct page *remove_pool_huge_page(struct hstate *h, int nr_nodes, node; struct page *page = NULL; + lockdep_assert_held(&hugetlb_lock); for_each_node_mask_to_free(h, nr_nodes, node, nodes_allowed) { /* * If we're returning unused surplus pages, only examine @@ -1950,6 +1955,7 @@ static int gather_surplus_pages(struct hstate *h, long delta) long needed, allocated; bool alloc_ok = true; + lockdep_assert_held(&hugetlb_lock); needed = (h->resv_huge_pages + delta) - h->free_huge_pages; if (needed <= 0) { h->resv_huge_pages += delta; @@ -2043,6 +2049,7 @@ static void return_unused_surplus_pages(struct hstate *h, struct page *page; LIST_HEAD(page_list); + lockdep_assert_held(&hugetlb_lock); /* Uncommit the reservation */ h->resv_huge_pages -= unused_resv_pages; @@ -2641,6 +2648,7 @@ static void try_to_free_low(struct hstate *h, unsigned long count, int i; LIST_HEAD(page_list); + lockdep_assert_held(&hugetlb_lock); if (hstate_is_gigantic(h)) return; @@ -2682,6 +2690,7 @@ static int adjust_pool_surplus(struct hstate *h, nodemask_t *nodes_allowed, { int nr_nodes, node; + lockdep_assert_held(&hugetlb_lock); VM_BUG_ON(delta != -1 && delta != 1); if (delta < 0) {