Skip to contentSkip to conversation

io_uring: Trim out unused includes

PATCH Applied Gabriel Krisman Bertazi 4 participants 6 messages Jan 5 – Jan 12 io_uring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 io_uring: Trim out unused includes

Clean up some left overs of refactoring io_uring into multiple files. Compile tested with a few configurations.

---
 io_uring/alloc_cache.h |  1 +
 io_uring/cancel.c      |  2 --
 io_uring/filetable.h   |  1 -
 io_uring/io_uring.c    | 12 ------------
 io_uring/io_uring.h    |  1 -
 5 files changed, 1 insertion(+), 16 deletions(-)
io_uring/alloc_cache.h +1 -0
index d33ce159ef33..bb2f21a7bfd6 100644
@@ -2,6 +2,7 @@
 #define IOU_ALLOC_CACHE_H
 
 #include <linux/io_uring_types.h>
+#include <linux/kasan.h>
 
 /*
  * Don't allow the cache to grow beyond this size.
io_uring/cancel.c +0 -2
index ca12ac10c0ae..38452ab06098 100644
@@ -2,10 +2,8 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
-#include <linux/file.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
-#include <linux/namei.h>
 #include <linux/nospec.h>
 #include <linux/io_uring.h>
 
io_uring/filetable.h +0 -1
index 7717ea9efd0e..c348233a3411 100644
@@ -2,7 +2,6 @@
 #ifndef IOU_FILE_TABLE_H
 #define IOU_FILE_TABLE_H
 
-#include <linux/file.h>
 #include <linux/io_uring_types.h>
 #include "rsrc.h"
 
io_uring/io_uring.c +0 -12
index 6cb24cdf8e68..0d812042e38f 100644
@@ -40,37 +40,25 @@
  * Copyright (c) 2018-2019 Christoph Hellwig
  */
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/syscalls.h>
-#include <net/compat.h>
 #include <linux/refcount.h>
-#include <linux/uio.h>
 #include <linux/bits.h>
 
 #include <linux/sched/signal.h>
 #include <linux/fs.h>
-#include <linux/file.h>
 #include <linux/mm.h>
-#include <linux/mman.h>
 #include <linux/percpu.h>
 #include <linux/slab.h>
-#include <linux/bvec.h>
-#include <linux/net.h>
-#include <net/sock.h>
 #include <linux/anon_inodes.h>
-#include <linux/sched/mm.h>
 #include <linux/uaccess.h>
 #include <linux/nospec.h>
-#include <linux/fsnotify.h>
-#include <linux/fadvise.h>
 #include <linux/task_work.h>
 #include <linux/io_uring.h>
 #include <linux/io_uring/cmd.h>
 #include <linux/audit.h>
 #include <linux/security.h>
 #include <linux/jump_label.h>
-#include <asm/shmparam.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/io_uring.h>
io_uring/io_uring.h +0 -1
index a790c16854d3..c5bbb43b5842 100644
@@ -4,7 +4,6 @@
 #include <linux/errno.h>
 #include <linux/lockdep.h>
 #include <linux/resume_user_mode.h>
-#include <linux/kasan.h>
 #include <linux/poll.h>
 #include <linux/io_uring_types.h>
 #include <uapi/linux/eventpoll.h>
Signature · 1 line
2.52.0
maintainer Applied
#1 lore raw
Quoted 4 lines · Gabriel Krisman Bertazi

Clean up some left overs of refactoring io_uring into multiple files. Compile tested with a few configurations.

Applied, thanks!

[1/1] io_uring: Trim out unused includes

      commit: 48ed70131e4f3057f819c848d92fe84ba696e2a9

Best regards,

Signature · 1 line
Jens Axboe
#2 lore raw
In reply to Gabriel Krisman Bertazi

Hello Gabriel,

Quoted 2 lines · Gabriel Krisman Bertazi

Clean up some left overs of refactoring io_uring into multiple files. Compile tested with a few configurations.

Do you have a tool to detect those unused header? I am curious how is the process to discover unused headers in .c files.

Thanks
--breno

#3 lore raw
Quoted 2 lines · Breno Leitao

Do you have a tool to detect those unused header? I am curious how is the process to discover unused headers in .c files.

No. I noticed one that was obviously wrong and that caused me to manually walk over the rest that looked suspicious. I probably missed some in the process.

I suppose LLMs, if you can stomach those, would help :)

Signature · 1 line
Gabriel Krisman Bertazi
#4 lore raw
Quoted 8 lines · Gabriel Krisman Bertazi
Quoted 2 lines · Breno Leitao

Do you have a tool to detect those unused header? I am curious how is the process to discover unused headers in .c files.

No. I noticed one that was obviously wrong and that caused me to manually walk over the rest that looked suspicious. I probably missed some in the process.

That is fair, I do the same for my code as well.

Thanks
--breno

#5 lore raw

There is a tool "Include What You Use"
(https://github.com/include-what-you-use/include-what-you-use) that can be used to automate removing unused includes, among other things. I've used it in other codebases, though never tried it on Linux.

Best,
Caleb

Quoted 16 lines · Breno Leitao
Quoted 8 lines · Gabriel Krisman Bertazi
Quoted 2 lines · Breno Leitao

Do you have a tool to detect those unused header? I am curious how is the process to discover unused headers in .c files.

No. I noticed one that was obviously wrong and that caused me to manually walk over the rest that looked suspicious. I probably missed some in the process.

That is fair, I do the same for my code as well.

Thanks
--breno