This v5 patch series is used to read the port_attribute subnet_prefix
from a valid cache entry instead of having to call
device->ops.query_gid() in Infiniband link-layer devices. This requires
addition of a flag used to check that the cache entry is initialized and
that a valid value is being read.
1. Removed the port validity check from ib_get_cached_subnet_prefix.
This check was not useful as the port_num is always valid.
2. Shuffled locks pkey_lost_lock and netdev_lock in struct ib_port_data.
This was done as output of pahole showed two 4-byte holes in the
structure ib_port_data after pkey_list_lock and netdev_lock. Moving
netdev_lock shaved off 8 bytes from the structure.
3. Added a flag to struct ib_port_data. This is used to validate the
status of cached subnet_prefix. This valid cache entry of subnet_prefix
is used in function __ib_query_port().
This allows the utilization of the cache entry and hence avoids a call
into device->ops.query_gid(). We also ensure that in the event of a
cache update, the value for subnet_prefix gets read from the newly updated
GID cache and not via ib_query_port(), so that we do not end up reading a
stale cache value.
Anand Khoje (3):
IB/core: Removed port validity check from ib_get_cached_subnet_prefix
IB/core: Shuffle locks in ib_port_data to save memory
IB/core: Obtain subnet_prefix from cache in IB devices
drivers/infiniband/core/cache.c | 21 +++++++++++++--------
drivers/infiniband/core/core_priv.h | 2 +-
drivers/infiniband/core/device.c | 20 +++++++++++---------
drivers/infiniband/core/security.c | 7 ++-----
include/rdma/ib_cache.h | 1 -
include/rdma/ib_verbs.h | 5 ++++-
6 files changed, 31 insertions(+), 25 deletions(-)
--
1.8.3.1
pahole shows two 4-byte holes in struct ib_port_data after
pkey_list_lock and netdev_lock respectively.
Shuffling the netdev_lock to be after pkey_list_lock, this
shaves off eight bytes from the struct.
Suggested-by: Haakon Bugge <[email protected]>
Signed-off-by: Anand Khoje <[email protected]>
Reviewed-by: Leon Romanovsky <[email protected]>
---
v1 -> v2:
- Split the v1 patch in 3 patches as per Leon's suggestion.
v2 -> v3:
- No changes.
v3 -> v4:
- No changes.
v4 -> v5:
- No changes.
---
include/rdma/ib_verbs.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 05dbc21..c96d601 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2174,11 +2174,13 @@ struct ib_port_data {
struct ib_port_immutable immutable;
spinlock_t pkey_list_lock;
+
+ spinlock_t netdev_lock;
+
struct list_head pkey_list;
struct ib_port_cache cache;
- spinlock_t netdev_lock;
struct net_device __rcu *netdev;
struct hlist_node ndev_hash_link;
struct rdma_port_counter port_counter;
--
1.8.3.1
On Wed, Jun 16, 2021 at 09:15:06PM +0530, Anand Khoje wrote:
> This v5 patch series is used to read the port_attribute subnet_prefix
> from a valid cache entry instead of having to call
> device->ops.query_gid() in Infiniband link-layer devices. This requires
> addition of a flag used to check that the cache entry is initialized and
> that a valid value is being read.
>
> 1. Removed the port validity check from ib_get_cached_subnet_prefix.
> This check was not useful as the port_num is always valid.
>
> 2. Shuffled locks pkey_lost_lock and netdev_lock in struct ib_port_data.
> This was done as output of pahole showed two 4-byte holes in the
> structure ib_port_data after pkey_list_lock and netdev_lock. Moving
> netdev_lock shaved off 8 bytes from the structure.
>
> 3. Added a flag to struct ib_port_data. This is used to validate the
> status of cached subnet_prefix. This valid cache entry of subnet_prefix
> is used in function __ib_query_port().
> This allows the utilization of the cache entry and hence avoids a call
> into device->ops.query_gid(). We also ensure that in the event of a
> cache update, the value for subnet_prefix gets read from the newly updated
> GID cache and not via ib_query_port(), so that we do not end up reading a
> stale cache value.
>
> Anand Khoje (3):
> IB/core: Removed port validity check from ib_get_cached_subnet_prefix
> IB/core: Shuffle locks in ib_port_data to save memory
I took these two, thanks
Jason