From 7a847e87ec82cb7f04a777aa97ebbbd0bbd0bd1a Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Wed, 8 Nov 2017 08:36:36 +0100
Subject: [PATCH 2/2] kernel: Remove unneeded includes in sys/kern.

---
 sys/kern/kern_acct.c        |  6 ------
 sys/kern/kern_acl.c         |  6 ------
 sys/kern/kern_checkpoint.c  | 18 ------------------
 sys/kern/kern_clock.c       | 15 ---------------
 sys/kern/kern_collect.c     | 10 ----------
 sys/kern/kern_condvar.c     |  2 --
 sys/kern/kern_conf.c        |  6 ------
 sys/kern/kern_cputimer.c    |  4 ----
 sys/kern/kern_debug.c       |  1 -
 sys/kern/kern_descrip.c     |  8 --------
 sys/kern/kern_device.c      |  8 --------
 sys/kern/kern_dmsg.c        |  9 ---------
 sys/kern/kern_dsched.c      | 10 ----------
 sys/kern/kern_environment.c |  5 -----
 sys/kern/kern_event.c       | 11 -----------
 sys/kern/kern_exec.c        | 17 -----------------
 sys/kern/kern_exit.c        | 10 ----------
 sys/kern/kern_fork.c        |  8 --------
 sys/kern/kern_fp.c          | 12 ------------
 sys/kern/kern_intr.c        |  7 -------
 sys/kern/kern_iosched.c     | 10 ----------
 sys/kern/kern_jail.c        |  8 --------
 sys/kern/kern_kinfo.c       |  2 --
 sys/kern/kern_kthread.c     |  6 ------
 sys/kern/kern_ktr.c         | 11 -----------
 sys/kern/kern_ktrace.c      |  3 ---
 sys/kern/kern_linker.c      |  7 -------
 sys/kern/kern_lock.c        |  3 ---
 sys/kern/kern_lockf.c       |  6 ------
 sys/kern/kern_memio.c       |  3 ---
 sys/kern/kern_mib.c         |  2 --
 sys/kern/kern_module.c      |  3 ---
 sys/kern/kern_mpipe.c       |  5 -----
 sys/kern/kern_mutex.c       |  5 -----
 sys/kern/kern_nrandom.c     |  8 --------
 sys/kern/kern_ntptime.c     |  1 -
 sys/kern/kern_objcache.c    |  8 --------
 sys/kern/kern_p1003_1b.c    |  2 --
 sys/kern/kern_physio.c      |  3 ---
 sys/kern/kern_plimit.c      |  1 -
 sys/kern/kern_posix4_mib.c  |  3 ---
 sys/kern/kern_proc.c        | 12 ------------
 sys/kern/kern_prot.c        |  5 -----
 sys/kern/kern_refcount.c    |  3 ---
 sys/kern/kern_resource.c    |  4 ----
 sys/kern/kern_sched.c       |  2 --
 sys/kern/kern_sensors.c     |  6 ------
 sys/kern/kern_sfbuf.c       |  8 --------
 sys/kern/kern_shutdown.c    | 14 --------------
 sys/kern/kern_sig.c         | 10 ----------
 sys/kern/kern_slaballoc.c   | 12 ------------
 sys/kern/kern_spinlock.c    |  7 -------
 sys/kern/kern_subr.c        |  7 -------
 sys/kern/kern_synch.c       |  9 ---------
 sys/kern/kern_sysctl.c      |  2 --
 sys/kern/kern_sysref.c      |  3 ---
 sys/kern/kern_systimer.c    |  5 -----
 sys/kern/kern_threads.c     |  2 --
 sys/kern/kern_time.c        |  5 -----
 sys/kern/kern_timeout.c     |  4 ----
 sys/kern/kern_udev.c        |  5 -----
 sys/kern/kern_umtx.c        | 10 ----------
 sys/kern/kern_usched.c      |  4 ----
 sys/kern/kern_uuid.c        |  4 ----
 sys/kern/kern_varsym.c      |  3 ---
 sys/kern/kern_wdog.c        |  5 -----
 sys/kern/kern_xio.c         |  9 ---------
 67 files changed, 433 deletions(-)

diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c
index 982a3d2143..ba49cc6a42 100644
--- a/sys/kern/kern_acct.c
+++ b/sys/kern/kern_acct.c
@@ -42,18 +42,12 @@
 #include <sys/proc.h>
 #include <sys/priv.h>
 #include <sys/mount.h>
-#include <sys/vnode.h>
-#include <sys/fcntl.h>
 #include <sys/syslog.h>
-#include <sys/kernel.h>
-#include <sys/sysent.h>
 #include <sys/sysctl.h>
 #include <sys/nlookup.h>
 #include <sys/acct.h>
-#include <sys/resourcevar.h>
 #include <sys/tty.h>
 
-#include <vm/vm_zone.h>
 
 struct lock acct_lock = LOCK_INITIALIZER("acct_lock", 0, 0);
 
diff --git a/sys/kern/kern_acl.c b/sys/kern/kern_acl.c
index 2794b15119..3e8a07a963 100644
--- a/sys/kern/kern_acl.c
+++ b/sys/kern/kern_acl.c
@@ -36,16 +36,10 @@
 #include <sys/systm.h>
 #include <sys/sysproto.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
 #include <sys/vnode.h>
-#include <sys/lock.h>
 #include <sys/proc.h>
 #include <sys/nlookup.h>
-#include <sys/file.h>
-#include <sys/sysent.h>
-#include <sys/errno.h>
 #include <sys/stat.h>
-#include <sys/acl.h>
 
 static int vacl_set_acl(struct vnode *vp, acl_type_t type, struct acl *aclp);
 static int vacl_get_acl(struct vnode *vp, acl_type_t type, struct acl *aclp);
diff --git a/sys/kern/kern_checkpoint.c b/sys/kern/kern_checkpoint.c
index 98abd500b4..16d320a287 100644
--- a/sys/kern/kern_checkpoint.c
+++ b/sys/kern/kern_checkpoint.c
@@ -25,48 +25,30 @@
  */
 
 #include <sys/types.h>
-#include <sys/param.h>
 #include <sys/proc.h>
-#include <sys/module.h>
-#include <sys/sysent.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
 #include <sys/nlookup.h>
 
-#include <sys/file.h>
-#include <sys/fcntl.h>
-#include <sys/signal.h>
 #include <vm/vm_param.h>
 #include <vm/vm.h>
 #include <sys/imgact_elf.h>
 #include <sys/procfs.h>
 
-#include <sys/lock.h>
 #include <vm/pmap.h>
-#include <vm/vm_map.h>
 #include <vm/vm_extern.h>
 #include <sys/mman.h>
 #include <sys/sysproto.h>
-#include <sys/resource.h>
-#include <sys/resourcevar.h>
-#include <sys/malloc.h>
 #include <sys/stat.h>
-#include <sys/uio.h>
 #include <sys/namei.h>
 #include <sys/vnode.h>
 #include <machine/inttypes.h>
-#include <machine/limits.h>
-#include <machine/frame.h>
-#include <sys/signalvar.h>
 #include <sys/syslog.h>
 #include <sys/sysctl.h>
 #include <machine/sigframe.h>
 #include <sys/exec.h>
-#include <sys/unistd.h>
-#include <sys/time.h>
 #include <sys/kern_syscall.h>
 #include <sys/checkpoint.h>
-#include <sys/mount.h>
 #include <sys/ckpt.h>
 
 #include <sys/mplock2.h>
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c
index 13f668b40e..7285d72b8f 100644
--- a/sys/kern/kern_clock.c
+++ b/sys/kern/kern_clock.c
@@ -73,36 +73,21 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/callout.h>
 #include <sys/kernel.h>
 #include <sys/kinfo.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/resource.h>
-#include <sys/resourcevar.h>
-#include <sys/signalvar.h>
 #include <sys/priv.h>
 #include <sys/timex.h>
 #include <sys/timepps.h>
-#include <sys/upmap.h>
-#include <sys/lock.h>
 #include <sys/sysctl.h>
 #include <sys/kcollect.h>
 
 #include <vm/vm.h>
 #include <vm/pmap.h>
-#include <vm/vm_map.h>
 #include <vm/vm_extern.h>
 
-#include <sys/thread2.h>
 #include <sys/spinlock2.h>
 
 #include <machine/cpu.h>
-#include <machine/limits.h>
-#include <machine/smp.h>
-#include <machine/cpufunc.h>
-#include <machine/specialreg.h>
-#include <machine/clock.h>
 
 #ifdef GPROF
 #include <sys/gmon.h>
diff --git a/sys/kern/kern_collect.c b/sys/kern/kern_collect.c
index c4b42f6129..e53ee89f05 100644
--- a/sys/kern/kern_collect.c
+++ b/sys/kern/kern_collect.c
@@ -38,29 +38,19 @@
 #include <sys/kernel.h>
 #include <sys/proc.h>
 #include <sys/kinfo.h>
-#include <sys/queue.h>
 #include <sys/sysctl.h>
 #include <sys/kthread.h>
 #include <machine/cpu.h>
-#include <sys/lock.h>
-#include <sys/spinlock.h>
 #include <sys/kcollect.h>
 
-#include <sys/thread2.h>
 #include <sys/spinlock2.h>
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
 #include <vm/vm_kern.h>
-#include <vm/vm_object.h>
-#include <vm/vm_page.h>
-#include <vm/vm_map.h>
 #include <vm/vm_pager.h>
 #include <vm/vm_extern.h>
 
-#include <machine/stdarg.h>
-#include <machine/smp.h>
-#include <machine/clock.h>
 
 static uint32_t kcollect_samples = -1;	/* 0 to disable */
 TUNABLE_INT("kern.collect_samples", &kcollect_samples);
diff --git a/sys/kern/kern_condvar.c b/sys/kern/kern_condvar.c
index a01344d5b6..334f8aa456 100644
--- a/sys/kern/kern_condvar.c
+++ b/sys/kern/kern_condvar.c
@@ -1,7 +1,5 @@
 #include <sys/condvar.h>
 #include <sys/spinlock2.h>
-#include <sys/systm.h>
-#include <sys/lock.h>
 
 void
 cv_init(struct cv *c, const char *desc)
diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c
index b7acf8ea5f..170a64948f 100644
--- a/sys/kern/kern_conf.c
+++ b/sys/kern/kern_conf.c
@@ -33,17 +33,11 @@
  * $FreeBSD: src/sys/kern/kern_conf.c,v 1.73.2.3 2003/03/10 02:18:25 imp Exp $
  */
 
-#include <sys/param.h>
-#include <sys/kernel.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
-#include <sys/module.h>
 #include <sys/conf.h>
 #include <sys/vnode.h>
-#include <sys/queue.h>
-#include <sys/device.h>
 #include <sys/disk.h>
-#include <machine/stdarg.h>
 
 #include <sys/sysref2.h>
 
diff --git a/sys/kern/kern_cputimer.c b/sys/kern/kern_cputimer.c
index db65322025..7cc9ed8d6d 100644
--- a/sys/kern/kern_cputimer.c
+++ b/sys/kern/kern_cputimer.c
@@ -35,13 +35,9 @@
  * Generic cputimer - access to a reliable, free-running counter.
  */
 
-#include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
-#include <sys/thread.h>
-#include <sys/globaldata.h>
 #include <sys/serialize.h>
-#include <sys/systimer.h>
 #include <sys/sysctl.h>
 #include <sys/thread2.h>
 
diff --git a/sys/kern/kern_debug.c b/sys/kern/kern_debug.c
index 6108f3ecc4..357cdf8fd7 100644
--- a/sys/kern/kern_debug.c
+++ b/sys/kern/kern_debug.c
@@ -75,7 +75,6 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 
-#include <ddb/ddb.h>
 
 /*
  * Simple DDB stack trace funtionality.
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 402f845f75..7d8c1d499e 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -70,33 +70,25 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
 #include <sys/sysproto.h>
 #include <sys/conf.h>
 #include <sys/device.h>
 #include <sys/file.h>
 #include <sys/filedesc.h>
-#include <sys/kernel.h>
 #include <sys/sysctl.h>
 #include <sys/vnode.h>
 #include <sys/proc.h>
 #include <sys/nlookup.h>
 #include <sys/stat.h>
 #include <sys/filio.h>
-#include <sys/fcntl.h>
-#include <sys/unistd.h>
-#include <sys/resourcevar.h>
-#include <sys/event.h>
 #include <sys/kern_syscall.h>
 #include <sys/kcore.h>
 #include <sys/kinfo.h>
 #include <sys/un.h>
-#include <sys/objcache.h>
 
 #include <vm/vm.h>
 #include <vm/vm_extern.h>
 
-#include <sys/thread2.h>
 #include <sys/file2.h>
 #include <sys/spinlock2.h>
 
diff --git a/sys/kern/kern_device.c b/sys/kern/kern_device.c
index 9fd062a831..efbfb22214 100644
--- a/sys/kern/kern_device.c
+++ b/sys/kern/kern_device.c
@@ -31,22 +31,14 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/module.h>
-#include <sys/malloc.h>
 #include <sys/conf.h>
 #include <sys/bio.h>
 #include <sys/buf.h>
 #include <sys/vnode.h>
-#include <sys/queue.h>
-#include <sys/device.h>
-#include <sys/tree.h>
-#include <sys/syslink_rpc.h>
 #include <sys/proc.h>
 #include <sys/dsched.h>
 #include <sys/devfs.h>
 
-#include <machine/stdarg.h>
 
 #include <sys/thread2.h>
 #include <sys/mplock2.h>
diff --git a/sys/kern/kern_dmsg.c b/sys/kern/kern_dmsg.c
index 504caa2a57..6f2f5abb33 100644
--- a/sys/kern/kern_dmsg.c
+++ b/sys/kern/kern_dmsg.c
@@ -35,24 +35,15 @@
  * TODO: txcmd CREATE state is deferred by tx msgq, need to calculate
  *	 a streaming response.  See subr_diskiocom()'s diskiodone().
  */
-#include <sys/param.h>
-#include <sys/types.h>
 #include <sys/kernel.h>
 #include <sys/conf.h>
 #include <sys/systm.h>
-#include <sys/queue.h>
-#include <sys/tree.h>
-#include <sys/malloc.h>
 #include <sys/mount.h>
 #include <sys/socket.h>
-#include <sys/vnode.h>
 #include <sys/sysctl.h>
 #include <sys/file.h>
 #include <sys/proc.h>
 #include <sys/priv.h>
-#include <sys/thread.h>
-#include <sys/globaldata.h>
-#include <sys/limits.h>
 
 #include <sys/dmsg.h>
 
diff --git a/sys/kern/kern_dsched.c b/sys/kern/kern_dsched.c
index a672b689fe..1715f8afa7 100644
--- a/sys/kern/kern_dsched.c
+++ b/sys/kern/kern_dsched.c
@@ -35,21 +35,11 @@
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/proc.h>
-#include <sys/sysctl.h>
 #include <sys/buf.h>
 #include <sys/conf.h>
-#include <sys/diskslice.h>
 #include <sys/disk.h>
-#include <sys/malloc.h>
-#include <machine/md_var.h>
-#include <sys/ctype.h>
-#include <sys/syslog.h>
-#include <sys/device.h>
-#include <sys/msgport.h>
-#include <sys/msgport2.h>
 #include <sys/buf2.h>
 #include <sys/dsched.h>
-#include <sys/fcntl.h>
 
 /*
  * Called on disk_create()
diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c
index 00807353ea..1be129ae00 100644
--- a/sys/kern/kern_environment.c
+++ b/sys/kern/kern_environment.c
@@ -41,16 +41,11 @@
  * above.
  */
 
-#include <sys/param.h>
 #include <sys/kenv.h>
 #include <sys/kernel.h>
-#include <sys/libkern.h>
-#include <sys/malloc.h>
 #include <sys/priv.h>
-#include <sys/spinlock.h>
 #include <sys/spinlock2.h>
 #include <sys/sysproto.h>
-#include <sys/systm.h>
 #include <sys/sysctl.h>
 
 /* exported variables */
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index e776ce55ef..cec6997b28 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -30,23 +30,12 @@
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/proc.h>
-#include <sys/malloc.h> 
-#include <sys/unistd.h>
 #include <sys/file.h>
-#include <sys/lock.h>
-#include <sys/fcntl.h>
-#include <sys/queue.h>
-#include <sys/event.h>
-#include <sys/eventvar.h>
-#include <sys/protosw.h>
 #include <sys/socket.h>
 #include <sys/socketvar.h>
 #include <sys/stat.h>
 #include <sys/sysctl.h>
 #include <sys/sysproto.h>
-#include <sys/thread.h>
-#include <sys/uio.h>
-#include <sys/signalvar.h>
 #include <sys/filio.h>
 #include <sys/ktr.h>
 
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 95788db689..c7e08f0d81 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -32,38 +32,23 @@
 #include <sys/kernel.h>
 #include <sys/mount.h>
 #include <sys/filedesc.h>
-#include <sys/fcntl.h>
 #include <sys/acct.h>
 #include <sys/exec.h>
 #include <sys/imgact.h>
 #include <sys/imgact_elf.h>
 #include <sys/kern_syscall.h>
 #include <sys/wait.h>
-#include <sys/malloc.h>
 #include <sys/proc.h>
 #include <sys/priv.h>
 #include <sys/ktrace.h>
-#include <sys/signalvar.h>
 #include <sys/pioctl.h>
 #include <sys/nlookup.h>
-#include <sys/sysent.h>
 #include <sys/shm.h>
 #include <sys/sysctl.h>
-#include <sys/vnode.h>
-#include <sys/vmmeter.h>
-#include <sys/libkern.h>
 
-#include <cpu/lwbuf.h>
 
-#include <vm/vm.h>
 #include <vm/vm_param.h>
-#include <sys/lock.h>
-#include <vm/pmap.h>
-#include <vm/vm_page.h>
-#include <vm/vm_map.h>
-#include <vm/vm_kern.h>
 #include <vm/vm_extern.h>
-#include <vm/vm_object.h>
 #include <vm/vnode_pager.h>
 #include <vm/vm_pager.h>
 
@@ -71,8 +56,6 @@
 #include <sys/reg.h>
 
 #include <sys/objcache.h>
-#include <sys/refcount.h>
-#include <sys/thread2.h>
 #include <vm/vm_page2.h>
 
 MALLOC_DEFINE(M_PARGS, "proc-args", "Process arguments");
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 69703f39b2..07d7dde05f 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -41,37 +41,27 @@
 #include <sys/systm.h>
 #include <sys/sysproto.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
 #include <sys/proc.h>
 #include <sys/ktrace.h>
 #include <sys/pioctl.h>
 #include <sys/tty.h>
 #include <sys/wait.h>
 #include <sys/vnode.h>
-#include <sys/resourcevar.h>
-#include <sys/signalvar.h>
 #include <sys/taskqueue.h>
 #include <sys/ptrace.h>
 #include <sys/acct.h>		/* for acct_process() function prototype */
-#include <sys/filedesc.h>
 #include <sys/shm.h>
 #include <sys/sem.h>
 #include <sys/jail.h>
 #include <sys/kern_syscall.h>
 #include <sys/unistd.h>
-#include <sys/eventhandler.h>
 #include <sys/dsched.h>
 
 #include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <sys/lock.h>
 #include <vm/pmap.h>
-#include <vm/vm_map.h>
 #include <vm/vm_extern.h>
 #include <sys/user.h>
 
-#include <sys/refcount.h>
-#include <sys/thread2.h>
 #include <sys/spinlock2.h>
 #include <sys/mplock2.h>
 
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index ad66d2e424..f31b6679f6 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -42,10 +42,7 @@
 #include <sys/sysproto.h>
 #include <sys/filedesc.h>
 #include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/malloc.h>
 #include <sys/proc.h>
-#include <sys/resourcevar.h>
 #include <sys/vnode.h>
 #include <sys/acct.h>
 #include <sys/ktrace.h>
@@ -54,14 +51,9 @@
 #include <sys/lwp.h>
 
 #include <vm/vm.h>
-#include <sys/lock.h>
 #include <vm/pmap.h>
-#include <vm/vm_map.h>
 #include <vm/vm_extern.h>
 
-#include <sys/vmmeter.h>
-#include <sys/refcount.h>
-#include <sys/thread2.h>
 #include <sys/signal2.h>
 #include <sys/spinlock2.h>
 
diff --git a/sys/kern/kern_fp.c b/sys/kern/kern_fp.c
index 13916fbe0e..89d8885f12 100644
--- a/sys/kern/kern_fp.c
+++ b/sys/kern/kern_fp.c
@@ -42,10 +42,8 @@
  * and additional file operations (ioctl, fcntl).
  */
 
-#include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
 #include <sys/sysproto.h>
 #include <sys/conf.h>
 #include <sys/filedesc.h>
@@ -54,29 +52,19 @@
 #include <sys/proc.h>
 #include <sys/priv.h>
 #include <sys/nlookup.h>
-#include <sys/file.h>
 #include <sys/stat.h>
 #include <sys/filio.h>
-#include <sys/fcntl.h>
-#include <sys/unistd.h>
-#include <sys/resourcevar.h>
-#include <sys/event.h>
 #include <sys/mman.h>
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
-#include <sys/lock.h>
 #include <vm/pmap.h>
 #include <vm/vm_map.h>
-#include <vm/vm_object.h>
-#include <vm/vm_page.h>
 #include <vm/vm_pager.h>
 #include <vm/vm_pageout.h>
 #include <vm/vm_extern.h>
-#include <vm/vm_kern.h>
 
 #include <sys/file2.h>
-#include <machine/limits.h>
 
 typedef struct file *file_t;
 
diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c
index d49fd19fbc..bacba2ea56 100644
--- a/sys/kern/kern_intr.c
+++ b/sys/kern/kern_intr.c
@@ -29,18 +29,11 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
 #include <sys/sysctl.h>
-#include <sys/thread.h>
 #include <sys/proc.h>
 #include <sys/random.h>
-#include <sys/serialize.h>
-#include <sys/interrupt.h>
-#include <sys/bus.h>
 #include <sys/machintr.h>
 
-#include <machine/frame.h>
 
 #include <sys/thread2.h>
 #include <sys/mplock2.h>
diff --git a/sys/kern/kern_iosched.c b/sys/kern/kern_iosched.c
index 2a959dd9ad..469cba0d70 100644
--- a/sys/kern/kern_iosched.c
+++ b/sys/kern/kern_iosched.c
@@ -38,22 +38,12 @@
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/proc.h>
-#include <sys/rtprio.h>
-#include <sys/queue.h>
-#include <machine/cpu.h>
-#include <sys/spinlock.h>
-#include <sys/iosched.h>
 #include <sys/sysctl.h>
 #include <sys/buf.h>
-#include <sys/limits.h>
 
-#include <sys/thread2.h>
-#include <sys/spinlock2.h>
 
 #include <vm/vm.h>
-#include <vm/vm_param.h>
 #include <vm/vm_kern.h>
-#include <vm/vm_extern.h>
 
 SYSCTL_NODE(, OID_AUTO, iosched, CTLFLAG_RW, 0, "I/O Scheduler");
 
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
index 8afa4ba6db..a89e8c090a 100644
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -41,23 +41,15 @@
 
 #include "opt_inet6.h"
 
-#include <sys/param.h>
-#include <sys/types.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
-#include <sys/errno.h>
 #include <sys/sysproto.h>
-#include <sys/malloc.h>
 #include <sys/nlookup.h>
-#include <sys/namecache.h>
 #include <sys/proc.h>
 #include <sys/priv.h>
 #include <sys/jail.h>
-#include <sys/socket.h>
 #include <sys/sysctl.h>
 #include <sys/kern_syscall.h>
-#include <net/if.h>
-#include <netinet/in.h>
 #include <netinet6/in6_var.h>
 
 #include <sys/mplock2.h>
diff --git a/sys/kern/kern_kinfo.c b/sys/kern/kern_kinfo.c
index 48661b5823..e44cef0db3 100644
--- a/sys/kern/kern_kinfo.c
+++ b/sys/kern/kern_kinfo.c
@@ -48,9 +48,7 @@
 #include <sys/conf.h>
 #include <sys/jail.h>
 #include <sys/mplock2.h>
-#include <sys/globaldata.h>
 #ifdef _KERNEL
-#include <sys/systm.h>
 #else
 #include <string.h>
 
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c
index 71f7332cc9..f9105c7eb0 100644
--- a/sys/kern/kern_kthread.c
+++ b/sys/kern/kern_kthread.c
@@ -30,13 +30,7 @@
 #include <sys/systm.h>
 #include <sys/proc.h>
 #include <sys/kthread.h>
-#include <sys/ptrace.h>
-#include <sys/resourcevar.h>
-#include <sys/signalvar.h>
-#include <sys/unistd.h>
-#include <sys/wait.h>
 
-#include <machine/stdarg.h>
 
 static struct lwkt_token kpsus_token = LWKT_TOKEN_INITIALIZER(kpsus_token);
 
diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c
index a2698dfb43..31f1641151 100644
--- a/sys/kern/kern_ktr.c
+++ b/sys/kern/kern_ktr.c
@@ -69,28 +69,17 @@
 #include "opt_ddb.h"
 #include "opt_ktr.h"
 
-#include <sys/param.h>
 #include <sys/cons.h>
-#include <sys/kernel.h>
-#include <sys/libkern.h>
 #include <sys/proc.h>
-#include <sys/sysctl.h>
 #include <sys/ktr.h>
-#include <sys/systm.h>
-#include <sys/time.h>
-#include <sys/malloc.h>
-#include <sys/spinlock.h>
 #include <sys/kbio.h>
 #include <sys/ctype.h>
 #include <sys/limits.h>
 
-#include <sys/thread2.h>
 #include <sys/spinlock2.h>
 
 #include <machine/cpu.h>
-#include <machine/cpufunc.h>
 #include <machine/specialreg.h>
-#include <machine/md_var.h>
 
 #include <ddb/ddb.h>
 
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c
index 7f9d1bb663..eeb6a664fd 100644
--- a/sys/kern/kern_ktrace.c
+++ b/sys/kern/kern_ktrace.c
@@ -38,13 +38,10 @@
 #include <sys/kernel.h>
 #include <sys/proc.h>
 #include <sys/fcntl.h>
-#include <sys/lock.h>
 #include <sys/nlookup.h>
 #include <sys/vnode.h>
 #include <sys/ktrace.h>
-#include <sys/malloc.h>
 #include <sys/syslog.h>
-#include <sys/sysent.h>
 
 #include <vm/vm_zone.h>
 
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index 9fccfa089b..8a19a198f9 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -28,25 +28,18 @@
 
 #include "opt_ddb.h"
 
-#include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
 #include <sys/sysproto.h>
 #include <sys/sysent.h>
 #include <sys/proc.h>
 #include <sys/priv.h>
-#include <sys/lock.h>
-#include <sys/module.h>
-#include <sys/queue.h>
 #include <sys/linker.h>
 #include <sys/fcntl.h>
-#include <sys/libkern.h>
 #include <sys/nlookup.h>
 #include <sys/vnode.h>
 #include <sys/sysctl.h>
 
-#include <vm/vm_zone.h>
 
 #ifdef _KERNEL_VIRTUAL
 #include <dlfcn.h>
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index ae0ea6841e..5f14368d7c 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -44,10 +44,7 @@
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/proc.h>
-#include <sys/lock.h>
 #include <sys/sysctl.h>
-#include <sys/spinlock.h>
-#include <sys/thread2.h>
 #include <sys/spinlock2.h>
 #include <sys/indefinite2.h>
 
diff --git a/sys/kern/kern_lockf.c b/sys/kern/kern_lockf.c
index d7367dd36c..091c3e3239 100644
--- a/sys/kern/kern_lockf.c
+++ b/sys/kern/kern_lockf.c
@@ -41,17 +41,11 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/lock.h>
 #include <sys/proc.h>
-#include <sys/unistd.h>
 #include <sys/vnode.h>
-#include <sys/malloc.h>
-#include <sys/fcntl.h>
-#include <sys/resourcevar.h>
 
 #include <sys/lockf.h>
 #include <machine/limits.h>	/* for LLONG_MAX */
-#include <machine/stdarg.h>
 
 #include <sys/spinlock2.h>
 
diff --git a/sys/kern/kern_memio.c b/sys/kern/kern_memio.c
index 1cda4e38a5..0bdbd98acf 100644
--- a/sys/kern/kern_memio.c
+++ b/sys/kern/kern_memio.c
@@ -48,13 +48,10 @@
 #include <sys/fcntl.h>
 #include <sys/filio.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
 #include <sys/memrange.h>
 #include <sys/proc.h>
 #include <sys/priv.h>
 #include <sys/random.h>
-#include <sys/signalvar.h>
-#include <sys/uio.h>
 #include <sys/vnode.h>
 #include <sys/sysctl.h>
 
diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c
index a2c41d1149..d391ee5990 100644
--- a/sys/kern/kern_mib.c
+++ b/sys/kern/kern_mib.c
@@ -36,7 +36,6 @@
  * $FreeBSD: src/sys/kern/kern_mib.c,v 1.29.2.4 2001/07/30 23:28:00 peter Exp $
  */
 
-#include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
 #include <sys/sysctl.h>
@@ -44,7 +43,6 @@
 #include <sys/lockf.h>
 #include <sys/jail.h>
 #include <sys/unistd.h>
-#include <machine/smp.h>
 
 SYSCTL_NODE(, 0,	  sysctl, CTLFLAG_RW, 0,
 	"Sysctl internal magic");
diff --git a/sys/kern/kern_module.c b/sys/kern/kern_module.c
index 868b6b0af0..5ed62a401c 100644
--- a/sys/kern/kern_module.c
+++ b/sys/kern/kern_module.c
@@ -26,14 +26,11 @@
  * $FreeBSD: src/sys/kern/kern_module.c,v 1.21 1999/11/08 06:53:30 peter Exp $
  */
 
-#include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
 #include <sys/eventhandler.h>
-#include <sys/malloc.h>
 #include <sys/sysproto.h>
 #include <sys/sysent.h>
-#include <sys/module.h>
 #include <sys/linker.h>
 #include <sys/proc.h>
 
diff --git a/sys/kern/kern_mpipe.c b/sys/kern/kern_mpipe.c
index 87951973ed..f6c22176cd 100644
--- a/sys/kern/kern_mpipe.c
+++ b/sys/kern/kern_mpipe.c
@@ -37,12 +37,7 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/slaballoc.h>
 #include <sys/mbuf.h>
-#include <sys/vmmeter.h>
-#include <sys/lock.h>
-#include <sys/thread.h>
-#include <sys/globaldata.h>
 #include <sys/mpipe.h>
 #include <sys/kthread.h>
 
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 6729cff16d..637ea747c6 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -55,14 +55,9 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/kernel.h>
 #include <sys/sysctl.h>
-#include <sys/indefinite.h>
-#include <sys/thread.h>
 
-#include <machine/cpufunc.h>
 
-#include <sys/thread2.h>
 #include <sys/mutex2.h>
 #include <sys/indefinite2.h>
 
diff --git a/sys/kern/kern_nrandom.c b/sys/kern/kern_nrandom.c
index bf98c2ece4..1db368664c 100644
--- a/sys/kern/kern_nrandom.c
+++ b/sys/kern/kern_nrandom.c
@@ -130,23 +130,15 @@
  * file.
  */
 
-#include <sys/types.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
 #include <sys/poll.h>
 #include <sys/event.h>
 #include <sys/random.h>
-#include <sys/systimer.h>
-#include <sys/time.h>
 #include <sys/proc.h>
-#include <sys/lock.h>
 #include <sys/sysctl.h>
-#include <sys/spinlock.h>
 #include <sys/csprng.h>
-#include <machine/atomic.h>
-#include <machine/clock.h>
 
-#include <sys/thread2.h>
 #include <sys/spinlock2.h>
 
 struct csprng_state csprng_state;
diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c
index b4cdf99a88..2e85df92c3 100644
--- a/sys/kern/kern_ntptime.c
+++ b/sys/kern/kern_ntptime.c
@@ -39,7 +39,6 @@
 #include <sys/kernel.h>
 #include <sys/proc.h>
 #include <sys/priv.h>
-#include <sys/time.h>
 #include <sys/timex.h>
 #include <sys/timepps.h>
 #include <sys/sysctl.h>
diff --git a/sys/kern/kern_objcache.c b/sys/kern/kern_objcache.c
index 3d7d5d15f4..ca29dd9c2c 100644
--- a/sys/kern/kern_objcache.c
+++ b/sys/kern/kern_objcache.c
@@ -30,17 +30,9 @@
  * SUCH DAMAGE.
  */
 
-#include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
-#include <sys/callout.h>
-#include <sys/globaldata.h>
-#include <sys/malloc.h>
-#include <sys/queue.h>
 #include <sys/objcache.h>
-#include <sys/spinlock.h>
-#include <sys/thread.h>
-#include <sys/thread2.h>
 #include <sys/spinlock2.h>
 
 static MALLOC_DEFINE(M_OBJCACHE, "objcache", "Object Cache");
diff --git a/sys/kern/kern_p1003_1b.c b/sys/kern/kern_p1003_1b.c
index d3313a7b04..3792ac1feb 100644
--- a/sys/kern/kern_p1003_1b.c
+++ b/sys/kern/kern_p1003_1b.c
@@ -41,8 +41,6 @@
 #include <sys/sysent.h>
 #include <sys/posix4.h>
 #include <sys/proc.h>
-#include <sys/syslog.h>
-#include <sys/module.h>
 #include <sys/sysproto.h>
 #include <sys/sysctl.h>
 #include <sys/unistd.h>
diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c
index ff52b7e874..af373aa22f 100644
--- a/sys/kern/kern_physio.c
+++ b/sys/kern/kern_physio.c
@@ -22,9 +22,6 @@
 #include <sys/buf.h>
 #include <sys/conf.h>
 #include <sys/proc.h>
-#include <sys/uio.h>
-#include <sys/device.h>
-#include <sys/thread2.h>
 
 #include <vm/vm.h>
 #include <vm/vm_extern.h>
diff --git a/sys/kern/kern_plimit.c b/sys/kern/kern_plimit.c
index c429ef2c35..ee69096f8a 100644
--- a/sys/kern/kern_plimit.c
+++ b/sys/kern/kern_plimit.c
@@ -78,7 +78,6 @@
 #include <vm/vm.h>
 #include <vm/vm_map.h>
 
-#include <machine/pmap.h>
 
 #include <sys/spinlock2.h>
 
diff --git a/sys/kern/kern_posix4_mib.c b/sys/kern/kern_posix4_mib.c
index 9254d66abf..0fd5375d46 100644
--- a/sys/kern/kern_posix4_mib.c
+++ b/sys/kern/kern_posix4_mib.c
@@ -33,9 +33,6 @@
  * $DragonFly: src/sys/kern/kern_posix4_mib.c,v 1.4 2007/06/26 19:31:08 dillon Exp $
  */
 
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/queue.h>
 #include <sys/sysctl.h>
 #include <sys/posix4.h>
 
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index e7c0b4b274..4ecd591f3f 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -29,28 +29,16 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/kernel.h>
 #include <sys/sysctl.h>
-#include <sys/malloc.h>
 #include <sys/proc.h>
 #include <sys/vnode.h>
 #include <sys/jail.h>
-#include <sys/filedesc.h>
 #include <sys/tty.h>
 #include <sys/dsched.h>
-#include <sys/signalvar.h>
-#include <sys/spinlock.h>
 #include <sys/random.h>
-#include <sys/vnode.h>
 #include <sys/exec.h>
-#include <vm/vm.h>
-#include <sys/lock.h>
-#include <vm/pmap.h>
-#include <vm/vm_map.h>
 #include <sys/user.h>
-#include <machine/smp.h>
 
-#include <sys/refcount.h>
 #include <sys/spinlock2.h>
 
 /*
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
index a3e9ac4b0b..dd6fe77fba 100644
--- a/sys/kern/kern_prot.c
+++ b/sys/kern/kern_prot.c
@@ -44,17 +44,12 @@
 #include <sys/systm.h>
 #include <sys/sysproto.h>
 #include <sys/kernel.h>
-#include <sys/lock.h>
 #include <sys/proc.h>
 #include <sys/priv.h>
-#include <sys/malloc.h>
 #include <sys/pioctl.h>
-#include <sys/resourcevar.h>
 #include <sys/jail.h>
 #include <sys/lockf.h>
-#include <sys/spinlock.h>
 
-#include <sys/thread2.h>
 #include <sys/spinlock2.h>
 
 static MALLOC_DEFINE(M_CRED, "cred", "credentials");
diff --git a/sys/kern/kern_refcount.c b/sys/kern/kern_refcount.c
index aad1a7ee98..59fcfc9b3b 100644
--- a/sys/kern/kern_refcount.c
+++ b/sys/kern/kern_refcount.c
@@ -41,12 +41,9 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/kernel.h>
 #include <sys/sysctl.h>
-#include <sys/thread.h>
 #include <sys/refcount.h>
 
-#include <machine/cpufunc.h>
 
 #include <sys/thread2.h>
 
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index ee678184cd..5a4d78eab9 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -42,19 +42,15 @@
 #include <sys/kern_syscall.h>
 #include <sys/kernel.h>
 #include <sys/resourcevar.h>
-#include <sys/malloc.h>
 #include <sys/proc.h>
 #include <sys/priv.h>
-#include <sys/time.h>
 #include <sys/lockf.h>
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
-#include <sys/lock.h>
 #include <vm/pmap.h>
 #include <vm/vm_map.h>
 
-#include <sys/thread2.h>
 #include <sys/spinlock2.h>
 
 static int donice (struct proc *chgp, int n);
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c
index 4b423c1f2a..a684c5f60c 100644
--- a/sys/kern/kern_sched.c
+++ b/sys/kern/kern_sched.c
@@ -40,8 +40,6 @@
 #include <sys/systm.h>
 #include <sys/posix4.h>
 #include <sys/proc.h>
-#include <sys/kernel.h>
-#include <sys/resource.h>
 #include <machine/cpu.h>	/* For need_user_resched */
 
 
diff --git a/sys/kern/kern_sensors.c b/sys/kern/kern_sensors.c
index 86a1108712..524e9358d8 100644
--- a/sys/kern/kern_sensors.c
+++ b/sys/kern/kern_sensors.c
@@ -22,14 +22,8 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
 #include <sys/kthread.h>
-#include <sys/queue.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/spinlock.h>
 #include <sys/spinlock2.h>
-#include <sys/lock.h>
 #include <sys/cpu_topology.h>
 
 #include <sys/sysctl.h>
diff --git a/sys/kern/kern_sfbuf.c b/sys/kern/kern_sfbuf.c
index 0111022ddb..7f3ec8eb77 100644
--- a/sys/kern/kern_sfbuf.c
+++ b/sys/kern/kern_sfbuf.c
@@ -24,21 +24,13 @@
  */
 
 #include <sys/param.h>
-#include <sys/types.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
 #include <sys/sfbuf.h>
-#include <sys/refcount.h>
 #include <sys/objcache.h>
 
-#include <cpu/lwbuf.h>
 
-#include <vm/vm.h>
 #include <vm/vm_extern.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_page.h>
-#include <vm/pmap.h>
 
 static void sf_buf_init(void *arg);
 SYSINIT(sock_sf, SI_BOOT2_MACHDEP, SI_ORDER_ANY, sf_buf_init, NULL);
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index df663bf2cf..7bc24f92ca 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -46,7 +46,6 @@
 #include <sys/eventhandler.h>
 #include <sys/buf.h>
 #include <sys/disk.h>
-#include <sys/diskslice.h>
 #include <sys/reboot.h>
 #include <sys/proc.h>
 #include <sys/priv.h>
@@ -56,33 +55,21 @@
 #include <sys/kernel.h>
 #include <sys/kerneldump.h>
 #include <sys/kthread.h>
-#include <sys/malloc.h>
 #include <sys/mount.h>
-#include <sys/queue.h>
 #include <sys/sysctl.h>
 #include <sys/vkernel.h>
-#include <sys/conf.h>
 #include <sys/sysproto.h>
-#include <sys/device.h>
 #include <sys/cons.h>
 #include <sys/kbio.h>
 #include <sys/shm.h>
 #include <sys/kern_syscall.h>
 #include <vm/vm_map.h>
-#include <vm/pmap.h>
 
-#include <sys/thread2.h>
 #include <sys/buf2.h>
 #include <sys/mplock2.h>
 
 #include <machine/cpu.h>
-#include <machine/clock.h>
-#include <machine/md_var.h>
-#include <machine/smp.h>		/* smp_active_mask, cpuid */
-#include <machine/vmparam.h>
-#include <machine/thread.h>
 
-#include <sys/signalvar.h>
 
 #include <sys/wdog.h>
 #include <dev/acpica/acpi_pvpanic/panic_notifier.h>
@@ -97,7 +84,6 @@
  * ANSI and traditional C compilers.  We use the machine version to stay
  * within the confines of the kernel header files.
  */
-#include <machine/stdarg.h>
 
 #ifdef DDB
 #include <ddb/ddb.h>
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 77eb662436..69dc31337d 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -42,33 +42,23 @@
 #include <sys/kernel.h>
 #include <sys/sysproto.h>
 #include <sys/signalvar.h>
-#include <sys/resourcevar.h>
 #include <sys/vnode.h>
-#include <sys/event.h>
-#include <sys/proc.h>
 #include <sys/nlookup.h>
 #include <sys/pioctl.h>
 #include <sys/acct.h>
-#include <sys/fcntl.h>
-#include <sys/lock.h>
 #include <sys/wait.h>
 #include <sys/ktrace.h>
 #include <sys/syslog.h>
 #include <sys/stat.h>
-#include <sys/sysent.h>
 #include <sys/sysctl.h>
-#include <sys/malloc.h>
 #include <sys/interrupt.h>
-#include <sys/unistd.h>
 #include <sys/kern_syscall.h>
 #include <sys/vkernel.h>
 
 #include <sys/signal2.h>
-#include <sys/thread2.h>
 #include <sys/spinlock2.h>
 
 #include <machine/cpu.h>
-#include <machine/smp.h>
 
 static int	coredump(struct lwp *, int);
 static char	*expand_name(const char *, uid_t, pid_t);
diff --git a/sys/kern/kern_slaballoc.c b/sys/kern/kern_slaballoc.c
index 62fee7a51d..e8b736cfc6 100644
--- a/sys/kern/kern_slaballoc.c
+++ b/sys/kern/kern_slaballoc.c
@@ -100,28 +100,16 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/slaballoc.h>
 #include <sys/mbuf.h>
-#include <sys/vmmeter.h>
-#include <sys/lock.h>
-#include <sys/thread.h>
-#include <sys/globaldata.h>
-#include <sys/sysctl.h>
 #include <sys/ktr.h>
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
-#include <vm/vm_kern.h>
 #include <vm/vm_extern.h>
-#include <vm/vm_object.h>
-#include <vm/pmap.h>
-#include <vm/vm_map.h>
-#include <vm/vm_page.h>
 #include <vm/vm_pageout.h>
 
 #include <machine/cpu.h>
 
-#include <sys/thread2.h>
 #include <vm/vm_page2.h>
 
 #define btokup(z)	(&pmap_kvtom((vm_offset_t)(z))->ku_pagecnt)
diff --git a/sys/kern/kern_spinlock.c b/sys/kern/kern_spinlock.c
index 1875467fa6..8148bcaaa9 100644
--- a/sys/kern/kern_spinlock.c
+++ b/sys/kern/kern_spinlock.c
@@ -50,20 +50,13 @@
  */
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/types.h>
-#include <sys/kernel.h>
 #include <sys/sysctl.h>
 #ifdef INVARIANTS
 #include <sys/proc.h>
 #endif
 #include <sys/priv.h>
-#include <machine/atomic.h>
 #include <machine/cpu.h>
-#include <machine/cpufunc.h>
-#include <machine/specialreg.h>
-#include <machine/clock.h>
 #include <sys/indefinite2.h>
-#include <sys/spinlock.h>
 #include <sys/spinlock2.h>
 #include <sys/ktr.h>
 
diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c
index cb793a58ea..76577f731d 100644
--- a/sys/kern/kern_subr.c
+++ b/sys/kern/kern_subr.c
@@ -39,19 +39,12 @@
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/lock.h>
-#include <sys/resourcevar.h>
 #include <sys/sysctl.h>
 #include <sys/uio.h>
 #include <sys/vnode.h>
-#include <sys/thread2.h>
-#include <machine/limits.h>
 
 #include <cpu/lwbuf.h>
 
-#include <vm/vm.h>
-#include <vm/vm_page.h>
 #include <vm/vm_map.h>
 
 SYSCTL_INT(_kern, KERN_IOV_MAX, iov_max, CTLFLAG_RD, NULL, UIO_MAXIOV,
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index 5540be179f..ef93ef9a6a 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -40,14 +40,7 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/proc.h>
-#include <sys/kernel.h>
-#include <sys/signalvar.h>
-#include <sys/resourcevar.h>
-#include <sys/vmmeter.h>
-#include <sys/sysctl.h>
 #include <sys/priv.h>
-#include <sys/lock.h>
-#include <sys/uio.h>
 #include <sys/kcollect.h>
 #ifdef KTRACE
 #include <sys/ktrace.h>
@@ -56,12 +49,10 @@
 #include <sys/serialize.h>
 
 #include <sys/signal2.h>
-#include <sys/thread2.h>
 #include <sys/spinlock2.h>
 #include <sys/mutex2.h>
 
 #include <machine/cpu.h>
-#include <machine/smp.h>
 
 #include <vm/vm_extern.h>
 
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 1606d5c279..d6f003a313 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -41,11 +41,9 @@
 #include <sys/kernel.h>
 #include <sys/buf.h>
 #include <sys/sysctl.h>
-#include <sys/malloc.h>
 #include <sys/proc.h>
 #include <sys/priv.h>
 #include <sys/sysproto.h>
-#include <sys/lock.h>
 #include <sys/sbuf.h>
 
 #include <vm/vm.h>
diff --git a/sys/kern/kern_sysref.c b/sys/kern/kern_sysref.c
index 3b9e54e9a2..e7e762ab66 100644
--- a/sys/kern/kern_sysref.c
+++ b/sys/kern/kern_sysref.c
@@ -49,9 +49,6 @@
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/tree.h>
-#include <sys/spinlock.h>
-#include <machine/atomic.h>
-#include <machine/cpufunc.h>
 
 #include <sys/spinlock2.h>
 #include <sys/sysref2.h>
diff --git a/sys/kern/kern_systimer.c b/sys/kern/kern_systimer.c
index c1656160f4..96efb739f5 100644
--- a/sys/kern/kern_systimer.c
+++ b/sys/kern/kern_systimer.c
@@ -50,12 +50,7 @@
  * cputimer_intr_reload()	Reload the one-shot (per-cpu basis)
  */
 
-#include <sys/param.h>
 #include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/thread.h>
-#include <sys/globaldata.h>
-#include <sys/systimer.h>
 #include <sys/thread2.h>
 
 /*
diff --git a/sys/kern/kern_threads.c b/sys/kern/kern_threads.c
index c098a76970..79080939ae 100644
--- a/sys/kern/kern_threads.c
+++ b/sys/kern/kern_threads.c
@@ -48,9 +48,7 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/kernel.h>
 #include <sys/proc.h>
-#include <sys/resourcevar.h>
 #include <sys/sysproto.h>
 
 #if 0
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 887d41bf10..84709f1c4d 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -36,12 +36,8 @@
 #include <sys/sysproto.h>
 #include <sys/resourcevar.h>
 #include <sys/signalvar.h>
-#include <sys/kernel.h>
-#include <sys/sysent.h>
 #include <sys/sysunion.h>
-#include <sys/proc.h>
 #include <sys/priv.h>
-#include <sys/time.h>
 #include <sys/vnode.h>
 #include <sys/sysctl.h>
 #include <sys/kern_syscall.h>
@@ -50,7 +46,6 @@
 
 #include <sys/msgport2.h>
 #include <sys/spinlock2.h>
-#include <sys/thread2.h>
 
 extern struct spinlock ntp_spin;
 
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c
index e7eeadfa50..50ff617557 100644
--- a/sys/kern/kern_timeout.c
+++ b/sys/kern/kern_timeout.c
@@ -81,12 +81,8 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/callout.h>
-#include <sys/kernel.h>
 #include <sys/interrupt.h>
-#include <sys/thread.h>
 
-#include <sys/thread2.h>
 #include <sys/mplock2.h>
 
 #include <vm/vm_extern.h>
diff --git a/sys/kern/kern_udev.c b/sys/kern/kern_udev.c
index afa706db44..597c0d12dd 100644
--- a/sys/kern/kern_udev.c
+++ b/sys/kern/kern_udev.c
@@ -37,15 +37,10 @@
 #include <sys/proc.h>
 #include <sys/buf.h>
 #include <sys/conf.h>
-#include <sys/event.h>
 #include <sys/vnode.h>
-#include <sys/malloc.h>
-#include <sys/objcache.h>
-#include <sys/ctype.h>
 #include <sys/syslog.h>
 #include <sys/udev.h>
 #include <sys/devfs.h>
-#include <libprop/proplib.h>
 
 #include <sys/thread2.h>
 
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index 47dee537fe..ffa895f0dc 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -41,30 +41,20 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/cdefs.h>
 #include <sys/kernel.h>
 #include <sys/sysproto.h>
 #include <sys/sysunion.h>
 #include <sys/sysent.h>
-#include <sys/syscall.h>
 #include <sys/sysctl.h>
-#include <sys/module.h>
-#include <sys/thread.h>
 #include <sys/proc.h>
 
 #include <cpu/lwbuf.h>
 
-#include <vm/vm.h>
 #include <vm/vm_param.h>
-#include <sys/lock.h>
-#include <vm/pmap.h>
 #include <vm/vm_map.h>
-#include <vm/vm_object.h>
-#include <vm/vm_page.h>
 #include <vm/vm_pager.h>
 #include <vm/vm_pageout.h>
 #include <vm/vm_extern.h>
-#include <vm/vm_kern.h>
 
 #include <vm/vm_page2.h>
 
diff --git a/sys/kern/kern_usched.c b/sys/kern/kern_usched.c
index 7abbd8c6b9..feae0bae2c 100644
--- a/sys/kern/kern_usched.c
+++ b/sys/kern/kern_usched.c
@@ -33,16 +33,12 @@
  * 
  */
 
-#include <sys/errno.h>
 #include <sys/globaldata.h>		/* curthread */
 #include <sys/proc.h>
 #include <sys/priv.h>
 #include <sys/sysproto.h>		/* struct usched_set_args */
 #include <sys/systm.h>			/* strcmp() */
-#include <sys/usched.h>	
 
-#include <machine/cpumask.h>
-#include <machine/smp.h>
 
 static TAILQ_HEAD(, usched) usched_list = TAILQ_HEAD_INITIALIZER(usched_list);
 
diff --git a/sys/kern/kern_uuid.c b/sys/kern/kern_uuid.c
index 1cc1b011fa..dd0eae487a 100644
--- a/sys/kern/kern_uuid.c
+++ b/sys/kern/kern_uuid.c
@@ -27,17 +27,13 @@
  * $DragonFly: src/sys/kern/kern_uuid.c,v 1.4 2007/06/19 06:07:57 dillon Exp $
  */
 
-#include <sys/param.h>
 #include <sys/endian.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/lock.h>
 #include <sys/kern_syscall.h>
 #include <sys/random.h>
 #include <sys/sbuf.h>
-#include <sys/socket.h>
 #include <sys/sysproto.h>
-#include <sys/uuid.h>
 #include <sys/gpt.h>
 #include <net/if_var.h>
 
diff --git a/sys/kern/kern_varsym.c b/sys/kern/kern_varsym.c
index 953dccf031..5692514d58 100644
--- a/sys/kern/kern_varsym.c
+++ b/sys/kern/kern_varsym.c
@@ -45,10 +45,7 @@
 #include <sys/proc.h>
 #include <sys/priv.h>
 #include <sys/jail.h>
-#include <sys/queue.h>
 #include <sys/sysctl.h>
-#include <sys/malloc.h>
-#include <sys/varsym.h>
 #include <sys/sysproto.h>
 
 MALLOC_DEFINE(M_VARSYM, "varsym", "variable sets for variant symlinks");
diff --git a/sys/kern/kern_wdog.c b/sys/kern/kern_wdog.c
index ef3f4c605c..335cad5997 100644
--- a/sys/kern/kern_wdog.c
+++ b/sys/kern/kern_wdog.c
@@ -32,19 +32,14 @@
  * SUCH DAMAGE.
  */
 
-#include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
 #include <sys/sysproto.h>
 #include <sys/spinlock2.h>
 #include <sys/conf.h>
 #include <sys/device.h>
 #include <sys/filedesc.h>
 #include <sys/sysctl.h>
-#include <sys/unistd.h>
-#include <sys/event.h>
-#include <sys/queue.h>
 #include <sys/wdog.h>
 #include <machine/limits.h>
 
diff --git a/sys/kern/kern_xio.c b/sys/kern/kern_xio.c
index 9749ed2c73..84b90a5b4b 100644
--- a/sys/kern/kern_xio.c
+++ b/sys/kern/kern_xio.c
@@ -49,22 +49,13 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
 #include <sys/proc.h>
-#include <sys/vmmeter.h>
 #include <sys/vnode.h>
-#include <sys/xio.h>
 
 #include <cpu/lwbuf.h>
 
-#include <vm/vm.h>
 #include <vm/vm_param.h>
-#include <sys/lock.h>
 #include <vm/vm_kern.h>
-#include <vm/pmap.h>
-#include <vm/vm_map.h>
-#include <vm/vm_object.h>
-#include <vm/vm_page.h>
 #include <vm/vm_pageout.h>
 #include <vm/vm_pager.h>
 #include <vm/vm_extern.h>
-- 
2.14.1

