2003-02-17 08:08:51

by Zwane Mwaikambo

[permalink] [raw]
Subject: [PATCH][2.5][5/5] CPU Hotplug net/

dev.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+)

Index: linux-2.5.61-trojan/net/core/dev.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.61/net/core/dev.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 dev.c
--- linux-2.5.61-trojan/net/core/dev.c 15 Feb 2003 12:32:33 -0000 1.1.1.1
+++ linux-2.5.61-trojan/net/core/dev.c 17 Feb 2003 07:00:13 -0000
@@ -2945,3 +2945,67 @@
return call_usermodehelper(argv [0], argv, envp);
}
#endif
+
+static int dev_cpu_callback(struct notifier_block *nfb, unsigned long action, void * ocpu)
+{
+ struct sk_buff *list_sk, *sk_head;
+ struct net_device *list_net, *net_head;
+ struct softnet_data *queue;
+ struct sk_buff *skb;
+ unsigned int cpu = smp_processor_id();
+ unsigned long oldcpu = (unsigned long) ocpu;
+ unsigned long flags;
+
+ if (action != CPU_OFFLINE)
+ return NOTIFY_OK;
+
+ local_irq_save(flags);
+
+ /* Move completion queue */
+
+ list_sk = softnet_data[oldcpu].completion_queue;
+ if (list_sk != NULL) {
+ sk_head = list_sk;
+ while (list_sk->next != NULL)
+ list_sk = list_sk->next;
+ list_sk->next = softnet_data[cpu].completion_queue;
+ softnet_data[cpu].completion_queue = sk_head;
+ softnet_data[oldcpu].completion_queue = NULL;
+ }
+
+ /* Move output_queue */
+
+ list_net = softnet_data[oldcpu].output_queue;
+ if (list_net != NULL) {
+ net_head = list_net;
+ while (list_net->next != NULL)
+ list_net = list_net->next_sched;
+ list_net->next_sched = softnet_data[cpu].output_queue;
+ softnet_data[cpu].output_queue = net_head;
+ softnet_data[oldcpu].output_queue = NULL;
+ }
+
+ local_irq_restore(flags);
+
+ /* Move input_pkt_queue */
+
+ queue = &softnet_data[oldcpu];
+ for (;;) {
+ skb = __skb_dequeue(&queue->input_pkt_queue);
+ if (skb == NULL)
+ break;
+ netif_rx(skb);
+ }
+
+ return 0;
+}
+
+static struct notifier_block cpu_callback_nfb = {&dev_cpu_callback, NULL, 0 };
+
+static int __init dev_cpu_callback_init(void)
+{
+ register_cpu_notifier(&cpu_callback_nfb);
+ return 0;
+}
+
+__initcall(dev_cpu_callback_init);