diff --git a/lnet/libcfs/debug.c b/lnet/libcfs/debug.c
index 58ef681a18c89a8397cf4ac2394e6719869957c1..a69d967e5fce32ddd17b695634f0296be62fb7a2 100644
--- a/lnet/libcfs/debug.c
+++ b/lnet/libcfs/debug.c
@@ -26,6 +26,7 @@
 
 # define DEBUG_SUBSYSTEM S_LNET
 
+#include <stdarg.h>
 #include <libcfs/kp30.h>
 #include <libcfs/libcfs.h>
 #include "tracefile.h"
@@ -470,10 +471,6 @@ EXPORT_SYMBOL(libcfs_debug_set_level);
 
 #include <libcfs/libcfs.h>
 
-#ifdef HAVE_SYS_USER_H
-# include <sys/user.h>
-#endif
-
 #ifdef HAVE_CATAMOUNT_DATA_H
 #include <catamount/data.h>
 #include <catamount/lputs.h>
diff --git a/lnet/selftest/brw_test.c b/lnet/selftest/brw_test.c
index 78bed3ce3300e8b5c1f2acb4c4b1d3dd8619daf7..8b0dd01d77f3fde587043edc99074cb7f14ee8b2 100644
--- a/lnet/selftest/brw_test.c
+++ b/lnet/selftest/brw_test.c
@@ -6,7 +6,6 @@
  *
  */
 
-#include <libcfs/kp30.h>
 #include "selftest.h"
 
 
diff --git a/lnet/selftest/framework.c b/lnet/selftest/framework.c
index fc6eaaa622a88a5f51bad666d6f41ca101e82805..3fde9713cfcff1cb6b1a5931318c631e8a93f951 100644
--- a/lnet/selftest/framework.c
+++ b/lnet/selftest/framework.c
@@ -8,13 +8,8 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
-#include <libcfs/kp30.h>
-#include <libcfs/libcfs.h>
-#include <lnet/lib-lnet.h>
-
 #include "selftest.h"
 
-
 int brw_inject_errors = 0;
 CFS_MODULE_PARM(brw_inject_errors, "i", int, 0644,
                 "# data errors to inject randomly, zero by default");
diff --git a/lnet/selftest/ping_test.c b/lnet/selftest/ping_test.c
index 6f0334b4b410de018bec67461de9aab369744566..39a67c7742a86915a50c6ea28882ff1513db33c9 100644
--- a/lnet/selftest/ping_test.c
+++ b/lnet/selftest/ping_test.c
@@ -7,7 +7,7 @@
  *
  * Test client & Server
  */
-#include <libcfs/kp30.h>
+
 #include "selftest.h"
 
 #define LST_PING_TEST_MAGIC     0xbabeface
diff --git a/lnet/selftest/rpc.c b/lnet/selftest/rpc.c
index 057a081da63583d2fe8065370689f09aea8e3383..baf8935940523b1bc4bfdb0f7c240743eeb75828 100644
--- a/lnet/selftest/rpc.c
+++ b/lnet/selftest/rpc.c
@@ -8,10 +8,6 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
-#include <libcfs/kp30.h>
-#include <libcfs/libcfs.h>
-#include <lnet/lib-lnet.h>
-
 #include "selftest.h"
 
 
diff --git a/lnet/selftest/selftest.h b/lnet/selftest/selftest.h
index 63179ff1cd30233e9d71841de626f9fbc4c2ec04..f27106ed5dd5dbb26123743dfa3f495e3a4f1df6 100644
--- a/lnet/selftest/selftest.h
+++ b/lnet/selftest/selftest.h
@@ -10,16 +10,17 @@
 
 #define LNET_ONLY
 
+#ifndef __KERNEL__
+#include <liblustre.h> /* userland spinlock_t and atomic_t */
+#endif
+
 #include <libcfs/kp30.h>
 #include <libcfs/libcfs.h>
 #include <lnet/lnet.h>
+#include <lnet/lib-lnet.h>
 #include <lnet/lib-types.h>
 #include <lnet/lnetst.h>
 
-#ifndef __KERNEL__
-#include <liblustre.h> /* userland spinlock_t and atomic_t */
-#endif
-
 #include "rpc.h"
 #include "timer.h"
 
diff --git a/lnet/selftest/timer.c b/lnet/selftest/timer.c
index 388cd8a9eb91f194c2c11fc705b68d156e404e0c..eb72a789da2005367f977bc5c1acec8f79b8feff 100644
--- a/lnet/selftest/timer.c
+++ b/lnet/selftest/timer.c
@@ -8,10 +8,6 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
-#include <libcfs/kp30.h>
-#include <libcfs/libcfs.h>
-#include <lnet/lib-lnet.h>
-
 #include "selftest.h"
 
 
diff --git a/lnet/selftest/workitem.c b/lnet/selftest/workitem.c
index 0ed83509790c48ada29ec73505083e01da9d6823..19b0a79be1961fbfff77d641ab253f878293a57a 100644
--- a/lnet/selftest/workitem.c
+++ b/lnet/selftest/workitem.c
@@ -7,9 +7,6 @@
  */
 #define DEBUG_SUBSYSTEM S_LNET
 
-#include <libcfs/kp30.h>
-#include <libcfs/libcfs.h>
-#include <lnet/lib-lnet.h>
 #include "selftest.h"
 
 
diff --git a/lustre/liblustre/llite_lib.c b/lustre/liblustre/llite_lib.c
index 1667b5d17e856207e90e0307e83196c9969b6fa6..e6d04e6576e868b1a9ca8a79b7fb24fc53f8e23e 100644
--- a/lustre/liblustre/llite_lib.c
+++ b/lustre/liblustre/llite_lib.c
@@ -44,6 +44,7 @@
  * of 'LIST_HEAD'. undef it to suppress warnings
  */
 #undef LIST_HEAD
+#include <liblustre.h>
 #include <lnet/lnetctl.h>     /* needed for parse_dump */
 
 #include "lutil.h"
diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c
index d2b4a0b2a745fb15663b71e2ee633a74bc7c9826..1386608417e450aa5857107d3c3cc0730bb604fa 100644
--- a/lustre/utils/liblustreapi.c
+++ b/lustre/utils/liblustreapi.c
@@ -49,9 +49,8 @@
 #include <unistd.h>
 #endif
 
-#include <lnet/lnetctl.h>
-
 #include <liblustre.h>
+#include <lnet/lnetctl.h>
 #include <obd.h>
 #include <lustre_lib.h>
 #include <obd_lov.h>