Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Add inline functions to manipulate the klists that l...
details: https://anonhg.NetBSD.org/src/rev/f7d64b7a6ed8
branches: trunk
changeset: 361152:f7d64b7a6ed8
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Feb 12 15:51:28 2022 +0000
description:
Add inline functions to manipulate the klists that link up knotes
via kn_selnext:
- klist_init()
- klist_fini()
- klist_insert()
- klist_remove()
These provide some API insulation from the implementation details of these
lists (but not completely; see vn_knote_attach() and vn_knote_detach()).
Currently just a wrapper around SLIST(9).
This will make it significantly easier to switch kn_selnext linkage
to a different kind of list.
diffstat:
sys/arch/arm/xscale/pxa2x0_apm.c | 7 ++++---
sys/arch/mips/ralink/ralink_gpio.c | 10 +++++-----
sys/dev/pci/xmm7360.c | 8 ++------
sys/external/bsd/drm2/linux/linux_sync_file.c | 8 ++++----
sys/kern/kern_event.c | 10 +++++-----
sys/kern/kern_proc.c | 16 +++++++++++++---
sys/kern/kern_sig.c | 8 ++++----
sys/kern/sys_select.c | 12 +++++++-----
sys/kern/vfs_init.c | 10 ++++++----
sys/kern/vfs_syscalls.c | 19 +++++++++++++------
sys/kern/vfs_vnode.c | 8 ++++++--
sys/sys/event.h | 27 ++++++++++++++++++++++++++-
sys/sys/mount.h | 3 ++-
13 files changed, 97 insertions(+), 49 deletions(-)
diffs (truncated from 512 to 300 lines):
diff -r dc429101ddb7 -r f7d64b7a6ed8 sys/arch/arm/xscale/pxa2x0_apm.c
--- a/sys/arch/arm/xscale/pxa2x0_apm.c Sat Feb 12 15:50:14 2022 +0000
+++ b/sys/arch/arm/xscale/pxa2x0_apm.c Sat Feb 12 15:51:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pxa2x0_apm.c,v 1.7 2021/09/26 16:36:18 thorpej Exp $ */
+/* $NetBSD: pxa2x0_apm.c,v 1.8 2022/02/12 15:51:28 thorpej Exp $ */
/* $OpenBSD: pxa2x0_apm.c,v 1.28 2007/03/29 18:42:38 uwe Exp $ */
/*-
@@ -601,7 +601,7 @@
struct pxa2x0_apm_softc *sc =
(struct pxa2x0_apm_softc *)kn->kn_hook;
- SLIST_REMOVE(&sc->sc_note, kn, knote, kn_selnext);
+ klist_remove(&sc->sc_note, kn);
}
int
@@ -633,7 +633,7 @@
}
kn->kn_hook = (caddr_t)sc;
- SLIST_INSERT_HEAD(&sc->sc_note, kn, kn_selnext);
+ klist_insert(&sc->sc_note, kn);
return (0);
}
@@ -651,6 +651,7 @@
}
lockinit(&sc->sc_lock, PWAIT, "apmlk", 0, 0);
+ klist_init(&sc->sc_note);
kthread_create_deferred(apm_thread_create, sc);
diff -r dc429101ddb7 -r f7d64b7a6ed8 sys/arch/mips/ralink/ralink_gpio.c
--- a/sys/arch/mips/ralink/ralink_gpio.c Sat Feb 12 15:50:14 2022 +0000
+++ b/sys/arch/mips/ralink/ralink_gpio.c Sat Feb 12 15:51:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ralink_gpio.c,v 1.13 2021/09/26 01:16:07 thorpej Exp $ */
+/* $NetBSD: ralink_gpio.c,v 1.14 2022/02/12 15:51:29 thorpej Exp $ */
/*-
* Copyright (c) 2011 CradlePoint Technology, Inc.
* All rights reserved.
@@ -29,7 +29,7 @@
/* ra_gpio.c -- Ralink 3052 gpio driver */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ralink_gpio.c,v 1.13 2021/09/26 01:16:07 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ralink_gpio.c,v 1.14 2022/02/12 15:51:29 thorpej Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -660,7 +660,7 @@
goto fail_3;
}
- SLIST_INIT(&knotes);
+ klist_init(&knotes);
if (kfilter_register("CP_GPIO_EVENT", &app_fops, &app_filter_id) != 0) {
RALINK_DEBUG(RALINK_DEBUG_ERROR,
"%s: kfilter_register for CP_GPIO_EVENT failed\n",
@@ -1514,7 +1514,7 @@
}
kn->kn_flags |= EV_CLEAR; /* automatically set */
- SLIST_INSERT_HEAD(&knotes, kn, kn_selnext);
+ klist_insert(&knotes, kn);
return 0;
}
@@ -1530,7 +1530,7 @@
RALINK_DEBUG(RALINK_DEBUG_ERROR, "Null kn found\n");
return;
}
- SLIST_REMOVE(&knotes, kn, knote, kn_selnext);
+ klist_remove(&knotes, kn);
}
/*
diff -r dc429101ddb7 -r f7d64b7a6ed8 sys/dev/pci/xmm7360.c
--- a/sys/dev/pci/xmm7360.c Sat Feb 12 15:50:14 2022 +0000
+++ b/sys/dev/pci/xmm7360.c Sat Feb 12 15:51:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xmm7360.c,v 1.14 2022/02/12 03:24:36 riastradh Exp $ */
+/* $NetBSD: xmm7360.c,v 1.15 2022/02/12 15:51:29 thorpej Exp $ */
/*
* Device driver for Intel XMM7360 LTE modems, eg. Fibocom L850-GL.
@@ -75,7 +75,7 @@
#include "opt_gateway.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.14 2022/02/12 03:24:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.15 2022/02/12 15:51:29 thorpej Exp $");
#endif
#include <sys/param.h>
@@ -258,10 +258,6 @@
#define if_hardmtu if_mtu
#define IF_OUTPUT_CONST const
#define si_note sel_klist
-#define klist_insert(klist, kn) \
- SLIST_INSERT_HEAD(klist, kn, kn_selnext)
-#define klist_remove(klist, kn) \
- SLIST_REMOVE(klist, kn, knote, kn_selnext)
#define XMM_KQ_ISFD_INITIALIZER .f_flags = FILTEROP_ISFD
#define tty_lock() mutex_spin_enter(&tty_lock)
#define tty_unlock() mutex_spin_exit(&tty_lock)
diff -r dc429101ddb7 -r f7d64b7a6ed8 sys/external/bsd/drm2/linux/linux_sync_file.c
--- a/sys/external/bsd/drm2/linux/linux_sync_file.c Sat Feb 12 15:50:14 2022 +0000
+++ b/sys/external/bsd/drm2/linux/linux_sync_file.c Sat Feb 12 15:51:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_sync_file.c,v 1.1 2021/12/19 10:45:50 riastradh Exp $ */
+/* $NetBSD: linux_sync_file.c,v 1.2 2022/02/12 15:51:29 thorpej Exp $ */
/*-
* Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_sync_file.c,v 1.1 2021/12/19 10:45:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_sync_file.c,v 1.2 2022/02/12 15:51:29 thorpej Exp $");
#include <sys/event.h>
#include <sys/fcntl.h>
@@ -136,7 +136,7 @@
kn->kn_fop = &sync_file_filtops;
kn->kn_hook = sf;
mutex_enter(&sf->sf_lock);
- SLIST_INSERT_HEAD(&sf->sf_selq.sel_klist, kn, kn_selnext);
+ klist_insert(&sf->sf_selq.sel_klist, kn);
mutex_exit(&sf->sf_lock);
return 0;
default:
@@ -150,7 +150,7 @@
struct sync_file *sf = kn->kn_hook;
mutex_enter(&sf->sf_lock);
- SLIST_REMOVE(&sf->sf_selq.sel_klist, kn, knote, kn_selnext);
+ klist_remove(&sf->sf_selq.sel_klist, kn);
mutex_exit(&sf->sf_lock);
}
diff -r dc429101ddb7 -r f7d64b7a6ed8 sys/kern/kern_event.c
--- a/sys/kern/kern_event.c Sat Feb 12 15:50:14 2022 +0000
+++ b/sys/kern/kern_event.c Sat Feb 12 15:51:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_event.c,v 1.139 2022/01/01 10:54:21 msaitoh Exp $ */
+/* $NetBSD: kern_event.c,v 1.140 2022/02/12 15:51:29 thorpej Exp $ */
/*-
* Copyright (c) 2008, 2009, 2021 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
#endif /* _KERNEL_OPT */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.139 2022/01/01 10:54:21 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.140 2022/02/12 15:51:29 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -790,7 +790,7 @@
*/
kn->kn_sfflags &= ~NOTE_CHILD;
- SLIST_INSERT_HEAD(&p->p_klist, kn, kn_selnext);
+ klist_insert(&p->p_klist, kn);
mutex_exit(p->p_lock);
return 0;
@@ -828,7 +828,7 @@
goto again;
}
kn->kn_status |= KN_DETACHED;
- SLIST_REMOVE(&p->p_klist, kn, knote, kn_selnext);
+ klist_remove(&p->p_klist, kn);
mutex_exit(p->p_lock);
}
mutex_spin_exit(&kq->kq_lock);
@@ -1019,7 +1019,7 @@
error = EACCES;
goto out;
}
- SLIST_INSERT_HEAD(&p2->p_klist, kntrack, kn_selnext);
+ klist_insert(&p2->p_klist, kntrack);
mutex_exit(p2->p_lock);
KASSERT(fdp->fd_knhashmask != 0);
diff -r dc429101ddb7 -r f7d64b7a6ed8 sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c Sat Feb 12 15:50:14 2022 +0000
+++ b/sys/kern/kern_proc.c Sat Feb 12 15:51:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_proc.c,v 1.262 2020/12/24 12:14:50 nia Exp $ */
+/* $NetBSD: kern_proc.c,v 1.263 2022/02/12 15:51:29 thorpej Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.262 2020/12/24 12:14:50 nia Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.263 2022/02/12 15:51:29 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_kstack.h"
@@ -354,7 +354,17 @@
static int
proc_ctor(void *arg __unused, void *obj, int flags __unused)
{
- memset(obj, 0, sizeof(struct proc));
+ struct proc *p = obj;
+
+ memset(p, 0, sizeof(*p));
+ klist_init(&p->p_klist);
+
+ /*
+ * There is no need for a proc_dtor() to do a klist_fini(),
+ * since knote_proc_exit() ensures that p->p_klist is empty
+ * when a process exits.
+ */
+
return 0;
}
diff -r dc429101ddb7 -r f7d64b7a6ed8 sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c Sat Feb 12 15:50:14 2022 +0000
+++ b/sys/kern/kern_sig.c Sat Feb 12 15:51:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sig.c,v 1.400 2021/10/27 04:45:42 thorpej Exp $ */
+/* $NetBSD: kern_sig.c,v 1.401 2022/02/12 15:51:29 thorpej Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.400 2021/10/27 04:45:42 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.401 2022/02/12 15:51:29 thorpej Exp $");
#include "opt_execfmt.h"
#include "opt_ptrace.h"
@@ -2660,7 +2660,7 @@
kn->kn_flags |= EV_CLEAR; /* automatically set */
mutex_enter(p->p_lock);
- SLIST_INSERT_HEAD(&p->p_klist, kn, kn_selnext);
+ klist_insert(&p->p_klist, kn);
mutex_exit(p->p_lock);
return 0;
@@ -2672,7 +2672,7 @@
struct proc *p = kn->kn_obj;
mutex_enter(p->p_lock);
- SLIST_REMOVE(&p->p_klist, kn, knote, kn_selnext);
+ klist_remove(&p->p_klist, kn);
mutex_exit(p->p_lock);
}
diff -r dc429101ddb7 -r f7d64b7a6ed8 sys/kern/sys_select.c
--- a/sys/kern/sys_select.c Sat Feb 12 15:50:14 2022 +0000
+++ b/sys/kern/sys_select.c Sat Feb 12 15:51:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_select.c,v 1.57 2021/12/10 20:36:04 andvar Exp $ */
+/* $NetBSD: sys_select.c,v 1.58 2022/02/12 15:51:29 thorpej Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009, 2010, 2019, 2020 The NetBSD Foundation, Inc.
@@ -84,7 +84,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.57 2021/12/10 20:36:04 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.58 2022/02/12 15:51:29 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -675,7 +675,7 @@
void
selrecord_knote(struct selinfo *sip, struct knote *kn)
{
- SLIST_INSERT_HEAD(&sip->sel_klist, kn, kn_selnext);
+ klist_insert(&sip->sel_klist, kn);
}
/*
@@ -689,8 +689,7 @@
bool
selremove_knote(struct selinfo *sip, struct knote *kn)
{
- SLIST_REMOVE(&sip->sel_klist, kn, knote, kn_selnext);
- return SLIST_EMPTY(&sip->sel_klist);
+ return klist_remove(&sip->sel_klist, kn);
}
/*
Home |
Main Index |
Thread Index |
Old Index