Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Use a queue of deferred entries to delete routes instead...
details: https://anonhg.NetBSD.org/src/rev/284b7c049f1b
branches: trunk
changeset: 358610:284b7c049f1b
user: christos <christos%NetBSD.org@localhost>
date: Tue Jan 09 19:52:29 2018 +0000
description:
Use a queue of deferred entries to delete routes instead of a fixed stack
of 10. Otherwise we can overflow in route deletions from the rexmit timer.
XXX: pullup-8
diffstat:
sys/net/route.c | 36 +++++++++++++++---------------------
sys/net/route.h | 5 +++--
sys/sys/param.h | 4 ++--
3 files changed, 20 insertions(+), 25 deletions(-)
diffs (121 lines):
diff -r 015e153a851d -r 284b7c049f1b sys/net/route.c
--- a/sys/net/route.c Tue Jan 09 17:58:09 2018 +0000
+++ b/sys/net/route.c Tue Jan 09 19:52:29 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route.c,v 1.202 2018/01/05 01:53:15 christos Exp $ */
+/* $NetBSD: route.c,v 1.203 2018/01/09 19:52:29 christos Exp $ */
/*-
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
#endif
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.202 2018/01/05 01:53:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.203 2018/01/09 19:52:29 christos Exp $");
#include <sys/param.h>
#ifdef RTFLUSH_DEBUG
@@ -255,7 +255,7 @@
struct workqueue *wq;
struct work wk;
kmutex_t lock;
- struct rtentry *queue[10];
+ SLIST_HEAD(, rtentry) queue;
} rt_free_global __cacheline_aligned;
/* psref for rtentry */
@@ -458,6 +458,8 @@
#endif
mutex_init(&rt_free_global.lock, MUTEX_DEFAULT, IPL_SOFTNET);
+ SLIST_INIT(&rt_free_global.queue);
+
rt_psref_class = psref_class_create("rtentry", IPL_SOFTNET);
error = workqueue_create(&rt_free_global.wq, "rt_free",
@@ -687,20 +689,19 @@
rt_free_work(struct work *wk, void *arg)
{
-restart:
- mutex_enter(&rt_free_global.lock);
- for (size_t i = 0; i < __arraycount(rt_free_global.queue); i++) {
- if (rt_free_global.queue[i] == NULL)
- continue;
- struct rtentry *rt = rt_free_global.queue[i];
- rt_free_global.queue[i] = NULL;
+ for (;;) {
+ struct rtentry *rt;
+
+ mutex_enter(&rt_free_global.lock);
+ if ((rt = SLIST_FIRST(&rt_free_global.queue)) == NULL) {
+ mutex_exit(&rt_free_global.lock);
+ return;
+ }
+ SLIST_REMOVE_HEAD(&rt_free_global.queue, rt_free);
mutex_exit(&rt_free_global.lock);
-
atomic_dec_uint(&rt->rt_refcnt);
_rt_free(rt);
- goto restart;
}
- mutex_exit(&rt_free_global.lock);
}
void
@@ -714,16 +715,9 @@
return;
}
- size_t i;
mutex_enter(&rt_free_global.lock);
- for (i = 0; i < __arraycount(rt_free_global.queue); i++) {
- if (rt_free_global.queue[i] == NULL)
- break;
- }
-
- KASSERT(i < __arraycount(rt_free_global.queue));
- rt_free_global.queue[i] = rt;
rt_ref(rt);
+ SLIST_INSERT_HEAD(&rt_free_global.queue, rt, rt_free);
mutex_exit(&rt_free_global.lock);
workqueue_enqueue(rt_free_global.wq, &rt_free_global.wk, NULL);
}
diff -r 015e153a851d -r 284b7c049f1b sys/net/route.h
--- a/sys/net/route.h Tue Jan 09 17:58:09 2018 +0000
+++ b/sys/net/route.h Tue Jan 09 19:52:29 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route.h,v 1.116 2017/12/18 04:11:13 ozaki-r Exp $ */
+/* $NetBSD: route.h,v 1.117 2018/01/09 19:52:29 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -124,7 +124,8 @@
struct sockaddr *rt_tag; /* route tagging info */
#ifdef _KERNEL
kcondvar_t rt_cv;
- struct psref_target rt_psref;
+ struct psref_target rt_psref;
+ SLIST_ENTRY(rtentry) rt_free; /* queue of deferred frees */
#endif
};
diff -r 015e153a851d -r 284b7c049f1b sys/sys/param.h
--- a/sys/sys/param.h Tue Jan 09 17:58:09 2018 +0000
+++ b/sys/sys/param.h Tue Jan 09 19:52:29 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.556 2018/01/04 01:42:25 christos Exp $ */
+/* $NetBSD: param.h,v 1.557 2018/01/09 19:52:29 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
* 2.99.9 (299000900)
*/
-#define __NetBSD_Version__ 899001100 /* NetBSD 8.99.11 */
+#define __NetBSD_Version__ 899001200 /* NetBSD 8.99.12 */
#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
(m) * 1000000) + (p) * 100) <= __NetBSD_Version__)
Home |
Main Index |
Thread Index |
Old Index