From patchwork Sat Jan 29 17:02:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12729563 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 0DAADC43217 for ; Sat, 29 Jan 2022 17:02:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C7DBF6B0089; Sat, 29 Jan 2022 12:02:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C2B666B008C; Sat, 29 Jan 2022 12:02:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACB1D6B0092; Sat, 29 Jan 2022 12:02:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay031.a.hostedemail.com [64.99.140.31]) by kanga.kvack.org (Postfix) with ESMTP id 9942B6B0089 for ; Sat, 29 Jan 2022 12:02:08 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 6D47D80CBB for ; Sat, 29 Jan 2022 17:02:08 +0000 (UTC) X-FDA: 79083942336.01.6C20250 Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90059.outbound.protection.outlook.com [40.107.9.59]) by imf30.hostedemail.com (Postfix) with ESMTP id CD31F80003 for ; Sat, 29 Jan 2022 17:02:07 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mlIwTWhhzB0KgRw9pNUZU1mGDBOI3kfWgnz4sFQxctjd4up8MgHSDPOgkmuS6za+hM/BOfFtKJWG1sstK9kHpodwv61sPxcVwCAuecQ02qOfTm+oId0MsypLhRAmbuT0ZCl2LCg3tv3vG03HcM6NZPhN5WTqucHWBtPbMfLvimDyu2pkphlKoWp8skiiDHPzpR6HFv5l87yrLVZVpBtmFGyRJjDWUBULx4MrKiQTcfCboUq2DWLTa5joMMihuUIxTCKDitcu+FjftTFEIcS0cVWesytmFf6588bRu/ZVQKc+O0/upv+OHJqwd5dw+ZQ4uZJg+ADMaYquneh/z84ekA== 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=gLPBHDvXBMkQgGlRIh1tkuwHuf0uvhx2Y4O1zkh+ryw=; b=IwtV3Rl0eLpc26MnYR04jDyPdju1+/1pPkmuqAGxBFo81iq94cZobyTwWTtFo6fngzdU7MAQg/t+tlUemeJJcAO4M2ki52Wcp+NzqoBPjFsA4AvrgwELwNnQ+B2FWoUZN31Qsq5IF8iTiergVsKaOWe9fJsiMZ6oxz9beYj7vW4Lc7iJ2sW52AAvTlclNL3Si/hLoi5Gl2HDeFekFFICSR6cw6rCjDaMxTQJ60cVObjTfWa9rrUj1Cv1Lq5pVBRI+vzU/Nh7p4PPf0aLfhxKdJfhGJgJOLp/jcxpqjP0wP+Nc5c6xoka54dtgR53t85Ml+qQpH+KU44A1JGkg6K1nA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB2584.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:1e3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Sat, 29 Jan 2022 17:02:05 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::c9a2:1db0:5469:54e1]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::c9a2:1db0:5469:54e1%6]) with mapi id 15.20.4930.020; Sat, 29 Jan 2022 17:02:05 +0000 From: Christophe Leroy To: Luis Chamberlain , Jessica Yu CC: Christophe Leroy , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "kgdb-bugreport@lists.sourceforge.net" , "linux-mm@kvack.org" , "linux-arch@vger.kernel.org" Subject: [PATCH v3 2/6] modules: Prepare for handling several RB trees Thread-Topic: [PATCH v3 2/6] modules: Prepare for handling several RB trees Thread-Index: AQHYFTHxTvyQXbQLfkCX5PUzwy1VGA== Date: Sat, 29 Jan 2022 17:02:05 +0000 Message-ID: <4332de93cfe4eaaf756825d5f72cc7c9fae13c34.1643475473.git.christophe.leroy@csgroup.eu> References: In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f8beb2b4-6937-4366-c451-08d9e3491418 x-ms-traffictypediagnostic: PR0P264MB2584:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: hWGKN3C4Ej/d4sZlgyU4S3Sd0Ju1XH5zpBai7ucXgvF99VmB+7Ed909QOn0KuZs/6wZPwUqV8aRbPvOhjWwSgWnIGLfvFr9Dl5KQ83sceKllHwEorLvFPUsFduUVw9PKwoDjhsWxH++hMteK8pP/767QbgQyFz/gHEx9hIDQW+hQ7AMIp1omi2Uyr0psNousiqjoviXSjQ0O2Ww4S512Qi0doFRNaBx1PQgi5RWHvy8a4h937oSiPaQ3aFHICnCqeR/swx7mQcMgBw3wz+5bOMkTo0rfW1oKyl650iXIzDA9O3bqL6wtUtUWIWeh02ID8Pih6nbKm71bsMgpfY1B+MZhAFB6L9JURozmB0j04vDvxHfofZLxARII/MeeUmN0GLjgj6oE0Bp7s18gyk+fAvQSkHC2EyVmRVJLjaVKAJkkDYRLU2IbbN1zrtpMvq5qPE7X2wpKs0w3vfxIgbsENbqYiXzv121YYe5KKIXuAR8Aac5ZE2NbRWGW3iwdlRBZZXPF3AkAX3JGVYKD0aizIss+8m8Na1Pijj24QveEPoPoitJCI16x68JCU7iLCLI+HpMId3ngZeFa58uzjvRSFRjYZFhwKQID3WGDc8AuDvF837nfIPNVaOXyIfJC8YrVckQ8kJPFRBQcHRxFYbsNbUmlw6Kupuc7dnmTZMIVD1d8kcsmJPrFC4qyeQpjqSZKChehMxwNM5ELKUsq4WxhrQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(54906003)(110136005)(6512007)(2906002)(86362001)(6486002)(508600001)(4326008)(122000001)(38100700002)(91956017)(316002)(76116006)(26005)(64756008)(6506007)(8936002)(186003)(5660300002)(44832011)(66476007)(66556008)(71200400001)(66946007)(8676002)(66446008)(83380400001)(2616005)(36756003)(38070700005)(20210929001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?JaN9RSDWGBfJlk/b/5Qfr7A?= =?iso-8859-1?q?CyycMar17QOeH+RCzl6lSu41ZgDUVo4cqHY0JwAa92AB5P/ivhEzu/TVtA4v?= =?iso-8859-1?q?6fk7Nxnj3vX/0E5dXtxRzRIm2AVBNpfiYNjTdW/usKK4hyrF2TKJq8NbpjNn?= =?iso-8859-1?q?NYcMu++nfNWk4bJbdzQWmmE83lY1wbCFEjhzTMOlEW/U8q2Oh66h/O7MH9O7?= =?iso-8859-1?q?JNdatcoM0jlAGNBqEWgu+h/CZZzUHyk+WeJ51FN/kQ50Q7ziidbeo2o7YyVb?= =?iso-8859-1?q?Ms3Ao23i2MSPduSuLJD1CxR4MbQ/5R4OKC6KiyymgqOnuhycozI95f/7TpqP?= =?iso-8859-1?q?L6paaXwqzzBwtl7EzCbnk3vQpXlwN7AFd3MJr3BTqc9lQDoQwyHAtskxJNoB?= =?iso-8859-1?q?Fm9vU4IVhw4a8gL9j7I+Ce7vLijNCdoO24WTO6ZnlbVGBZHMwDord6zJldbe?= =?iso-8859-1?q?sbux5FjTQlIkxxeSXz21AFBrtDaTEKy6aaIULrpS1CQ3fKXDybxfGKZ+m1Do?= =?iso-8859-1?q?x5Zs3L0TMFTP7BY2EZ9xUmotPo0hw6VKxkqnwif7VHBXuArtRt2vr8yiuPmb?= =?iso-8859-1?q?S4LqEKj/1NwcYkUdhM4raa35ii38VDXc4TL4SsTwlKq0SxLl0QtG5SkROwJG?= =?iso-8859-1?q?zsnapxDpimDi0tKFAkwzi0cyjTaCfjPmeLu29sXs+IQcnGt5YxWhz5NIbEus?= =?iso-8859-1?q?BDJ3iBN9RrThD4EpiFB8/hpaAf12KVfkA1ikfPtXdhhc8d4oQz5zUy/yrJdP?= =?iso-8859-1?q?l9TqepiSMJUXZ27hbhx1966XE3yXtbj5sEKeL5IDwxqwx0q5uM9tGP5F9t6U?= =?iso-8859-1?q?wsat907hVyg4IZJ6etr3rpGXuNfOnSMoI0UwvrXK5NxWTdldUWS+QXx6VER/?= =?iso-8859-1?q?uz07X96nrV5mVTOWJCMvfFPaQ5tx5p9huQ2I9siKMSE7F1hg9qFHtGbWLwg9?= =?iso-8859-1?q?Z/pYp5hsCdhuLEwibm+aRIcBXVzoEafyfPUozjJkYyXi8BjIhcgT8ePO8oCP?= =?iso-8859-1?q?VlDsP+fELXDmUnWiS0Cx4GejLhAU5UkAssdPWybNymoueRK1q5j5tXip7vKT?= =?iso-8859-1?q?WAZklJ64W2Ra9S++mQi2GNnt5qewGSI92ekMznULxSyK/O194bCkCuYsTYoh?= =?iso-8859-1?q?E5ETIZ734MUH0oJdERepOA6eNtEXNwTo+D4oQkD6PtOZupPHdDs6gvV0jOLI?= =?iso-8859-1?q?tgbRZsRFb22Xd1uTqZ9CwTm8AkZbWw0Q664evllQE6ppq/dqanMuVK9PZNdi?= =?iso-8859-1?q?eAN6PD0WoiXmbt/ezEEFWyHCwaaHE7+J97QW3Bi59FM25Ow7C3IWI003rQIG?= =?iso-8859-1?q?QuYRLMuDJEYrY4vv0hWLCJWlQtPEK/se0XJJMnxm+//8oWwjpcjid5Is5o9D?= =?iso-8859-1?q?HPUYLC6SUyL51faUPb1gEAvQFnfEYLdJvMb/R1x8xx6Nj215I3XPyy8kB7va?= =?iso-8859-1?q?lDGzVxWgoHcCE0Kq8AnpLk/mSyIIau7GBqxHhBbbfcqvrDdBmdwtdLh+OZ2B?= =?iso-8859-1?q?kM89u7tvdJvv29Wh+ehVks+cdlAoSiANevuXqEYMrhM9+7RhnyGv/vB12/OU?= =?iso-8859-1?q?OwT2bPTt41fht+gULDHmvNNObU/+J7z8noTSFjpP4iMk5M0K3CAMGQPtZwuc?= =?iso-8859-1?q?MJAIYIRCJ5OyJmNrYjVXSVgIOyNoD/V/lEXGPAEKNJ/OZMwBSUkY8kWEoBiH?= =?iso-8859-1?q?mpuckwWnhTUXf1D4lIlgT80YbfQwHPrQr1+0y6qsJvVtaMGkfCIWNIJ9UdpC?= =?iso-8859-1?q?l42s=3D?= MIME-Version: 1.0 X-OriginatorOrg: csgroup.eu X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: f8beb2b4-6937-4366-c451-08d9e3491418 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jan 2022 17:02:05.8452 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9914def7-b676-4fda-8815-5d49fb3b45c8 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: LdH7KpXpLR/SPVoBEu5F8ZKXySA9jFWD/oO3FnfyWuPiW9sB0K30qo4RJusuH7jHu9KByUnzLuzMMX7KzbnmhWKLV4Ggy0gEW6HrN7Q2g+0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB2584 X-Rspamd-Queue-Id: CD31F80003 X-Rspam-User: nil Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.9.59 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-Stat-Signature: twhe3ukxj5y4t6bp6xx6o356rmyuhgnd X-Rspamd-Server: rspam08 X-HE-Tag: 1643475727-154670 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000028, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In order to separate text and data, we need to setup two rb trees. Modify functions to give the tree as a parameter. Signed-off-by: Christophe Leroy --- kernel/module.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 080193e15d24..163e32e39064 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -162,14 +162,14 @@ static const struct latch_tree_ops mod_tree_ops = { .comp = mod_tree_comp, }; -static noinline void __mod_tree_insert(struct mod_tree_node *node) +static noinline void __mod_tree_insert(struct mod_tree_node *node, struct mod_tree_root *tree) { - latch_tree_insert(&node->node, &mod_tree.root, &mod_tree_ops); + latch_tree_insert(&node->node, &tree->root, &mod_tree_ops); } -static void __mod_tree_remove(struct mod_tree_node *node) +static void __mod_tree_remove(struct mod_tree_node *node, struct mod_tree_root *tree) { - latch_tree_erase(&node->node, &mod_tree.root, &mod_tree_ops); + latch_tree_erase(&node->node, &tree->root, &mod_tree_ops); } /* @@ -181,28 +181,28 @@ static void mod_tree_insert(struct module *mod) mod->core_layout.mtn.mod = mod; mod->init_layout.mtn.mod = mod; - __mod_tree_insert(&mod->core_layout.mtn); + __mod_tree_insert(&mod->core_layout.mtn, &mod_tree); if (mod->init_layout.size) - __mod_tree_insert(&mod->init_layout.mtn); + __mod_tree_insert(&mod->init_layout.mtn, &mod_tree); } static void mod_tree_remove_init(struct module *mod) { if (mod->init_layout.size) - __mod_tree_remove(&mod->init_layout.mtn); + __mod_tree_remove(&mod->init_layout.mtn, &mod_tree); } static void mod_tree_remove(struct module *mod) { - __mod_tree_remove(&mod->core_layout.mtn); + __mod_tree_remove(&mod->core_layout.mtn, &mod_tree); mod_tree_remove_init(mod); } -static struct module *mod_find(unsigned long addr) +static struct module *mod_find(unsigned long addr, struct mod_tree_root *tree) { struct latch_tree_node *ltn; - ltn = latch_tree_find((void *)addr, &mod_tree.root, &mod_tree_ops); + ltn = latch_tree_find((void *)addr, &tree->root, &mod_tree_ops); if (!ltn) return NULL; @@ -215,7 +215,7 @@ static void mod_tree_insert(struct module *mod) { } static void mod_tree_remove_init(struct module *mod) { } static void mod_tree_remove(struct module *mod) { } -static struct module *mod_find(unsigned long addr) +static struct module *mod_find(unsigned long addr, struct mod_tree_root *tree) { struct module *mod; @@ -234,22 +234,22 @@ static struct module *mod_find(unsigned long addr) * Bounds of module text, for speeding up __module_address. * Protected by module_mutex. */ -static void __mod_update_bounds(void *base, unsigned int size) +static void __mod_update_bounds(void *base, unsigned int size, struct mod_tree_root *tree) { unsigned long min = (unsigned long)base; unsigned long max = min + size; - if (min < module_addr_min) - module_addr_min = min; - if (max > module_addr_max) - module_addr_max = max; + if (min < tree->addr_min) + tree->addr_min = min; + if (max > tree->addr_max) + tree->addr_max = max; } static void mod_update_bounds(struct module *mod) { - __mod_update_bounds(mod->core_layout.base, mod->core_layout.size); + __mod_update_bounds(mod->core_layout.base, mod->core_layout.size, &mod_tree); if (mod->init_layout.size) - __mod_update_bounds(mod->init_layout.base, mod->init_layout.size); + __mod_update_bounds(mod->init_layout.base, mod->init_layout.size, &mod_tree); } #ifdef CONFIG_KGDB_KDB @@ -4742,7 +4742,7 @@ struct module *__module_address(unsigned long addr) module_assert_mutex_or_preempt(); - mod = mod_find(addr); + mod = mod_find(addr, &mod_tree); if (mod) { BUG_ON(!within_module(addr, mod)); if (mod->state == MODULE_STATE_UNFORMED)