git: 497240def87c - main - Retire clone_drain_lock

From: Mateusz Guzik <mjg_at_FreeBSD.org>
Date: Sat, 20 Aug 2022 09:45:10 UTC
The branch main has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=497240def87cf93a6420ff4dd5396ae9ae569dfb

commit 497240def87cf93a6420ff4dd5396ae9ae569dfb
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2022-08-19 21:20:51 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2022-08-20 09:44:05 +0000

    Retire clone_drain_lock
    
    It is only ever xlocked in drain_dev_clone_events and the only consumer of
    that routine does not need it -- eventhandler code already makes sure the
    relevant callback is no longer running.
    
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D36268
---
 sys/fs/devfs/devfs_int.h   | 1 -
 sys/fs/devfs/devfs_vnops.c | 4 ----
 sys/kern/kern_conf.c       | 8 --------
 sys/kern/tty_tty.c         | 2 --
 sys/net/if_tuntap.c        | 1 -
 sys/sys/conf.h             | 1 -
 6 files changed, 17 deletions(-)

diff --git a/sys/fs/devfs/devfs_int.h b/sys/fs/devfs/devfs_int.h
index e5afa311cbfd..ddd3c82bac3a 100644
--- a/sys/fs/devfs/devfs_int.h
+++ b/sys/fs/devfs/devfs_int.h
@@ -91,7 +91,6 @@ int	devfs_pathpath(const char *, const char *);
 extern struct unrhdr *devfs_inos;
 extern struct mtx devmtx;
 extern struct mtx devfs_de_interlock;
-extern struct sx clone_drain_lock;
 extern struct mtx cdevpriv_mtx;
 extern TAILQ_HEAD(cdev_priv_list, cdev_priv) cdevp_list;
 
diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c
index 7b571a6821b7..13619d318cfc 100644
--- a/sys/fs/devfs/devfs_vnops.c
+++ b/sys/fs/devfs/devfs_vnops.c
@@ -85,8 +85,6 @@ static MALLOC_DEFINE(M_CDEVPDATA, "DEVFSP", "Metainfo for cdev-fp data");
 
 struct mtx	devfs_de_interlock;
 MTX_SYSINIT(devfs_de_interlock, &devfs_de_interlock, "devfs interlock", MTX_DEF);
-struct sx	clone_drain_lock;
-SX_SYSINIT(clone_drain_lock, &clone_drain_lock, "clone events drain lock");
 struct mtx	cdevpriv_mtx;
 MTX_SYSINIT(cdevpriv_mtx, &cdevpriv_mtx, "cdevpriv lock", MTX_DEF);
 
@@ -1102,10 +1100,8 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlock)
 		cdev = NULL;
 		DEVFS_DMP_HOLD(dmp);
 		sx_xunlock(&dmp->dm_lock);
-		sx_slock(&clone_drain_lock);
 		EVENTHANDLER_INVOKE(dev_clone,
 		    td->td_ucred, pname, strlen(pname), &cdev);
-		sx_sunlock(&clone_drain_lock);
 
 		if (cdev == NULL)
 			sx_xlock(&dmp->dm_lock);
diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c
index 1cd5bc2635c1..374aafc91005 100644
--- a/sys/kern/kern_conf.c
+++ b/sys/kern/kern_conf.c
@@ -1523,14 +1523,6 @@ destroy_dev_drain(struct cdevsw *csw)
 	dev_unlock();
 }
 
-void
-drain_dev_clone_events(void)
-{
-
-	sx_xlock(&clone_drain_lock);
-	sx_xunlock(&clone_drain_lock);
-}
-
 #include "opt_ddb.h"
 #ifdef DDB
 #include <sys/kernel.h>
diff --git a/sys/kern/tty_tty.c b/sys/kern/tty_tty.c
index c10dac907498..8490a4421f5f 100644
--- a/sys/kern/tty_tty.c
+++ b/sys/kern/tty_tty.c
@@ -68,9 +68,7 @@ ctty_clone(void *arg, struct ucred *cred, char *name, int namelen,
 	if (strcmp(name, "tty"))
 		return;
 	p = curproc;
-	sx_sunlock(&clone_drain_lock);
 	sx_slock(&proctree_lock);
-	sx_slock(&clone_drain_lock);
 	dev_lock();
 	if (!(p->p_flag & P_CONTROLT))
 		*dev = ctty;
diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c
index bd9fc811d19f..5e1e60933caa 100644
--- a/sys/net/if_tuntap.c
+++ b/sys/net/if_tuntap.c
@@ -707,7 +707,6 @@ tun_uninit(const void *unused __unused)
 
 	EVENTHANDLER_DEREGISTER(ifnet_arrival_event, arrival_tag);
 	EVENTHANDLER_DEREGISTER(dev_clone, clone_tag);
-	drain_dev_clone_events();
 
 	mtx_lock(&tunmtx);
 	while ((tp = TAILQ_FIRST(&tunhead)) != NULL) {
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index 9f60dcaf62fa..ad6ffc31dc2a 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -279,7 +279,6 @@ void	destroy_dev(struct cdev *_dev);
 int	destroy_dev_sched(struct cdev *dev);
 int	destroy_dev_sched_cb(struct cdev *dev, void (*cb)(void *), void *arg);
 void	destroy_dev_drain(struct cdevsw *csw);
-void	drain_dev_clone_events(void);
 struct cdevsw *dev_refthread(struct cdev *_dev, int *_ref);
 struct cdevsw *devvn_refthread(struct vnode *vp, struct cdev **devp, int *_ref);
 void	dev_relthread(struct cdev *_dev, int _ref);