NAPI question
Subsystems (2)
In dev.c, there is this code. Please see my question by the ### marks.
static void net_rx_action(struct softirq_action *h)
{
int this_cpu = smp_processor_id();
struct softnet_data *queue = &softnet_data[this_cpu];
unsigned long start_time = jiffies;
int budget = netdev_max_backlog;
br_read_lock(BR_NETPROTO_LOCK);
local_irq_disable();
while (!list_empty(&queue->poll_list)) {
struct net_device *dev;
if (budget <= 0 || jiffies - start_time > 1)
goto softnet_break;
local_irq_enable();
dev = list_entry(queue->poll_list.next, struct net_device, poll_list);
if (dev->quota <= 0 || dev->poll(dev, &budget)) {
local_irq_disable();
list_del(&dev->poll_list);
list_add_tail(&dev->poll_list, &queue->poll_list);### How can quota ever get negative? In other words, why not just set it to dev->weight ### always? Or, if the dev didn't use up all it's quota from the last round, why not ### increase it up to a max of 2 x weight or something like that?
if (dev->quota < 0)
dev->quota += dev->weight;
else
dev->quota = dev->weight;
} else {
dev_put(dev);
local_irq_disable();
}
}Signature · 3 lines
Ben Greear <[email protected]> <Ben_Greear AT excite.com> President of Candela Technologies Inc http://www.candelatech.com ScryMUD: http://scry.wanfear.com http://scry.wanfear.com/~greear
This is basic Deficit Round Robin (DRR) algorithm, you cant just set things arbitrarily, i am afraid ;->
Search for George Varghese's paper if you want to know more.
cheers,
jamal
Quoted 23 lines · Ben Greear
### How can quota ever get negative? In other words, why not just set it to
dev->weightalways? Or, if the dev didn't use up all it's quota from the last round, why not
### increase it up to a max of 2 x weight or something like that?if (dev->quota < 0) dev->quota += dev->weight; else dev->quota = dev->weight; } else { dev_put(dev); local_irq_disable(); } }--
Ben Greear <[email protected]> <Ben_GreearAT excite.com>
President of Candela Technologies Inc http://www.candelatech.com
ScryMUD: http://scry.wanfear.com http://scry.wanfear.com/~greear