This patch replaces code that looks up the ndev from the ib_device and port number of a rxe device with the saved value of the ndev used when the rxe device was created. Since the rxe driver does not support multi port operation or path migration, the ndev is constant for the life of the rxe device. The ndev lookup code in rxe_init_packet has a significant performance impact under heavy load and can consume a noticeable fraction of the overall cpu time. Signed-off-by: Bob Pearson <rpearsonhpe@xxxxxxxxx> --- drivers/infiniband/sw/rxe/rxe_net.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index 10e4a752ff7c..c1b2eaf82334 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -508,14 +508,9 @@ struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av, { unsigned int hdr_len; struct sk_buff *skb = NULL; - struct net_device *ndev; - const struct ib_gid_attr *attr; + struct net_device *ndev = rxe->ndev; const int port_num = 1; - attr = rdma_get_gid_attr(&rxe->ib_dev, port_num, av->grh.sgid_index); - if (IS_ERR(attr)) - return NULL; - if (av->network_type == RXE_NETWORK_TYPE_IPV4) hdr_len = ETH_HLEN + sizeof(struct udphdr) + sizeof(struct iphdr); @@ -523,25 +518,14 @@ struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av, hdr_len = ETH_HLEN + sizeof(struct udphdr) + sizeof(struct ipv6hdr); - rcu_read_lock(); - ndev = rdma_read_gid_attr_ndev_rcu(attr); - if (IS_ERR(ndev)) { - rcu_read_unlock(); - goto out; - } - skb = alloc_skb(paylen + hdr_len + LL_RESERVED_SPACE(ndev), - GFP_ATOMIC); - - if (unlikely(!skb)) { - rcu_read_unlock(); + skb = alloc_skb(paylen + hdr_len + LL_RESERVED_SPACE(ndev), GFP_ATOMIC); + if (unlikely(!skb)) goto out; - } skb_reserve(skb, hdr_len + LL_RESERVED_SPACE(ndev)); /* FIXME: hold reference to this netdev until life of this skb. */ - skb->dev = ndev; - rcu_read_unlock(); + skb->dev = ndev; if (av->network_type == RXE_NETWORK_TYPE_IPV4) skb->protocol = htons(ETH_P_IP); @@ -554,7 +538,6 @@ struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av, pkt->mask |= RXE_GRH_MASK; out: - rdma_put_gid_attr(attr); return skb; } -- 2.39.2