ipv4: avoid parallel route cache gc executions
authorMarcelo Ricardo Leitner <mleitner@redhat.com>
Thu, 14 Aug 2014 19:44:53 +0000 (16:44 -0300)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 5 Nov 2014 20:27:47 +0000 (20:27 +0000)
commitad5ca98f54c3b6604a7bb72059973a85deb0b779
tree6da314d313defbaad89172ec6c7e77259c2a8747
parent6c383b3a565dbf07cf6665e5da535f8668479453
ipv4: avoid parallel route cache gc executions

When rt_intern_hash() has to deal with neighbour cache overflowing,
it triggers the route cache garbage collector in an attempt to free
some references on neighbour entries.

Such call cannot be done async but should also not run in parallel with
an already-running one, so that they don't collapse fighting over the
hash lock entries.

This patch thus blocks parallel executions with spinlocks:
- A call from worker and from rt_intern_hash() are not the same, and
cannot be merged, thus they will wait each other on rt_gc_lock.
- Calls to gc from rt_intern_hash() may happen in parallel but we must
wait for it to finish in order to try again. This dedup and
synchrinozation is then performed by the locking just before calling
__do_rt_garbage_collect().

Signed-off-by: Marcelo Ricardo Leitner <mleitner@redhat.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/ipv4/route.c