Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Switch sys/net to percpu_create.



details:   https://anonhg.NetBSD.org/src/rev/fc6a7d6d5146
branches:  trunk
changeset: 744430:fc6a7d6d5146
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Feb 01 12:54:50 2020 +0000

description:
Switch sys/net to percpu_create.

diffstat:

 sys/net/if.c          |  24 ++++++++++--------------
 sys/net/if_l2tp.c     |   9 ++++-----
 sys/net/route.c       |  11 ++++-------
 sys/netinet/wqinput.c |   6 +++---
 4 files changed, 21 insertions(+), 29 deletions(-)

diffs (146 lines):

diff -r d8fd3daa70a1 -r fc6a7d6d5146 sys/net/if.c
--- a/sys/net/if.c      Sat Feb 01 12:54:30 2020 +0000
+++ b/sys/net/if.c      Sat Feb 01 12:54:50 2020 +0000
@@ -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 @@
        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 @@
        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));
 }
 
diff -r d8fd3daa70a1 -r fc6a7d6d5146 sys/net/if_l2tp.c
--- a/sys/net/if_l2tp.c Sat Feb 01 12:54:30 2020 +0000
+++ b/sys/net/if_l2tp.c Sat Feb 01 12:54:50 2020 +0000
@@ -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 @@
 
        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 @@
        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);
diff -r d8fd3daa70a1 -r fc6a7d6d5146 sys/net/route.c
--- a/sys/net/route.c   Sat Feb 01 12:54:30 2020 +0000
+++ b/sys/net/route.c   Sat Feb 01 12:54:50 2020 +0000
@@ -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 @@
 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 *
diff -r d8fd3daa70a1 -r fc6a7d6d5146 sys/netinet/wqinput.c
--- a/sys/netinet/wqinput.c     Sat Feb 01 12:54:30 2020 +0000
+++ b/sys/netinet/wqinput.c     Sat Feb 01 12:54:50 2020 +0000
@@ -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 @@
                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);



Home | Main Index | Thread Index | Old Index