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. Requires additional changes in the
sysctl handlers (but that code is strange anyway).
> As we run without kernel lock, these pools should have IPL_MPFLOOR
> protection.
That makes sense to me. OK claudio@
> 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
>
--
:wq Claudio