From patchwork Wed Jun 15 14:19:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 12882413 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 C1A93CCA47E for ; Wed, 15 Jun 2022 14:19:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B730D6B0075; Wed, 15 Jun 2022 10:19:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B4A146B0078; Wed, 15 Jun 2022 10:19:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99BE76B007B; Wed, 15 Jun 2022 10:19:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 77F3F6B0078 for ; Wed, 15 Jun 2022 10:19:45 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 438153496A for ; Wed, 15 Jun 2022 14:19:45 +0000 (UTC) X-FDA: 79580678730.11.7A7D8B1 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf20.hostedemail.com (Postfix) with ESMTP id 7C1411C007E for ; Wed, 15 Jun 2022 14:19:44 +0000 (UTC) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25FDvQ1S015201; Wed, 15 Jun 2022 14:19:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2021-07-09; bh=gTOa4sCsowVfnMdwtik+r2rl6y+WpU7ND9MuGs2cInU=; b=OwO8JApKapKC6acGaXwDqLR3fnGED+ZobDeMzGxQvqx+jrrUITCKT3qqwkiSkEMAxI7q wOYkxsYzOJ0W/r6nnjJnmzaA8exGsYtJj1E9mxh50uWuOXY+1n+qV4tOFOaAECMWVPZ2 0pPjZ4IfAn59gpP3b216nNdGw6HX0QhFOqqXF4pbtitusRG+if0cyNgYSTG5e3L/zDXG UafYUK6ZACp0HlieOBNGP3Q1IJVGxip7Mu8g5C/B9sA16pVJNqR8M39jc0vu3EaZYr2o Q6BR9jCAo52I3rc0NOXcImJbc4aFUP4cirCnFV4mNurkVY/9ywvjacA7VpJvLaGYsH02 Ew== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmhn0gsfw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Jun 2022 14:19:41 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25FDtnhf031252; Wed, 15 Jun 2022 14:19:40 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2049.outbound.protection.outlook.com [104.47.57.49]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gpr7p2nrp-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Jun 2022 14:19:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iAVcxmU5UoP1HFpE8xSFAVXMI4+q4SxUyMjGYGk/SyqIKgWoM5S7Oopq6vrggGsjwsZ4wDxKLIR6xYK8x64zaOz/lVXStZLClgyi4z4UIm/SyQWJJtUTDREaT6mmHQrDxNN4DLMfNkFIQCVbQirGXLTzKIkCu+sEQIYreONvuWYx/ktbAkiEANHTQNTTL72E/qsBMWWlbWaqBHQfM40JsuvD4hCghH1X9xI4qD1udqm3hlS8dDtETEY7bPUW9ISLoIV9YSg4C47BOA27m8u+cJ+OPMCWuiqjqexELPiDXoIZvfynEBxB4vCkTNw7QwJLRpQYOJj3VIuW2TbdqyIy3w== 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=gTOa4sCsowVfnMdwtik+r2rl6y+WpU7ND9MuGs2cInU=; b=fG100qUb8FKI68ANOFuz7K9igKYwriJ2BJlU0Z/jWuGNxF0l/sSSquIq1jHIGPx36uV5Rcs7EUqKXiUl364fNvdQJ99RCMszw3onrdTQlK9jOKhvK4ttdhOa7mP32NrAgLTmWq8iIHJdWVm5cRUDWG1PtRSmDKxhACzdWSty177mW6lmH4xEFHUcYPbr9bupaaqX7C1Vz77lDU/rTDiMU8q53Xgd5SW5M4xcmXoVUF/uCqxgiDWwuuVwZK0G39l0gNmagInYNa1JHKQeimqTaZpPT+NvrQ0TrPBcPUZPo9VVVNl7jNsFBTygcVA+/ZDKxEDlF+fuivXMQzIvosAKtw== 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=gTOa4sCsowVfnMdwtik+r2rl6y+WpU7ND9MuGs2cInU=; b=cI93iyTsIzV21JBNqVqRMBgjoZKAdUgmZXw9aVAwmCt5/H4+x30S7ZpRbalR+JLYhMb8P23i9kyy54tZvjPZKZbV7RQhW5Dz+oSYfNlxbXJf9w5f5zbW6Uvm3ccUcaIMUyVysQaLLEHyiIuuS0gm9MWG4i5WncWRIlWxe5tGyLU= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by MN2PR10MB3342.namprd10.prod.outlook.com (2603:10b6:208:12b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.15; Wed, 15 Jun 2022 14:19:39 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::e1df:2e42:6674:313e]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::e1df:2e42:6674:313e%7]) with mapi id 15.20.5332.013; Wed, 15 Jun 2022 14:19:39 +0000 From: Liam Howlett To: "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton , Qian Cai CC: Yu Zhao Subject: [PATCH Fix 1/3] maple_tree: Fix mt_destroy_walk() on full non-leaf non-alloc nodes Thread-Topic: [PATCH Fix 1/3] maple_tree: Fix mt_destroy_walk() on full non-leaf non-alloc nodes Thread-Index: AQHYgMLys5sMlAg0rkKdMdWAEuRIZQ== Date: Wed, 15 Jun 2022 14:19:38 +0000 Message-ID: <20220615141921.417598-2-Liam.Howlett@oracle.com> References: <20220615141921.417598-1-Liam.Howlett@oracle.com> In-Reply-To: <20220615141921.417598-1-Liam.Howlett@oracle.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.35.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: dc122f79-b9bf-447e-c071-08da4eda1519 x-ms-traffictypediagnostic: MN2PR10MB3342:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: O8yBqy+6DT0/AMzL3EhZF7BS8UaWKcooNaO4E5NrVnFhODI23pHzP3AHN6zllK5sAu6yxuctiEhBfdgq652mzjDtcKwWBUdxBuVKNEu5B/24I5erfCEZADc5CFs+63b6/uFFEOBcVbb80+H1udMsTVx20J9D/RTLD5khKrlWvxE7bzZVK9ayEmdetFLjT+ql0uVdVDsEfv3/LnUa1QtKat+rkn5vTZ2xt6m0/VAurF9XSelFgC5fK7cV+OxnkwAAWSoN1U5e7MQB0b9anq/HZoll5SQEKPTn6F5ihInVbQlDWxy6iRFeRToy56E4zEd4Ag/SONhHqST6z1WhHMYG5zRGGBUCQUJVOzveMuMGnRckneTajhxMbnrpt0GPKDhV2tZhnALgfYURMDnRRhgwg8zv2PTFA2QYKe3ZEScEsHUrBdAJGlS0AdUud9lij3ieLa73LxJNUgy35MUzZ3q30rjAO6DYtiR/p4EymQeG7xg3nZPkFMMcwCiX+h8+xdbrO4aFyh64ZAlxXqXl+/ujRXAAoOUg0KudBR3GJ2dQSy07wry/9wZIA981b4ntv28S93y6DgzPsw88SwtU+48By8paFMUK7tXU/NhfdA8w5mOXJclWWtqtfAT7RX1d9iGO9IhsKMgqI0flFiRl+baDbn+pgUwJvSdfsu/p3dqGrQNM6Zc/EXw2BlrnbuBqEYsAi7iG3SGRPy7U6cAz6zhuqw== 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:(13230016)(366004)(86362001)(316002)(122000001)(110136005)(38100700002)(186003)(5660300002)(4326008)(8936002)(2906002)(71200400001)(38070700005)(66556008)(64756008)(66476007)(8676002)(66446008)(6506007)(76116006)(91956017)(26005)(6512007)(508600001)(83380400001)(6486002)(1076003)(36756003)(44832011)(2616005)(66946007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?mT24yWl/IIVZDL3daLivHHf?= =?iso-8859-1?q?70f1REhRlk4R8dYnCG9NKTN9gbBUbUomNjYraHKuDw5fFJ2dHEra6mTcrPGq?= =?iso-8859-1?q?U8dEN4qD6rQm9OBM9kAsqQD/AvMa/Qm8uVKMz2XpV5fCuo3jnNFqztLIiLZ7?= =?iso-8859-1?q?l9r6jODAHhXtTDhcOvFWllNUKJsvWl1URD1jPIVbsq1HBMdQD4dE0KXz9icX?= =?iso-8859-1?q?kHnnSVCkCjrzjOFVO4OyyZlcia4n3m7fpo2E2hoT2nxYZnrCV6VLDzTzpora?= =?iso-8859-1?q?XFyiUQaFX7SUvTE9c/EkkwLVvcBRlfRQW7t1uNi2md9jUB2SZ7a3TLxKDKfV?= =?iso-8859-1?q?Bh1aDxP3QWMe83Q6uXgU/LtUADjW5SeZ6usb/g6VSBjfTRtD2MFv7DKJujLI?= =?iso-8859-1?q?vHFKKtC1VSWzUsBVBlnsz+7918ZJZVN+lAV9qsxoY6y5qFoQBY+VZFrzimY1?= =?iso-8859-1?q?wZnYBz38tOkdNrFvFcMgx6nyjiKvWlJaTa5BNvSV/By2Y4/qdjyN50WEYVCo?= =?iso-8859-1?q?vHanxZiSyvydoH3r3qnjoAJsCHlpLd3bYOqgSovrFPQDZaDTOoh2kHP50Nbi?= =?iso-8859-1?q?9d5y5z0OCPD+5QLp+deK4+3qn0F7BulCF9d9M4AaivBQKjvspza3zHvzYwgM?= =?iso-8859-1?q?eHYJ7yBwMAvpkahrMWI84kocuZmWVT+JBODcB2aHTGW5PtMOnVe1v8s+7gXS?= =?iso-8859-1?q?BZzE0hYYj/LiLcyDnbG0sCIpD6YmsiM3aApZCn02DY3U95aGlm10XnHVDMqh?= =?iso-8859-1?q?7erZAOd+XRC4/IgAilwGrI3I9Ic2BhUvPFhlL+9wuhrF/1gP1irIvYZGQv44?= =?iso-8859-1?q?aXA5UkpmLrRQOFPotp3HIIE5gVKXUp9MVgTABxIHFTJkjJtz4Odk1IQbhxph?= =?iso-8859-1?q?mXaz2mmvPqRodwdbtWQxNOc0iP2fJEhvvQKhqLXloSc7Qhn8LStvrdh02beG?= =?iso-8859-1?q?3u+ORTx2sfhqKq0Yb21Lg0G1Sh/50yRhFKlPXq8yEhk9MNfqFYHhQtc+KYQH?= =?iso-8859-1?q?OovzFPIkITu5pWqjxSEUDx72kXlpp+Nhp2Vk9jLXg4rGOGKKeZ+WRnwbVQoJ?= =?iso-8859-1?q?Ch9ALluWIOUw3L+Tgt+OXfSCHPy+zTuNccASpILzsu7M7+mckFY9IBYrxv5m?= =?iso-8859-1?q?djaCS5c/a6+2tkdst1lzBypjG0HH0fS280f1G4jwzKqe8rYvBPsV1H96of+I?= =?iso-8859-1?q?6jLfV6aDeiadeTs2tHAXGJsR2oTZ7viHDU879l84lpkugzK5yJ5vdGuNlQNx?= =?iso-8859-1?q?Gc9xX8Zb+S2L6DcR3sVNqT5YZn/jV28hIJsij3GLQjpIkmaC2YLZeXnhRWpr?= =?iso-8859-1?q?wTctaVtYl501AKlC4gQSPa8PdTa6V+oouxd1GlMjllRGY/ghJqOity+HZkvh?= =?iso-8859-1?q?u/oFYxi14IgSxuV5j3FlIjM0Rihhdh4qLQqR4mlNi+Ubmuq1d4a58mRZbBxT?= =?iso-8859-1?q?+dnSEpCw+bQ3eVzNd7VgpdUaovROJUNlulVuOYvY9JYrSwbK75PRa8FilirT?= =?iso-8859-1?q?Vr85pXDIAG4rIy7Ng9F98+jJ15/VxUGQzVIR1uMCra/KC13yvoZyz7JtNO6C?= =?iso-8859-1?q?qN5IHZZP9skbLyuhFLKvLwm0n1MZLZOtzKUF0nhzIiypgiRNFMQ5FuttUlJo?= =?iso-8859-1?q?PP45Znkd2dLRG2YhVpY13+im42nByel3dEvSSbDvzcYXt0jnI5v/cqBbm248?= =?iso-8859-1?q?ZXzhZcrExVRcYr+p7UAEcbYcpU2/rCHyFLA+RtMlLQ5Pe+fFys70EoXxs/5u?= =?iso-8859-1?q?K4+VvfSsKQOLzXUClZIn9kr3H2Dn3L+oALE4JNf9HOLMRVkZSKMHK2C9TTU8?= =?iso-8859-1?q?PGM0xpuk=3D?= MIME-Version: 1.0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc122f79-b9bf-447e-c071-08da4eda1519 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jun 2022 14:19:38.9411 (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: xxb+cYl0QcKFXL3sxe4ZaCZeeMn2+EUxoGCODm4K/NL211AtU0O3ksUIJ3UFU61Ur59Iy+MPOanUYn1Qz9YC7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB3342 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-15_04:2022-06-15,2022-06-15 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 mlxscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206150056 X-Proofpoint-GUID: Kn3t0HQrhaVeNK94DqR1lg96wv-dcNP9 X-Proofpoint-ORIG-GUID: Kn3t0HQrhaVeNK94DqR1lg96wv-dcNP9 ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1655302784; a=rsa-sha256; cv=pass; b=InGpNA8iiOtYnYpPMVHdRwe2MJ3v5MkoBsW6YgKhRveBvmUCngqicNBffMdHM3ttO3BqJZ qUc8br/tDBojqletruXSxWvFKx+BEOchgzfdRqtXnyJvzvy19OE3yj4zgVeqPZDA7b4Rq6 kVCnKxTALjhpUabwhrSgfQug5MNWX+0= ARC-Authentication-Results: i=2; imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=OwO8JApK; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=cI93iyTs; spf=none (imf20.hostedemail.com: domain of liam.howlett@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655302784; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gTOa4sCsowVfnMdwtik+r2rl6y+WpU7ND9MuGs2cInU=; b=BnJd5hGk/98diU23ymPXXjThT4arAyr0Inj+Ik/A08OG4qpXuYCbBEPLmc/sHNn7U+cMaS pZBNQaLICNeghAhzuVd4JeR1JKqSu9YPObo2irflD4Am64nOPgfxYWtpyuw8vGetSDhGcC daLQ9JPDT4FxM1nzk9U2nOxAkoHmU2o= X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 7C1411C007E X-Stat-Signature: 4como6y3web98derqgkuy7nekmtdbeni Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=OwO8JApK; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=cI93iyTs; spf=none (imf20.hostedemail.com: domain of liam.howlett@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") X-HE-Tag: 1655302784-342407 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: It is possible to iterate over the metadata of full non-leaf nodes when operating in non-alloc mode. Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 80622741c6b8..a1035963ae0d 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5429,11 +5429,15 @@ static void mt_destroy_walk(struct maple_enode *enode, unsigned char ma_flags, goto start_slots_free; type = mte_node_type(mas.node); slots = ma_slots(mte_to_node(mas.node), type); - if ((offset < mt_slots[type]) && (slots[offset])) { - struct maple_enode *parent = mas.node; + if ((offset < mt_slots[type])) { + struct maple_enode *next = slots[offset]; - mas.node = mas_slot_locked(&mas, slots, offset); - slots = mas_destroy_descend(&mas, parent, offset); + if (mte_node_type(next) && mte_to_node(next)) { + struct maple_enode *parent = mas.node; + + mas.node = mas_slot_locked(&mas, slots, offset); + slots = mas_destroy_descend(&mas, parent, offset); + } } node = mas_mn(&mas); } while (start != mas.node);