• Jason Wang's avatar
    tun: rx batching · 5503fcec
    Jason Wang authored
    We can only process 1 packet at one time during sendmsg(). This often
    lead bad cache utilization under heavy load. So this patch tries to do
    some batching during rx before submitting them to host network
    stack. This is done through accepting MSG_MORE as a hint from
    sendmsg() caller, if it was set, batch the packet temporarily in a
    linked list and submit them all once MSG_MORE were cleared.
    
    Tests were done by pktgen (burst=128) in guest over mlx4(noqueue) on host:
    
                                     Mpps  -+%
        rx-frames = 0                0.91  +0%
        rx-frames = 4                1.00  +9.8%
        rx-frames = 8                1.00  +9.8%
        rx-frames = 16               1.01  +10.9%
        rx-frames = 32               1.07  +17.5%
        rx-frames = 48               1.07  +17.5%
        rx-frames = 64               1.08  +18.6%
        rx-frames = 64 (no MSG_MORE) 0.91  +0%
    
    User were allowed to change per device batched packets through
    ethtool -C rx-frames. NAPI_POLL_WEIGHT were used as upper limitation
    to prevent bh from being disabled too long.
    Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
    Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    5503fcec
tun.c 60.4 KB