From mboxrd@z Thu Jan 1 00:00:00 1970 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 A86CBC433F5 for ; Wed, 23 Feb 2022 12:02:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 432578D0005; Wed, 23 Feb 2022 07:02:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E15F8D0001; Wed, 23 Feb 2022 07:02:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 282078D0005; Wed, 23 Feb 2022 07:02:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id 19DE88D0001 for ; Wed, 23 Feb 2022 07:02:40 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D248B9F84D for ; Wed, 23 Feb 2022 12:02:39 +0000 (UTC) X-FDA: 79173907638.31.12DEA64 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by imf27.hostedemail.com (Postfix) with ESMTP id D030140004 for ; Wed, 23 Feb 2022 12:02:38 +0000 (UTC) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4K3ZRF5YZlz9sSg; Wed, 23 Feb 2022 13:02:33 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PupAe0jjbyvw; Wed, 23 Feb 2022 13:02:33 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4K3ZRC0gJ1z9sSh; Wed, 23 Feb 2022 13:02:31 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 085D78B779; Wed, 23 Feb 2022 13:02:31 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id AROrFHZOhGpQ; Wed, 23 Feb 2022 13:02:30 +0100 (CET) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.7.201]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 65ED78B778; Wed, 23 Feb 2022 13:02:30 +0100 (CET) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.16.1) with ESMTPS id 21NC2LZS1148187 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 23 Feb 2022 13:02:21 +0100 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.17.1/Submit) id 21NC2LuK1148186; Wed, 23 Feb 2022 13:02:21 +0100 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Luis Chamberlain , Aaron Tomlin 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, linux-modules@vger.kernel.org Subject: [PATCH v6 2/6] module: Prepare for handling several RB trees Date: Wed, 23 Feb 2022 13:02:12 +0100 Message-Id: <8788e5b6180ad45ec933359bc97c1c8fe865f186.1645607143.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1645617734; l=4776; s=20211009; h=from:subject:message-id; bh=zW762VTX2wgJQdaUEhSgceFO6MryOmerkmFB78i7T/o=; b=opu3ZV2a7zUveKjdvLUAJlBYvn4o0Fkim4MybaD/po/M6L4Jo4sZpUoZZojQnG+EvZEEnt+68ssv sFG4q5q6CiQMIjcCvJRlIX2LlhqxRcsmGyvpggqXstHlEUFEb+xb X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Stat-Signature: ruhyei4yyufwez8ifhdaix8njqpq9afc X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.235.10 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D030140004 X-HE-Tag: 1645617758-79877 Content-Transfer-Encoding: quoted-printable 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: 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/internal.h | 4 ++-- kernel/module/main.c | 16 ++++++++-------- kernel/module/tree_lookup.c | 20 ++++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/kernel/module/internal.h b/kernel/module/internal.h index ac64e53ac5e3..0f3146347256 100644 --- a/kernel/module/internal.h +++ b/kernel/module/internal.h @@ -157,13 +157,13 @@ extern struct mod_tree_root mod_tree; void mod_tree_insert(struct module *mod); void mod_tree_remove_init(struct module *mod); void mod_tree_remove(struct module *mod); -struct module *mod_find(unsigned long addr); +struct module *mod_find(unsigned long addr, struct mod_tree_root *tree); #else /* !CONFIG_MODULES_TREE_LOOKUP */ =20 static inline void mod_tree_insert(struct module *mod) { } static inline void mod_tree_remove_init(struct module *mod) { } static inline void mod_tree_remove(struct module *mod) { } -static inline struct module *mod_find(unsigned long addr) +static inline struct module *mod_find(unsigned long addr, struct mod_tre= e_root *tree) { struct module *mod; =20 diff --git a/kernel/module/main.c b/kernel/module/main.c index 3832a71cdacb..a831f51595d7 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -91,22 +91,22 @@ struct symsearch { * 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 mo= d_tree_root *tree) { unsigned long min =3D (unsigned long)base; unsigned long max =3D min + size; =20 - if (min < module_addr_min) - module_addr_min =3D min; - if (max > module_addr_max) - module_addr_max =3D max; + if (min < tree->addr_min) + tree->addr_min =3D min; + if (max > tree->addr_max) + tree->addr_max =3D max; } =20 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); } =20 static void module_assert_mutex_or_preempt(void) @@ -3017,7 +3017,7 @@ struct module *__module_address(unsigned long addr) =20 module_assert_mutex_or_preempt(); =20 - mod =3D mod_find(addr); + mod =3D mod_find(addr, &mod_tree); if (mod) { BUG_ON(!within_module(addr, mod)); if (mod->state =3D=3D MODULE_STATE_UNFORMED) diff --git a/kernel/module/tree_lookup.c b/kernel/module/tree_lookup.c index 0bc4ec3b22ce..995fe68059db 100644 --- a/kernel/module/tree_lookup.c +++ b/kernel/module/tree_lookup.c @@ -61,14 +61,14 @@ static const struct latch_tree_ops mod_tree_ops =3D { .comp =3D mod_tree_comp, }; =20 -static noinline void __mod_tree_insert(struct mod_tree_node *node) +static noinline void __mod_tree_insert(struct mod_tree_node *node, struc= t 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); } =20 -static void __mod_tree_remove(struct mod_tree_node *node) +static void __mod_tree_remove(struct mod_tree_node *node, struct mod_tre= e_root *tree) { - latch_tree_erase(&node->node, &mod_tree.root, &mod_tree_ops); + latch_tree_erase(&node->node, &tree->root, &mod_tree_ops); } =20 /* @@ -80,28 +80,28 @@ void mod_tree_insert(struct module *mod) mod->core_layout.mtn.mod =3D mod; mod->init_layout.mtn.mod =3D mod; =20 - __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); } =20 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); } =20 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); } =20 -struct module *mod_find(unsigned long addr) +struct module *mod_find(unsigned long addr, struct mod_tree_root *tree) { struct latch_tree_node *ltn; =20 - ltn =3D latch_tree_find((void *)addr, &mod_tree.root, &mod_tree_ops); + ltn =3D latch_tree_find((void *)addr, &tree->root, &mod_tree_ops); if (!ltn) return NULL; =20 --=20 2.34.1