diff mbox

[RFC] net: ipv4 -- Introduce ifa limit per net

Message ID 20160304.231109.1838919633640757059.davem@davemloft.net
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

David Miller March 5, 2016, 4:11 a.m. UTC
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 04 Mar 2016 16:08:30 -0800

> __inet_del_ifa() should probably take into account in_dev->dead (no
> promotion, no list scan...)

Indeed, that is the real problem:

Comments

Cyrill Gorcunov March 5, 2016, 7:18 a.m. UTC | #1
On Fri, Mar 04, 2016 at 11:11:09PM -0500, David Miller wrote:
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Fri, 04 Mar 2016 16:08:30 -0800
> 
> > __inet_del_ifa() should probably take into account in_dev->dead (no
> > promotion, no list scan...)
> 
> Indeed, that is the real problem:

Oh, this email dropped into my inbox a way later then
I wrote the reply. I'll test it, thanks David and Eric!
Cyrill Gorcunov March 5, 2016, 3:57 p.m. UTC | #2
On Fri, Mar 04, 2016 at 11:11:09PM -0500, David Miller wrote:
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Fri, 04 Mar 2016 16:08:30 -0800
> 
> > __inet_del_ifa() should probably take into account in_dev->dead (no
> > promotion, no list scan...)
> 
> Indeed, that is the real problem:

Well, tried it out. Indeed it partially released the contention
but with patch applied I stuck with

Samples: 20K of event 'cpu-clock', Event count (approx.): 4647374938
Overhead  Shared Object        Symbol
  19.27%  [kernel]             [k] __local_bh_enable_ip
  15.97%  [kernel]             [k] lock_acquire
  15.12%  [kernel]             [k] fib_del_ifaddr
  11.66%  [kernel]             [k] lock_release
   7.57%  [kernel]             [k] lock_is_held
   5.35%  [kernel]             [k] lock_acquired
   3.26%  [kernel]             [k] _raw_spin_unlock_irqrestore
   3.04%  [kernel]             [k] __local_bh_disable_ip
   2.10%  [kernel]             [k] _raw_spin_unlock_irq
   1.54%  [kernel]             [k] native_save_fl
   1.37%  [kernel]             [k] ___might_sleep
   0.90%  [kernel]             [k] do_raw_spin_trylock
   0.83%  [kernel]             [k] nf_ct_iterate_cleanup
   0.77%  [kernel]             [k] debug_lockdep_rcu_enabled
   0.62%  [kernel]             [k] tick_nohz_idle_enter
   0.61%  [kernel]             [k] _raw_spin_lock
   0.58%  [kernel]             [k] __slab_alloc.isra.43.constprop.47
   0.42%  [kernel]             [k] get_parent_ip
   0.40%  [kernel]             [k] preempt_count_sub
   0.36%  [kernel]             [k] native_save_fl
   0.34%  [kernel]             [k] _raw_spin_unlock
   0.31%  [kernel]             [k] do_raw_spin_unlock

and until everything get cleaned up I couldn't connect
to the node via ssh. I continue playing with patch maybe
I find some other optimization paths. Thanks!
diff mbox

Patch

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 8c3df2c..7412feb 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -334,6 +334,12 @@  static void __inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
 
 	ASSERT_RTNL();
 
+	/* None of these potentially quadratic scans matter if the
+	 * device is being destroyed.
+	 */
+	if (in_dev->dead)
+		goto no_promotions;
+
 	/* 1. Deleting primary ifaddr forces deletion all secondaries
 	 * unless alias promotion is set
 	 **/
@@ -380,6 +386,7 @@  static void __inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
 			fib_del_ifaddr(ifa, ifa1);
 	}
 
+no_promotions:
 	/* 2. Unlink it */
 
 	*ifap = ifa1->ifa_next;