Re: devctl (alike?) for devfs




Kostik, John, Warner,

thank you for your guidance and suggestions.
I am currently testing the patch attached and I am using a kernel with WITNESS and INVARIANTS enabled.
Scope of my testing is plugging/unplugging of UMASS devices.
I get CREATE notifications all right.
I do not get any panics/complaints from the kernel, good.
Unfortunately I do not get any DESTROY notifications either.

Could you please look through the patch? Is there any control flow path that I missed or something even more obvious?
I hope that we do not have any cdev leaks.

I am testing the patch with RELENG_7 as of May 6.

--
Andriy Gapon
diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c
index 1db25f8..0245253 100644
--- a/sys/kern/kern_conf.c
+++ b/sys/kern/kern_conf.c
@@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
+#include <sys/bus.h>
#include <sys/bio.h>
#include <sys/lock.h>
#include <sys/mutex.h>
@@ -99,6 +100,9 @@ dev_unlock_and_free(void)
mtx_unlock(&devmtx);

while ((cdp = TAILQ_FIRST(&cdp_free)) != NULL) {
+ if (!cold)
+ devctl_notify("DEVFS", cdp->cdp_c.si_name, "DESTROY", NULL);
+
TAILQ_REMOVE(&cdp_free, cdp, cdp_list);
devfs_free(&cdp->cdp_c);
}
@@ -172,8 +176,12 @@ dev_rel(struct cdev *dev)
flag = 1;
}
dev_unlock();
- if (flag)
+ if (flag) {
+ if (!cold)
+ devctl_notify("DEVFS", dev->si_name, "DESTROY", NULL);
+
devfs_free(dev);
+ }
}

struct cdevsw *
@@ -706,6 +714,10 @@ make_dev_credv(int flags, struct cdevsw *devsw, int minornr,
devfs_create(dev);
clean_unrhdrl(devfs_inos);
dev_unlock_and_free();
+
+ if (!cold)
+ devctl_notify("DEVFS", dev->si_name, "CREATE", NULL);
+
return (dev);
}

@@ -794,6 +806,10 @@ make_dev_alias(struct cdev *pdev, const char *fmt, ...)
clean_unrhdrl(devfs_inos);
dev_unlock();
dev_depends(pdev, dev);
+
+ if (!cold)
+ devctl_notify("DEVFS", dev->si_name, "CREATE", NULL);
+
return (dev);
}

_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"

Relevant Pages

  • Re: RT patch acceptance
    ... judge the complexity of a design for that type of system. ... claim that you cannot judge the complexity of a kernel modification. ... Since the patch in question doesn't actually need that information to ... nanokernel's API up to date with additions to Linux's API that RT people ...
    (Linux-Kernel)
  • Re: inline asm semantics: output constraint width smaller than input
    ... Now in this case the patch you suggest might end up hurting the end result ... The below patch is to build the kernel for x86_64, ... # Device Drivers ... # PCI IDE chipsets support ...
    (Linux-Kernel)
  • [RFC] Making percpu module variables have their own memory.
    ... Someone using the -rt patch found that one of the tracing options caused ... 64K for every CPU to cover all the per_cpu variables used in the kernel ... static void wakeup_softirqd_prio ...
    (Linux-Kernel)
  • Re: This is [Re:] How to improve the quality of the kernel[?].
    ... The -mm kernel already implements what your proposed PTS would do. ... If patch have no TS ID, ... Thus i can apply for example lguest patches and implement and test new ... How many open source projects use Bugzilla and how many use the Debian BTS? ...
    (Linux-Kernel)
  • Re: Documentation - how to apply patches for various trees
    ... >> explanation of the various kernel trees and how to apply their patches. ... +a patch to the kernel or, more specifically, what base kernel a patch for ... +and what new version the patch will change the source tree into. ...
    (Linux-Kernel)