From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by dpdk.org (Postfix) with ESMTP id 318CF5A74 for ; Fri, 10 Jul 2015 01:37:41 +0200 (CEST) Received: by pabvl15 with SMTP id vl15so157741637pab.1 for ; Thu, 09 Jul 2015 16:37:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ehaxwdQbSImCa9HAlyk65egWmzPRjfG6NvM9AzVwTOo=; b=YcqyQuZ/hZIhp0KjLblVVr2dV9e3kLrQDbEaEa+UzupTsLrZeegqFhjMlixHmeOzvA aZZzXxBptLpwqqivLxhvMqihZ1tVdWchEJs/zDvIG4MCz75sdvNs0lE169hjRCkXJhcl 8rm99dKd5gO6TfK3WmSnYPYil8s4U/TbybjTw8HGArUjCs/lqE/ljQRMl+ODMBoc56Ao 8lqcRqKA2PEZiorhggp7iODsCPOqv4KRNsrs8k+54FNbm6dXVFfuUhgZPrdSxh7ityTD aNkyAH4yVjQuYatRM/uf44p6Hcag/50MBMpxetuLiX4HcRbt1zi+Rl7Gk91vTWxyXW7e J/rA== X-Gm-Message-State: ALoCoQkNvdAw+b+cUBYPqU1NAPRhAeBA1KcsT+9Fuf/PASm+ckzk1eFt/cFw18T1NKZtnl1HEkIr X-Received: by 10.68.221.70 with SMTP id qc6mr35657058pbc.76.1436485060599; Thu, 09 Jul 2015 16:37:40 -0700 (PDT) Received: from urahara.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id cq5sm7232038pad.11.2015.07.09.16.37.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Jul 2015 16:37:40 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Date: Thu, 9 Jul 2015 16:37:48 -0700 Message-Id: <1436485068-30609-3-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436485068-30609-1-git-send-email-stephen@networkplumber.org> References: <1436485068-30609-1-git-send-email-stephen@networkplumber.org> Cc: Stephen Hemminger Subject: [dpdk-dev] [PATCH 2/2] mbuf: make sure userdata is initialized X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jul 2015 23:37:42 -0000 From: Stephen Hemminger For applications that use m->userdata the initialization can be a signficant (10%) performance penalty. Rather than taking the cache penalty of initializing userdata in the receive handling, do it in the place where mbuf is already cache hot and being setup. Signed-off-by: Stephen Hemminger --- drivers/net/cxgbe/sge.c | 1 + drivers/net/e1000/em_rxtx.c | 2 ++ drivers/net/e1000/igb_rxtx.c | 2 ++ drivers/net/enic/enic_main.c | 2 ++ drivers/net/fm10k/fm10k.h | 1 + drivers/net/i40e/i40e_rxtx.c | 4 ++++ drivers/net/ixgbe/ixgbe_rxtx.c | 4 ++++ drivers/net/ixgbe/ixgbe_rxtx_vec.c | 1 + drivers/net/virtio/virtio_rxtx.c | 3 +++ drivers/net/vmxnet3/vmxnet3_rxtx.c | 1 + drivers/net/xenvirt/rte_eth_xenvirt.c | 1 + lib/librte_mbuf/rte_mbuf.h | 1 + 12 files changed, 23 insertions(+) diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c index 359296e..c51ed39 100644 --- a/drivers/net/cxgbe/sge.c +++ b/drivers/net/cxgbe/sge.c @@ -406,6 +406,7 @@ static unsigned int refill_fl_usembufs(struct adapter *adap, struct sge_fl *q, } mbuf->data_off = RTE_PKTMBUF_HEADROOM; + mbuf->userdata = NULL; mbuf->next = NULL; mapping = (dma_addr_t)(mbuf->buf_physaddr + mbuf->data_off); diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c index 38f5c3b..a2fd522 100644 --- a/drivers/net/e1000/em_rxtx.c +++ b/drivers/net/e1000/em_rxtx.c @@ -790,6 +790,7 @@ eth_em_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxq->crc_len); rxm->data_off = RTE_PKTMBUF_HEADROOM; rte_packet_prefetch((char *)rxm->buf_addr + rxm->data_off); + rxm->userdata = NULL; rxm->nb_segs = 1; rxm->next = NULL; rxm->pkt_len = pkt_len; @@ -959,6 +960,7 @@ eth_em_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, data_len = rte_le_to_cpu_16(rxd.length); rxm->data_len = data_len; rxm->data_off = RTE_PKTMBUF_HEADROOM; + rxm->userdata = NULL; /* * If this is the first buffer of the received packet, diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 43d6703..9fc0690 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -774,6 +774,7 @@ eth_igb_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, pkt_len = (uint16_t) (rte_le_to_cpu_16(rxd.wb.upper.length) - rxq->crc_len); rxm->data_off = RTE_PKTMBUF_HEADROOM; + rxm->userdata = NULL; rte_packet_prefetch((char *)rxm->buf_addr + rxm->data_off); rxm->nb_segs = 1; rxm->next = NULL; @@ -948,6 +949,7 @@ eth_igb_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, data_len = rte_le_to_cpu_16(rxd.wb.upper.length); rxm->data_len = data_len; rxm->data_off = RTE_PKTMBUF_HEADROOM; + rxm->userdata = NULL; /* * If this is the first buffer of the received packet, diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 15313c2..8cf5948 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -342,6 +342,7 @@ static int enic_rq_alloc_buf(struct vnic_rq *rq) } hdr_mbuf->data_off = RTE_PKTMBUF_HEADROOM; + hdr_mbuf->userdata = NULL; hdr_mbuf->nb_segs = 2; hdr_mbuf->port = enic->port_id; @@ -363,6 +364,7 @@ static int enic_rq_alloc_buf(struct vnic_rq *rq) } mbuf->data_off = RTE_PKTMBUF_HEADROOM; + mbuf->userdata = NULL; mbuf->next = NULL; dma_addr = (dma_addr_t) diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h index c089882..c9d9147 100644 --- a/drivers/net/fm10k/fm10k.h +++ b/drivers/net/fm10k/fm10k.h @@ -257,6 +257,7 @@ fm10k_pktmbuf_reset(struct rte_mbuf *mb, uint8_t in_port) mb->data_off = (uint16_t)(RTE_PTR_ALIGN((char *)mb->buf_addr + RTE_PKTMBUF_HEADROOM, FM10K_RX_DATABUF_ALIGN) - (char *)mb->buf_addr); + mb->userdata = NULL; mb->port = in_port; } diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c index 88b015d..177b823 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -804,6 +804,7 @@ i40e_rx_alloc_bufs(struct i40e_rx_queue *rxq) rte_mbuf_refcnt_set(mb, 1); mb->next = NULL; mb->data_off = RTE_PKTMBUF_HEADROOM; + mb->userdata = NULL; mb->nb_segs = 1; mb->port = rxq->port_id; dma_addr = rte_cpu_to_le_64(\ @@ -961,6 +962,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) I40E_RXD_QW1_LENGTH_PBUF_SHIFT) - rxq->crc_len; rxm->data_off = RTE_PKTMBUF_HEADROOM; + rxm->userdata = NULL; rte_prefetch0(RTE_PTR_ADD(rxm->buf_addr, RTE_PKTMBUF_HEADROOM)); rxm->nb_segs = 1; rxm->next = NULL; @@ -1069,6 +1071,7 @@ i40e_recv_scattered_pkts(void *rx_queue, I40E_RXD_QW1_LENGTH_PBUF_SHIFT; rxm->data_len = rx_packet_len; rxm->data_off = RTE_PKTMBUF_HEADROOM; + rxm->userdata = NULL; /** * If this is the first buffer of the received packet, set the @@ -2436,6 +2439,7 @@ i40e_alloc_rx_queue_mbufs(struct i40e_rx_queue *rxq) rte_mbuf_refcnt_set(mbuf, 1); mbuf->next = NULL; mbuf->data_off = RTE_PKTMBUF_HEADROOM; + mbuf->userdata = NULL; mbuf->nb_segs = 1; mbuf->port = rxq->port_id; diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index b1db57f..558c039 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -1054,6 +1054,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf) rte_mbuf_refcnt_set(mb, 1); mb->data_off = RTE_PKTMBUF_HEADROOM; + mb->userdata = NULL; /* populate the descriptors */ dma_addr = rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb)); @@ -1321,6 +1322,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, pkt_len = (uint16_t) (rte_le_to_cpu_16(rxd.wb.upper.length) - rxq->crc_len); rxm->data_off = RTE_PKTMBUF_HEADROOM; + rxm->userdata = NULL; rte_packet_prefetch((char *)rxm->buf_addr + rxm->data_off); rxm->nb_segs = 1; rxm->next = NULL; @@ -1596,6 +1598,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off = RTE_PKTMBUF_HEADROOM; + rxm->userdata = NULL; rxdp->read.hdr_addr = dma; rxdp->read.pkt_addr = dma; } else @@ -3462,6 +3465,7 @@ ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq) rte_mbuf_refcnt_set(mbuf, 1); mbuf->next = NULL; mbuf->data_off = RTE_PKTMBUF_HEADROOM; + mbuf->userdata = NULL; mbuf->nb_segs = 1; mbuf->port = rxq->port_id; diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec.c b/drivers/net/ixgbe/ixgbe_rxtx_vec.c index 912d3b4..d73d8dc 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx_vec.c +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec.c @@ -742,6 +742,7 @@ ixgbe_rxq_vec_setup(struct ixgbe_rx_queue *rxq) mb_def.nb_segs = 1; mb_def.data_off = RTE_PKTMBUF_HEADROOM; + mb_def.userdata = NULL; mb_def.port = rxq->port_id; rte_mbuf_refcnt_set(&mb_def, 1); diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 091c7fb..b6966cc 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -519,6 +519,7 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxm->port = rxvq->port_id; rxm->data_off = RTE_PKTMBUF_HEADROOM; + rxm->userdata = NULL; rxm->nb_segs = 1; rxm->next = NULL; @@ -635,6 +636,7 @@ virtio_recv_mergeable_pkts(void *rx_queue, seg_num = 1; rxm->data_off = RTE_PKTMBUF_HEADROOM; + rxm->userdata = NULL; rxm->nb_segs = seg_num; rxm->next = NULL; rxm->pkt_len = (uint32_t)(len[0] - hdr_size); @@ -673,6 +675,7 @@ virtio_recv_mergeable_pkts(void *rx_queue, rxm = rcv_pkts[extra_idx]; rxm->data_off = RTE_PKTMBUF_HEADROOM - hdr_size; + rxm->userdata = NULL; rxm->next = NULL; rxm->pkt_len = (uint32_t)(len[extra_idx]); rxm->data_len = (uint16_t)(len[extra_idx]); diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c b/drivers/net/vmxnet3/vmxnet3_rxtx.c index c0cbacb..fe6560b 100644 --- a/drivers/net/vmxnet3/vmxnet3_rxtx.c +++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c @@ -638,6 +638,7 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxm->pkt_len = (uint16_t)rcd->len; rxm->data_len = (uint16_t)rcd->len; rxm->data_off = RTE_PKTMBUF_HEADROOM; + rxm->userdata = NULL; rxm->ol_flags = 0; rxm->vlan_tci = 0; diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c index 73e8bce..4000a31 100644 --- a/drivers/net/xenvirt/rte_eth_xenvirt.c +++ b/drivers/net/xenvirt/rte_eth_xenvirt.c @@ -111,6 +111,7 @@ eth_xenvirt_rx(void *q, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) PMD_RX_LOG(DEBUG, "packet len:%d\n", len[i]); rxm->next = NULL; rxm->data_off = RTE_PKTMBUF_HEADROOM; + rxm->userdata = NULL; rxm->data_len = (uint16_t)(len[i] - sizeof(struct virtio_net_hdr)); rxm->nb_segs = 1; rxm->port = pi->port_id; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index f0a543b..302a9c1 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -794,6 +794,7 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m) m->vlan_tci_outer = 0; m->nb_segs = 1; m->port = 0xff; + m->userdata = NULL; m->ol_flags = 0; m->packet_type = 0; -- 2.1.4