Switch sys/net to percpu_create.

This commit is contained in:
riastradh 2020-02-01 12:54:50 +00:00
parent 3d6eb80076
commit 4734f65cda
4 changed files with 21 additions and 29 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if.c,v 1.469 2020/01/29 03:16:28 thorpej Exp $ */
/* $NetBSD: if.c,v 1.470 2020/02/01 12:54:50 riastradh Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.469 2020/01/29 03:16:28 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.470 2020/02/01 12:54:50 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@ -2916,17 +2916,6 @@ if_tunnel_ro_init_pc(void *p, void *arg __unused, struct cpu_info *ci __unused)
tro->tr_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
}
percpu_t *
if_tunnel_alloc_ro_percpu(void)
{
percpu_t *ro_percpu;
ro_percpu = percpu_alloc(sizeof(struct tunnel_ro));
percpu_foreach(ro_percpu, if_tunnel_ro_init_pc, NULL);
return ro_percpu;
}
static void
if_tunnel_ro_fini_pc(void *p, void *arg __unused, struct cpu_info *ci __unused)
{
@ -2938,11 +2927,18 @@ if_tunnel_ro_fini_pc(void *p, void *arg __unused, struct cpu_info *ci __unused)
mutex_obj_free(tro->tr_lock);
}
percpu_t *
if_tunnel_alloc_ro_percpu(void)
{
return percpu_create(sizeof(struct tunnel_ro),
if_tunnel_ro_init_pc, if_tunnel_ro_fini_pc, NULL);
}
void
if_tunnel_free_ro_percpu(percpu_t *ro_percpu)
{
percpu_foreach(ro_percpu, if_tunnel_ro_fini_pc, NULL);
percpu_free(ro_percpu, sizeof(struct tunnel_ro));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_l2tp.c,v 1.42 2020/02/01 02:58:05 riastradh Exp $ */
/* $NetBSD: if_l2tp.c,v 1.43 2020/02/01 12:54:50 riastradh Exp $ */
/*
* Copyright (c) 2017 Internet Initiative Japan Inc.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.42 2020/02/01 02:58:05 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.43 2020/02/01 12:54:50 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -267,8 +267,8 @@ l2tp_clone_create(struct if_clone *ifc, int unit)
sc->l2tp_ro_percpu = if_tunnel_alloc_ro_percpu();
sc->l2tp_ifq_percpu = percpu_alloc(sizeof(struct ifqueue *));
percpu_foreach(sc->l2tp_ifq_percpu, l2tp_ifq_init_pc, NULL);
sc->l2tp_ifq_percpu = percpu_create(sizeof(struct ifqueue *),
l2tp_ifq_init_pc, l2tp_ifq_fini_pc, NULL);
sc->l2tp_si = softint_establish(si_flags, l2tpintr_softint, sc);
mutex_enter(&l2tp_softcs.lock);
@ -367,7 +367,6 @@ l2tp_clone_destroy(struct ifnet *ifp)
mutex_exit(&sc->l2tp_lock);
softint_disestablish(sc->l2tp_si);
percpu_foreach(sc->l2tp_ifq_percpu, l2tp_ifq_fini_pc, NULL);
percpu_free(sc->l2tp_ifq_percpu, sizeof(struct ifqueue *));
mutex_enter(&l2tp_softcs.lock);

View File

@ -1,4 +1,4 @@
/* $NetBSD: route.c,v 1.226 2019/11/13 02:51:22 ozaki-r Exp $ */
/* $NetBSD: route.c,v 1.227 2020/02/01 12:54:50 riastradh 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.226 2019/11/13 02:51:22 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.227 2020/02/01 12:54:50 riastradh Exp $");
#include <sys/param.h>
#ifdef RTFLUSH_DEBUG
@ -2231,12 +2231,9 @@ rtcache_percpu_init_cpu(void *p, void *arg __unused, struct cpu_info *ci __unuse
percpu_t *
rtcache_percpu_alloc(void)
{
percpu_t *pc;
pc = percpu_alloc(sizeof(struct route *));
percpu_foreach(pc, rtcache_percpu_init_cpu, NULL);
return pc;
return percpu_create(sizeof(struct route *),
rtcache_percpu_init_cpu, NULL, NULL);
}
const struct sockaddr *

View File

@ -1,4 +1,4 @@
/* $NetBSD: wqinput.c,v 1.6 2019/09/19 04:09:34 ozaki-r Exp $ */
/* $NetBSD: wqinput.c,v 1.7 2020/02/01 12:54:51 riastradh Exp $ */
/*-
* Copyright (c) 2017 Internet Initiative Japan Inc.
@ -188,8 +188,8 @@ wqinput_create(const char *name, void (*func)(struct mbuf *, int, int))
panic("%s: workqueue_create failed (%d)\n", __func__, error);
pool_init(&wqi->wqi_work_pool, sizeof(struct wqinput_work), 0, 0, 0,
name, NULL, IPL_SOFTNET);
wqi->wqi_worklists = percpu_alloc(sizeof(struct wqinput_worklist *));
percpu_foreach(wqi->wqi_worklists, wqinput_percpu_init_cpu, NULL);
wqi->wqi_worklists = percpu_create(sizeof(struct wqinput_worklist *),
wqinput_percpu_init_cpu, NULL, NULL);
wqi->wqi_input = func;
wqinput_sysctl_setup(name, wqi);