Skip to content

Commit 3f4e1d2

Browse files
MortenBroerupbruce-richardson
authored andcommitted
net/intel: do not bypass mbuf lib for buffer fast-free
Freeing mbufs directly into the mempool meant that mbuf instrumentation, including mbuf history marking, was omitted. The mbufs are now freed via the rte_mbuf_raw_free_bulk() function instead. Added a static_assert to ensure that type casting the array of struct ci_tx_entry_vec to an array of rte_mbuf pointers remains sound. Performance note: The (n & 31) condition was not removed. For the default tx_rs_thresh value (32), the condition will be true. And due to inlining, the rte_mbuf_raw_free_bulk() ends up in an rte_memcpy(), where the optimizer takes advantage of knowing that the lower bits are not set. This should compensate somewhat for removing the handcoded optimization of copying in chunks of 32 mbufs. Signed-off-by: Morten Brørup <mb@smartsharesystems.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com> Tested-by: Bruce Richardson <bruce.richardson@intel.com>
1 parent b3a9569 commit 3f4e1d2

1 file changed

Lines changed: 3 additions & 33 deletions

File tree

  • drivers/net/intel/common

drivers/net/intel/common/tx.h

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -279,42 +279,12 @@ ci_tx_free_bufs_vec(struct ci_tx_queue *txq, ci_desc_done_fn desc_done, bool ctx
279279
(txq->fast_free_mp = txep[0].mbuf->pool);
280280

281281
if (mp != NULL && (n & 31) == 0) {
282-
void **cache_objs;
283-
struct rte_mempool_cache *cache = rte_mempool_default_cache(mp, rte_lcore_id());
284-
285-
if (cache == NULL)
286-
goto normal;
287-
288-
cache_objs = &cache->objs[cache->len];
289-
290-
if (n > RTE_MEMPOOL_CACHE_MAX_SIZE) {
291-
rte_mempool_ops_enqueue_bulk(mp, (void *)txep, n);
292-
goto done;
293-
}
294-
295-
/* The cache follows the following algorithm
296-
* 1. Add the objects to the cache
297-
* 2. Anything greater than the cache min value (if it
298-
* crosses the cache flush threshold) is flushed to the ring.
299-
*/
300-
/* Add elements back into the cache */
301-
uint32_t copied = 0;
302-
/* n is multiple of 32 */
303-
while (copied < n) {
304-
memcpy(&cache_objs[copied], &txep[copied], 32 * sizeof(void *));
305-
copied += 32;
306-
}
307-
cache->len += n;
308-
309-
if (cache->len >= cache->flushthresh) {
310-
rte_mempool_ops_enqueue_bulk(mp, &cache->objs[cache->size],
311-
cache->len - cache->size);
312-
cache->len = cache->size;
313-
}
282+
static_assert(sizeof(*txep) == sizeof(struct rte_mbuf *),
283+
"txep array is not similar to an array of rte_mbuf pointers");
284+
rte_mbuf_raw_free_bulk(mp, (void *)txep, n);
314285
goto done;
315286
}
316287

317-
normal:
318288
m = rte_pktmbuf_prefree_seg(txep[0].mbuf);
319289
if (likely(m)) {
320290
free[0] = m;

0 commit comments

Comments
 (0)