user2526111
user2526111

Reputation: 474

netif_rx vs. netif_receive_skb in NAPI driver

I know the fact - we should call netif_receive_skb() when we're implementing NAPI poll() function. However, I don't really understand why? why? why?....

If we call "netif_rx()" in napi->poll(), is there any "duplicate" queueing happened? or we raise duplicate softirq un-necessarily?

Actually, I did some sort of performance testing with iperf tool with 1G gigabit ethernet card and it only shows 10-30mbps throughput difference only. (However, if I call netif_rx() in napi->poll, it doubles # of NET_RX SIRQs...)

Why should we call netif_receive_skb() directly in napi->poll()? To process packet as much as possible in napi->poll() context is really helping the performance??

Best regards,

Upvotes: 4

Views: 5342

Answers (2)

Dražen Grašovec
Dražen Grašovec

Reputation: 802

Maybe has to do with locking. netif_receive_skb() is to be called from NET_RX softirq, and softirqs can be executed simultaneously on different CPUs, so proper locking should be implemented to avoid race condition.

Upvotes: 1

Lea
Lea

Reputation: 46

When we try to review the source code, we will find that, every time we entered the netif_rx, it disabled the preempt, and by the time it left, it enabled the preempt again. Disabling/enabling preempt too often will certainly cause a performance(system performance) reduces.

Upvotes: 1

Related Questions