On Tue, Apr 19, 2022 at 08:59:25AM +0200, Claudio Jeker wrote:
> On Tue, Apr 19, 2022 at 01:44:40AM +0200, Alexander Bluhm wrote:
> > Hi,
> > 
> > Can we use a pool for rttimer_queue_pool?
> 
> Another option would be to use static rttimer_queues instead of allocating
> them. Not that many timers are used.

Multicast allocates queues on demand per routing table.  So static
allocation is not an option.

sys_setsockopt -> sosetopt -> rip_ctloutput -> ip_mrouter_set ->
ip_mrouter_init -> rt_timer_queue_create

Diff merged to current.

ok?

> Requires additional changes in the
> sysctl handlers (but that code is strange anyway).

I am trying to clean up that mess.

bluhm

Index: net/route.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/route.c,v
retrieving revision 1.403
diff -u -p -r1.403 route.c
--- net/route.c 19 Apr 2022 15:44:56 -0000      1.403
+++ net/route.c 19 Apr 2022 15:53:59 -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 */
 
 int    rt_setgwroute(struct rtentry *, u_int);
 void   rt_putgwroute(struct rtentry *);
@@ -183,7 +184,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)
@@ -1387,8 +1388,10 @@ rt_timer_init(void)
 {
        static struct timeout   rt_timer_timeout;
 
-       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);
@@ -1400,7 +1403,8 @@ rt_timer_queue_create(u_int timeout)
 {
        struct rttimer_queue    *rtq;
 
-       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;
@@ -1436,7 +1440,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