net: remove INIT_RCU_HEAD() usage
[safe/jmp/linux-2.6] / net / core / drop_monitor.c
index d311202..f8c8749 100644 (file)
@@ -41,7 +41,7 @@ static void send_dm_alert(struct work_struct *unused);
  * netlink alerts
  */
 static int trace_state = TRACE_OFF;
-static spinlock_t trace_state_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(trace_state_lock);
 
 struct per_cpu_dm_data {
        struct work_struct dm_alert_work;
@@ -52,6 +52,7 @@ struct per_cpu_dm_data {
 
 struct dm_hw_stat_delta {
        struct net_device *dev;
+       unsigned long last_rx;
        struct list_head list;
        struct rcu_head rcu;
        unsigned long last_drop_val;
@@ -180,18 +181,25 @@ static void trace_napi_poll_hit(struct napi_struct *napi)
        struct dm_hw_stat_delta *new_stat;
 
        /*
-        * Ratelimit our check time to dm_hw_check_delta jiffies
+        * Don't check napi structures with no associated device
         */
-       if (!napi->dev ||
-           !time_after(jiffies, napi->dev->last_rx + dm_hw_check_delta))
+       if (!napi->dev)
                return;
 
        rcu_read_lock();
        list_for_each_entry_rcu(new_stat, &hw_stats_list, list) {
+               /*
+                * only add a note to our monitor buffer if:
+                * 1) this is the dev we received on
+                * 2) its after the last_rx delta
+                * 3) our rx_dropped count has gone up
+                */
                if ((new_stat->dev == napi->dev)  &&
+                   (time_after(jiffies, new_stat->last_rx + dm_hw_check_delta)) &&
                    (napi->dev->stats.rx_dropped != new_stat->last_drop_val)) {
                        trace_drop_common(NULL, NULL);
                        new_stat->last_drop_val = napi->dev->stats.rx_dropped;
+                       new_stat->last_rx = jiffies;
                        break;
                }
        }
@@ -287,7 +295,7 @@ static int dropmon_net_event(struct notifier_block *ev_block,
                        goto out;
 
                new_stat->dev = dev;
-               INIT_RCU_HEAD(&new_stat->rcu);
+               new_stat->last_rx = jiffies;
                spin_lock(&trace_state_lock);
                list_add_rcu(&new_stat->list, &hw_stats_list);
                spin_unlock(&trace_state_lock);