Hi,

Can we use a pool for rttimer_queue_pool?

As we run without kernel lock, these pools should have IPL_MPFLOOR
protection.

ok?

bluhm

Index: net/route.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/route.c,v
retrieving revision 1.402
diff -u -p -r1.402 route.c
--- net/route.c 22 Feb 2022 01:15:02 -0000      1.402
+++ net/route.c 18 Apr 2022 23:42:09 -0000
@@ -148,8 +148,9 @@ struct cpumem *             rtcounters;
 int                    rttrash;        /* routes not in table but not freed */
 int                    ifatrash;       /* ifas not in ifp list but not free */
 
-struct pool            rtentry_pool;   /* pool for rtentry structures */
-struct pool            rttimer_pool;   /* pool for rttimer structures */
+struct pool    rtentry_pool;           /* pool for rtentry structures */
+struct pool    rttimer_pool;           /* pool for rttimer structures */
+struct pool    rttimer_queue_pool;     /* pool for rttimer_queue structures */
 
 void   rt_timer_init(void);
 int    rt_setgwroute(struct rtentry *, u_int);
@@ -184,7 +185,7 @@ route_init(void)
 {
        rtcounters = counters_alloc(rts_ncounters);
 
-       pool_init(&rtentry_pool, sizeof(struct rtentry), 0, IPL_SOFTNET, 0,
+       pool_init(&rtentry_pool, sizeof(struct rtentry), 0, IPL_MPFLOOR, 0,
            "rtentry", NULL);
 
        while (rt_hashjitter == 0)
@@ -1392,8 +1393,10 @@ rt_timer_init(void)
        if (rt_init_done)
                panic("rt_timer_init: already initialized");
 
-       pool_init(&rttimer_pool, sizeof(struct rttimer), 0, IPL_SOFTNET, 0,
-           "rttmr", NULL);
+       pool_init(&rttimer_pool, sizeof(struct rttimer), 0,
+           IPL_MPFLOOR, 0, "rttmr", NULL);
+       pool_init(&rttimer_queue_pool, sizeof(struct rttimer_queue), 0,
+           IPL_MPFLOOR, 0, "rttmrq", NULL);
 
        LIST_INIT(&rttimer_queue_head);
        timeout_set_proc(&rt_timer_timeout, rt_timer_timer, &rt_timer_timeout);
@@ -1409,7 +1412,8 @@ rt_timer_queue_create(u_int timeout)
        if (rt_init_done == 0)
                rt_timer_init();
 
-       if ((rtq = malloc(sizeof(*rtq), M_RTABLE, M_NOWAIT|M_ZERO)) == NULL)
+       rtq = pool_get(&rttimer_queue_pool, PR_NOWAIT | PR_ZERO);
+       if (rtq == NULL)
                return (NULL);
 
        rtq->rtq_timeout = timeout;
@@ -1445,7 +1449,7 @@ rt_timer_queue_destroy(struct rttimer_qu
        }
 
        LIST_REMOVE(rtq, rtq_link);
-       free(rtq, M_RTABLE, sizeof(*rtq));
+       pool_put(&rttimer_queue_pool, rtq);
 }
 
 unsigned long

Reply via email to