Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 193614
b: refs/heads/master
c: 1e94d72
h: refs/heads/master
v: v3
  • Loading branch information
Tom Herbert authored and David S. Miller committed Mar 19, 2010
1 parent 5670d64 commit 35821ab
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a034016287236f435dbb8f1f57aee906f22b4598
refs/heads/master: 1e94d72feab025b8f7c55d07020602f82f3a97dd
2 changes: 2 additions & 0 deletions trunk/include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,9 @@ struct softnet_data {
struct sk_buff *completion_queue;

/* Elements below can be accessed between CPUs for RPS */
#ifdef CONFIG_SMP
struct call_single_data csd ____cacheline_aligned_in_smp;
#endif
struct sk_buff_head input_pkt_queue;
struct napi_struct backlog;
};
Expand Down
24 changes: 24 additions & 0 deletions trunk/net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2174,6 +2174,7 @@ int weight_p __read_mostly = 64; /* old backlog weight */

DEFINE_PER_CPU(struct netif_rx_stats, netdev_rx_stat) = { 0, };

#ifdef CONFIG_SMP
/*
* get_rps_cpu is called from netif_receive_skb and returns the target
* CPU from the RPS map of the receiving queue for a given skb.
Expand Down Expand Up @@ -2293,6 +2294,7 @@ static void trigger_softirq(void *data)
__napi_schedule(&queue->backlog);
__get_cpu_var(netdev_rx_stat).received_rps++;
}
#endif /* CONFIG_SMP */

/*
* enqueue_to_backlog is called to queue an skb to a per CPU backlog
Expand Down Expand Up @@ -2320,6 +2322,7 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu)

/* Schedule NAPI for backlog device */
if (napi_schedule_prep(&queue->backlog)) {
#ifdef CONFIG_SMP
if (cpu != smp_processor_id()) {
struct rps_remote_softirq_cpus *rcpus =
&__get_cpu_var(rps_remote_softirq_cpus);
Expand All @@ -2328,6 +2331,9 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu)
__raise_softirq_irqoff(NET_RX_SOFTIRQ);
} else
__napi_schedule(&queue->backlog);
#else
__napi_schedule(&queue->backlog);
#endif
}
goto enqueue;
}
Expand Down Expand Up @@ -2367,9 +2373,13 @@ int netif_rx(struct sk_buff *skb)
if (!skb->tstamp.tv64)
net_timestamp(skb);

#ifdef CONFIG_SMP
cpu = get_rps_cpu(skb->dev, skb);
if (cpu < 0)
cpu = smp_processor_id();
#else
cpu = smp_processor_id();
#endif

return enqueue_to_backlog(skb, cpu);
}
Expand Down Expand Up @@ -2735,6 +2745,7 @@ int __netif_receive_skb(struct sk_buff *skb)
*/
int netif_receive_skb(struct sk_buff *skb)
{
#ifdef CONFIG_SMP
int cpu;

cpu = get_rps_cpu(skb->dev, skb);
Expand All @@ -2743,6 +2754,9 @@ int netif_receive_skb(struct sk_buff *skb)
return __netif_receive_skb(skb);
else
return enqueue_to_backlog(skb, cpu);
#else
return __netif_receive_skb(skb);
#endif
}
EXPORT_SYMBOL(netif_receive_skb);

Expand Down Expand Up @@ -3168,6 +3182,7 @@ void netif_napi_del(struct napi_struct *napi)
}
EXPORT_SYMBOL(netif_napi_del);

#ifdef CONFIG_SMP
/*
* net_rps_action sends any pending IPI's for rps. This is only called from
* softirq and interrupts must be enabled.
Expand All @@ -3184,15 +3199,18 @@ static void net_rps_action(cpumask_t *mask)
}
cpus_clear(*mask);
}
#endif

static void net_rx_action(struct softirq_action *h)
{
struct list_head *list = &__get_cpu_var(softnet_data).poll_list;
unsigned long time_limit = jiffies + 2;
int budget = netdev_budget;
void *have;
#ifdef CONFIG_SMP
int select;
struct rps_remote_softirq_cpus *rcpus;
#endif

local_irq_disable();

Expand Down Expand Up @@ -3255,13 +3273,17 @@ static void net_rx_action(struct softirq_action *h)
netpoll_poll_unlock(have);
}
out:
#ifdef CONFIG_SMP
rcpus = &__get_cpu_var(rps_remote_softirq_cpus);
select = rcpus->select;
rcpus->select ^= 1;

local_irq_enable();

net_rps_action(&rcpus->mask[select]);
#else
local_irq_enable();
#endif

#ifdef CONFIG_NET_DMA
/*
Expand Down Expand Up @@ -6204,9 +6226,11 @@ static int __init net_dev_init(void)
queue->completion_queue = NULL;
INIT_LIST_HEAD(&queue->poll_list);

#ifdef CONFIG_SMP
queue->csd.func = trigger_softirq;
queue->csd.info = queue;
queue->csd.flags = 0;
#endif

queue->backlog.poll = process_backlog;
queue->backlog.weight = weight_p;
Expand Down

0 comments on commit 35821ab

Please sign in to comment.