From: Anand Khoje <anand.a.khoje@oracle.com>
To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: dledford@redhat.com, jgg@ziepe.ca, haakon.bugge@oracle.com,
leon@kernel.org
Subject: [PATCH v7 for-next 2/2] IB/core: Read subnet_prefix in ib_query_port via cache.
Date: Mon, 28 Jun 2021 14:59:20 +0530 [thread overview]
Message-ID: <20210628092920.1088-3-anand.a.khoje@oracle.com> (raw)
In-Reply-To: <20210628092920.1088-1-anand.a.khoje@oracle.com>
ib_query_port() calls device->ops.query_port() to get the port
attributes. The method of querying is device driver specific.
The same function calls device->ops.query_gid() to get the GID and
extract the subnet_prefix (gid_prefix).
The GID and subnet_prefix are stored in a cache. But they do not get
read from the cache if the device is an Infiniband device. The
following change takes advantage of the cached subnet_prefix.
Testing with RDBMS has shown a significant improvement in performance
with this change.
The variable cache_is_initialized is added because ib_query_port()
gets called early in the stage when cache is not built while reading
port immutable properties.
In that case, the default GID still gets read from HCA for IB link-
layer devices.
Fixes: fad61ad ("IB/core: Add subnet prefix to port info")
Signed-off-by: Anand Khoje <anand.a.khoje@oracle.com>
Signed-off-by: Haakon Bugge <haakon.bugge@oracle.com>
---
drivers/infiniband/core/cache.c | 1 +
drivers/infiniband/core/device.c | 9 +++++++++
include/rdma/ib_verbs.h | 1 +
3 files changed, 11 insertions(+)
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index 929399e..4150043 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -1631,6 +1631,7 @@ int ib_cache_setup_one(struct ib_device *device)
err = ib_cache_update(device, p, true, true, true);
if (err)
return err;
+ device->port_data[p].cache_is_initialized = 1;
}
return 0;
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index fa20b18..e078a48 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -2063,6 +2063,15 @@ static int __ib_query_port(struct ib_device *device,
IB_LINK_LAYER_INFINIBAND)
return 0;
+ if (!device->port_data[port_num].cache_is_initialized)
+ goto query_gid_from_device;
+
+ ib_get_cached_subnet_prefix(device, port_num,
+ &port_attr->subnet_prefix);
+
+ return 0;
+
+query_gid_from_device:
err = device->ops.query_gid(device, port_num, 0, &gid);
if (err)
return err;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 371df1c..e692f9b 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2179,6 +2179,7 @@ struct ib_port_data {
spinlock_t netdev_lock;
+ u8 cache_is_initialized:1;
struct list_head pkey_list;
struct ib_port_cache cache;
--
1.8.3.1
prev parent reply other threads:[~2021-06-28 9:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-28 9:29 [PATCH v7 for-next 0/2] IB/core: Obtaining subnet_prefix from cache in Anand Khoje
2021-06-28 9:29 ` [PATCH v7 for-next 1/2] IB/core: Updating cache for subnet_prefix in config_non_roce_gid_cache() Anand Khoje
2021-06-28 9:29 ` Anand Khoje [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210628092920.1088-3-anand.a.khoje@oracle.com \
--to=anand.a.khoje@oracle.com \
--cc=dledford@redhat.com \
--cc=haakon.bugge@oracle.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).