V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
innoink
V2EX  ›  问与答

有没有熟悉 DPDK 的大佬?问一个关于 prefetch 用法的问题

  •  
  •   innoink · Nov 30, 2016 · 3627 views
    This topic created in 3439 days ago, the information mentioned may be changed or developed.

    函数 static void rte_prefetch0(const volatile void *p)作用是 Prefetch a cache line into all cache levels.

    在 example 中有很多出地方用到,举个例子,在 l3fwd-power 的 937 行开始:

            for (j = 0; j < PREFETCH_OFFSET && j < nb_rx; j++) {
                rte_prefetch0(rte_pktmbuf_mtod(
                        pkts_burst[j], void *));
            }
    
            /* Prefetch and forward already prefetched packets */
            for (j = 0; j < (nb_rx - PREFETCH_OFFSET); j++) {
                rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[
                        j + PREFETCH_OFFSET], void *));
                l3fwd_simple_forward(pkts_burst[j], portid,
                                qconf);
            }
    
            /* Forward remaining prefetched packets */
            for (; j < nb_rx; j++) {
                l3fwd_simple_forward(pkts_burst[j], portid,
                                qconf);
            }
    

    这里预取之后执行 l3fwd_simple_forward ,里面主要做的是解析数据包格式之类的,需要读取保存数据包的 buf_addr ,但前面预取只是一个 cacheline ( 64 字节),对应 mbuf 结构的前半部分,数据包的 buf_addr 根本没有预取啊,那这个 prefetch 还有什么效果?

    1 replies    2016-11-30 14:02:40 +08:00
    innoink
        1
    innoink  
    OP
       Nov 30, 2016
    是我自己眼花了,这个问题终结
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2695 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 13:19 · PVG 21:19 · LAX 06:19 · JFK 09:19
    ♥ Do have faith in what you're doing.