From patchwork Fri May 5 17:41:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13232891 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D216C7EE24 for ; Fri, 5 May 2023 17:44:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F0EE6B0085; Fri, 5 May 2023 13:44:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 052916B0087; Fri, 5 May 2023 13:44:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0B396B0088; Fri, 5 May 2023 13:44:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by kanga.kvack.org (Postfix) with ESMTP id AF5F16B0087 for ; Fri, 5 May 2023 13:44:08 -0400 (EDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 345HhIvK029381; Fri, 5 May 2023 17:44:08 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-2023-03-30; bh=VFSQL5/0YuqNDgTT1gzifbZK16he4AsT0QLV48AYt1g=; b=ZaugMnNjTBk3nfgwsdnS11VSGluAiwHbpfH/QUkdKUZxZmxcll5/XfV+bpQp3o+dghf7 DzBvPqnkDpq4Oy7KJ3mwhn9C8E+mmV1tNy7p/gDN96xsk0CrHV8ahfA5tmIFw9l8sdLk dGW1uI3/CllmBEmFCR/bwJw2Jc2jgLd78eo3jCKF7NOCn/K7fpMEYZjkqnI9bNZCYCyK rQ6zDILNor3VIt2pX/PFqGVdZn7tpENiVy/tVRHbkRdXOY8nLmLUNA4vImQ5THUyf2sx QZmyFjuQ7dI1LYlaq5khMsrIsSFGEbXtxOReeC5KrNOjJuSQTAjkBnd/Hun2US9f4f+H Yg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q8su1wf4r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 May 2023 17:44:07 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 345GQG4V026938; Fri, 5 May 2023 17:44:06 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3q8spgeyp5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 May 2023 17:44:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tl68ta80GoKxNU9lBMOqW48Zg/CJGLdYVvIcYAM7APyWLswHAkpPG4+gvT1r8TEoKOQER/Xi7Mo3HUDY+MkXHtnZW50sj0/tNIqiv4MjPwgp1pliqh6UT+PxCB3ruTbQa3uYDbo3HlPrtpa4HWhRmQC97yRe66zLrjTZFy3JD9IgQPtqsf9ZALYCsqBGgpdxCciA1CFIEcBuQ0cDGc5lqWz+EywjnnAXWuBKpHT9zJtAczlYWwhqN3rMbid2G8+qGGbmcVrzjoYi15JcZaaBH3Nhp1KKXFfYSdL7DcOVp9Ar9OkUfucgdiXCeCdWXKnZWP/ZN/XrJnZpQjerXZTpjg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VFSQL5/0YuqNDgTT1gzifbZK16he4AsT0QLV48AYt1g=; b=dvybn2ZVjQVs0rS26I3uOrTRV6jyRoZXmt1LHfFsCwi/CTeAMAGO2NDt2W/8Pbm8Uq3xIdKSXxDAXtujZXoPaIz4CxAVEixwAhNWMUUvLmDgzLrs3otvEZAKqjqFyHG94NfvtJbtpfOsAgLq/14yUG4rnk/hyPtwWISSKVJHvbN0+GsLFq72xN5208Out8WvYEvUXPHIxdbJpmdS4bZsOyArwAm4I3XubKGDlhoMguvPpLngU5L+ON+aVDA3s/VSznqi7j7DB2qVMiBNJiRR7/YEJNfxSwEcHIM5s4gBEuM1Yjq2vXRP2/lf9d1qObN7vg9MHXHaBbBSplw5ThLTJA== 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=VFSQL5/0YuqNDgTT1gzifbZK16he4AsT0QLV48AYt1g=; b=KwRBA/bbQoIig2JQmIDR5UoSQRQu2EUvr1CbFZTUaxVRH0yQ8HcTsRCzAcSCynrl4lnZYoABsUxAvif8047i0WB968fx3o7UKX93TO0F8SoXBWK/sX0A4YNP+eYqYEcPy1vV/PvThRddSYbfx0L/cNHyQmnlt4rrkXK5igniTmk= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by BL3PR10MB6089.namprd10.prod.outlook.com (2603:10b6:208:3b5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.27; Fri, 5 May 2023 17:44:04 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8bb9:2bb7:3930:b5da]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::8bb9:2bb7:3930:b5da%7]) with mapi id 15.20.6363.022; Fri, 5 May 2023 17:44:04 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Liam R. Howlett" Subject: [PATCH v2 10/36] maple_tree: Use MAS_BUG_ON() when setting a leaf node as a parent Date: Fri, 5 May 2023 13:41:38 -0400 Message-Id: <20230505174204.2665599-11-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230505174204.2665599-1-Liam.Howlett@oracle.com> References: <20230505174204.2665599-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0144.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d5::10) To SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR10MB3022:EE_|BL3PR10MB6089:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b9321ec-c6ca-4807-75e5-08db4d9051a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5IrhhRdvB8vv/17lhNS6AdWofb8lZZIR5z3871A/n9DPKkaqeSIMTcCDr+XoVO1+HqVJfsBSTSqrJU1KcCQIGDs+xeuQYLGV8c2adVIXLAkqgP4cM/x/K+dtS5SINQYYGavq0Z2B9NwO5wUEU8fcwepkg4WWE6Htfhh9d74NcjAMCLT+6wL73tc2y8vjpMtBT59+KInzZXk8r6VbX+Pzf2RXWkKfHjs/SyCgeb8dEmd6UOK1YEoV5buTCXwVlNrLS+TOZnxGyslXkhRl0AGn5+tFAaWVG7CeFDYcI97Uj1+l3vrqbcz2lWiYVHtSKY+yc7JATTj7HqNnsbDNzVY2Wq4k8yQaM3tdPgc/VHO5+DxXLDlFo7a1LY4H4wZVNlCK2xEBLXcPif8bNfG622yYIFJebmuHzoVpCPMsrn/4aovLQzkrNVa8+/pximnb1oQgSoooJ5z/8LfA4/0oEZZhBXsP/gTm7TaOQG1JIGhx3ucg0hHqnLM3nFWBm+eZmVm5hd7q1a8+A8+6DIeH24S0ANh38vXnqXHdJTRqY6DJHR458eytg3zXMfxNxRcPo8c1 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3022.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(366004)(39860400002)(376002)(136003)(451199021)(66476007)(6916009)(4326008)(66946007)(66556008)(6666004)(478600001)(6486002)(316002)(36756003)(86362001)(83380400001)(107886003)(2616005)(6506007)(1076003)(26005)(6512007)(8936002)(5660300002)(8676002)(2906002)(41300700001)(186003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: By2OzFSEbXewBukove7VeQG2ACqCGtvk6ajnT2N+tEfsTinSf/QvwA4K7Mkf1qsKY9fm2mk9077xxrmrRdS0dHJV9NmGIecdQxjlBwMowMW43KAxk6dwXO1qVobf/AuNeRFmAEqFDTZtyxqFOfnCiflZxgay9g6vbLDKLNBGwWjOu8pOwCOtTzzCs81oRReynPlPqAsNFiU/jv7A48Haxg2AzECZLt/PzZ86VMEoS+L7RZJG6Yv77fBRVCEuuhTQ1WaDPmGXJSN/+I+9U4Y9Tr3PFgc3Gb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QOkWCVg9JOmLX/gvYo5/WKwaD7QkswoWnF2s9CEC+QgR3dowdDKmEf7JiXsGTn2joIhiSHsoYM52nFYPhit4FRoBJpC+/b4FPaab8l7YGIfeiQn++K+d1lCAob/xCeOvlxsm6Oj/omy77raPJ9GJjQ3UUzZUoxU4r5ETrFOgmHV35z2w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b9321ec-c6ca-4807-75e5-08db4d9051a5 X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2023 17:44:04.4688 (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: vb3iBgdDKw1izveosrSgKJvbQXEJZ0ikD+pBJYcdlHc/EdN6GOYgMdk+pdPYAUZFBXGPfi8DBq4I/fHnKeTnSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6089 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-05_24,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2305050146 X-Proofpoint-GUID: e9RYm0PeKU_u5aA2vraGPTpuqLugWopS X-Proofpoint-ORIG-GUID: e9RYm0PeKU_u5aA2vraGPTpuqLugWopS 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: Use MAS_BUG_ON() to dump the maple state and tree in the unlikely event of an issue. Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 8fd83f21caf00..a594f1d88d062 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -453,7 +453,7 @@ enum maple_type mas_parent_type(struct ma_state *mas, struct maple_enode *enode) } /* - * mte_set_parent() - Set the parent node and encode the slot + * mas_set_parent() - Set the parent node and encode the slot * @enode: The encoded maple node. * @parent: The encoded maple node that is the parent of @enode. * @slot: The slot that @enode resides in @parent. @@ -462,16 +462,16 @@ enum maple_type mas_parent_type(struct ma_state *mas, struct maple_enode *enode) * parent type. */ static inline -void mte_set_parent(struct maple_enode *enode, const struct maple_enode *parent, - unsigned char slot) +void mas_set_parent(struct ma_state *mas, struct maple_enode *enode, + const struct maple_enode *parent, unsigned char slot) { unsigned long val = (unsigned long)parent; unsigned long shift; unsigned long type; enum maple_type p_type = mte_node_type(parent); - BUG_ON(p_type == maple_dense); - BUG_ON(p_type == maple_leaf_64); + MAS_BUG_ON(mas, p_type == maple_dense); + MAS_BUG_ON(mas, p_type == maple_leaf_64); switch (p_type) { case maple_range_64: @@ -1740,7 +1740,7 @@ static inline void mas_adopt_children(struct ma_state *mas, offset = ma_data_end(node, type, pivots, mas->max); do { child = mas_slot_locked(mas, slots, offset); - mte_set_parent(child, parent, offset); + mas_set_parent(mas, child, parent, offset); } while (offset--); } @@ -2705,9 +2705,9 @@ static inline void mas_set_split_parent(struct ma_state *mas, return; if ((*slot) <= split) - mte_set_parent(mas->node, left, *slot); + mas_set_parent(mas, mas->node, left, *slot); else if (right) - mte_set_parent(mas->node, right, (*slot) - split - 1); + mas_set_parent(mas, mas->node, right, (*slot) - split - 1); (*slot)++; } @@ -3104,12 +3104,12 @@ static int mas_spanning_rebalance(struct ma_state *mas, mte_node_type(mast->orig_l->node)); mast->orig_l->depth++; mab_mas_cp(mast->bn, 0, mt_slots[mast->bn->type] - 1, &l_mas, true); - mte_set_parent(left, l_mas.node, slot); + mas_set_parent(mas, left, l_mas.node, slot); if (middle) - mte_set_parent(middle, l_mas.node, ++slot); + mas_set_parent(mas, middle, l_mas.node, ++slot); if (right) - mte_set_parent(right, l_mas.node, ++slot); + mas_set_parent(mas, right, l_mas.node, ++slot); if (mas_is_root_limits(mast->l)) { new_root: @@ -3336,8 +3336,8 @@ static inline bool mas_split_final_node(struct maple_subtree_state *mast, * The Big_node data should just fit in a single node. */ ancestor = mas_new_ma_node(mas, mast->bn); - mte_set_parent(mast->l->node, ancestor, mast->l->offset); - mte_set_parent(mast->r->node, ancestor, mast->r->offset); + mas_set_parent(mas, mast->l->node, ancestor, mast->l->offset); + mas_set_parent(mas, mast->r->node, ancestor, mast->r->offset); mte_to_node(ancestor)->parent = mas_mn(mas)->parent; mast->l->node = ancestor;