laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/38085?usp=email )
Change subject: gsm_bts_num(): use hashtable to lookup bts ...................................................................... gsm_bts_num(): use hashtable to lookup bts gsm_bts_num() is mostly used to lookup bts object from its nr in VTY and CTRL interfaces. However, it's also used in hotter paths like pcu_rx(). It is also used during local neighbor resolution, mostly at startup or when the VTY is re-applied from CTRL interface. Related: SYS#7062 Change-Id: I7312da7d9aa80c6d0f2e92e9c7d20d32ce453ad1 --- M include/osmocom/bsc/bts.h M include/osmocom/bsc/gsm_data.h M src/osmo-bsc/bts.c M src/osmo-bsc/gsm_data.c M src/osmo-bsc/net_init.c 5 files changed, 12 insertions(+), 3 deletions(-) Approvals: fixeria: Looks good to me, but someone else must approve laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/bsc/bts.h b/include/osmocom/bsc/bts.h index 38e675a..8e530ef 100644 --- a/include/osmocom/bsc/bts.h +++ b/include/osmocom/bsc/bts.h @@ -5,6 +5,7 @@ #include <stdbool.h> #include <osmocom/core/linuxlist.h> +#include <osmocom/core/hashtable.h> #include <osmocom/core/msgb.h> #include <osmocom/core/bitvec.h> #include <osmocom/gsm/tlv.h> @@ -340,6 +341,9 @@ /* Geographical location of the BTS, head list of "struct bts_location" */ struct llist_head loc_list; + /*! Entry in hash table network->bts_by_nr. */ + struct hlist_node node_by_nr; + /* number of this BTS in network */ gsm_bts_nr_t nr; /* human readable name / description */ diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 715e8c9..5ed339d 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -20,6 +20,7 @@ #include <osmocom/core/tdef.h> #include <osmocom/core/time_cc.h> #include <osmocom/core/linuxlist.h> +#include <osmocom/core/hashtable.h> #include <osmocom/core/linuxrbtree.h> #include <osmocom/core/utils.h> @@ -986,6 +987,7 @@ gsm_bts_nr_t num_bts; struct llist_head bts_list; struct llist_head bts_rejected; + DECLARE_HASHTABLE(bts_by_nr, 10); /* BTS-based counters when we can't find the actual BTS * e.g. when conn->lchan is NULL */ diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c index 790a8d4..38e5f11 100644 --- a/src/osmo-bsc/bts.c +++ b/src/osmo-bsc/bts.c @@ -159,6 +159,7 @@ /* Entries in bts->loc_list are freed by talloc recursively, no need to free them here. */ llist_del(&bts->list); + hash_del(&bts->node_by_nr); paging_destructor(bts); bts_setup_ramp_remove(bts); @@ -198,10 +199,12 @@ talloc_set_destructor(bts, gsm_bts_talloc_destructor); + bts->nr = bts_num; + llist_add_tail(&bts->list, &net->bts_list); + hash_add(net->bts_by_nr, &bts->node_by_nr, bts->nr); net->num_bts++; - bts->nr = bts_num; bts->num_trx = 0; INIT_LLIST_HEAD(&bts->trx_list); bts->network = net; diff --git a/src/osmo-bsc/gsm_data.c b/src/osmo-bsc/gsm_data.c index d5c74ad..d725572 100644 --- a/src/osmo-bsc/gsm_data.c +++ b/src/osmo-bsc/gsm_data.c @@ -231,11 +231,10 @@ if (num >= net->num_bts) return NULL; - llist_for_each_entry(bts, &net->bts_list, list) { + hash_for_each_possible(net->bts_by_nr, bts, node_by_nr, num) { if (bts->nr == num) return bts; } - return NULL; } diff --git a/src/osmo-bsc/net_init.c b/src/osmo-bsc/net_init.c index e5d3fad..fc29d43 100644 --- a/src/osmo-bsc/net_init.c +++ b/src/osmo-bsc/net_init.c @@ -124,6 +124,7 @@ INIT_LLIST_HEAD(&net->bts_list); net->num_bts = 0; + hash_init(net->bts_by_nr); net->T_defs = gsm_network_T_defs; osmo_tdefs_reset(net->T_defs); -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/38085?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: I7312da7d9aa80c6d0f2e92e9c7d20d32ce453ad1 Gerrit-Change-Number: 38085 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pes...@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de> Gerrit-Reviewer: laforge <lafo...@osmocom.org>