Skip to contentSkip to conversation

kernel/entry: Remove unneeded header "common.h"

PATCH In review Khalid Ali 2 participants 4 messages Jun 11, 2025 – Jun 16, 2025 Generic entry code

lore
Share & tools
lore

Khalid Ali

author
#0 lore raw

PATCH 1/1 kernel/entry: Remove unneeded header "common.h"

syscall_user_dispatch() is part syscall user dispatch and it has a header already, so this patch moves that function to include/linux/syscall_user_dispatch.h which fits well. In that case we don't need common.h anymore. All functions related to syscall
user dispatch are on that header i mentioned, so this one shouldn't be special. We need to access the function from that header.

---
 include/linux/syscall_user_dispatch.h | 2 ++
 kernel/entry/common.c                 | 3 +--
 kernel/entry/common.h                 | 7 -------
 kernel/entry/syscall_user_dispatch.c  | 2 --
 4 files changed, 3 insertions(+), 11 deletions(-)
 delete mode 100644 kernel/entry/common.h
include/linux/syscall_user_dispatch.h +2 -0
index 3858a6ffdd5c..6fffca47b136 100644
@@ -48,4 +48,6 @@ static inline int syscall_user_dispatch_set_config(struct task_struct *task,
 
 #endif /* CONFIG_GENERIC_ENTRY */
 
+bool syscall_user_dispatch(struct pt_regs *regs);
+
 #endif /* _SYSCALL_USER_DISPATCH_H */
kernel/entry/common.c +1 -2
index a8dd1f27417c..e774dc9e7eaf 100644
@@ -9,8 +9,7 @@
 #include <linux/livepatch.h>
 #include <linux/audit.h>
 #include <linux/tick.h>
-
-#include "common.h"
+#include <linux/syscall_user_dispatch.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/syscalls.h>
kernel/entry/common.h deleted +0 -7
deleted file mode 100644
index f6e6d02f07fe..000000000000
@@ -1,7 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _COMMON_H
-#define _COMMON_H
-
-bool syscall_user_dispatch(struct pt_regs *regs);
-
-#endif
kernel/entry/syscall_user_dispatch.c +0 -2
index 5340c5aa89e7..b88a4b546d70 100644
@@ -15,8 +15,6 @@
 
 #include <asm/syscall.h>
 
-#include "common.h"
-
 static void trigger_sigsys(struct pt_regs *regs)
 {
 	struct kernel_siginfo info;
Signature · 1 line
2.49.0
#1 lore raw
Quoted 6 lines · Khalid Ali

syscall_user_dispatch() is part syscall user dispatch and it has a header already, so this patch moves that function to include/linux/syscall_user_dispatch.h which fits well. In that case we don't need common.h anymore. All functions related to syscall
user dispatch are on that header i mentioned, so this one shouldn't be special. We need to access the function from that header.

This word salad does not qualify as a change log. Please read

https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#changelog

including the documentation it links to.

The reason why common.h exists is that syscall_user_dispatch() is a internal function, which is on purpose not exposed globally. There is no reason to expose it globally, so it stays where it is.

Thanks,

tglx

author
#2 lore raw
Quoted 5 lines

The reason why common.h exists is that syscall_user_dispatch() is a internal function, which is on purpose not exposed globally. There is no reason to expose it globally, so it stays where it is.
Still there is no strong reason "common.h" could exist, there is no doc explicitly mentions that.

Why can't we just put the prototype into the source since currently it is the only place used is common.c, so we should put it on top of the source. Again don't see strong reason why entire header exist for single function, even on future if more local definations come we should put on top of the source, if there is one single source file using it. This makes consistent across the entire kernel codebase which mostly do what i mentioned.

The only exception for local headers is if the source file using it is too large and using many structures, enums and prototypes, in that case it is acceptable. However the decision of creation of that local header with no exception makes the header pointless.

I didn't find any kernel doc that describes the decision, so we should make it consistent with other subsystems if there is no specific reason for that this makes the source file more organized.

#3 lore raw
Quoted 8 lines · Khalid Ali
Quoted 5 lines

The reason why common.h exists is that syscall_user_dispatch() is a internal function, which is on purpose not exposed globally. There is no reason to expose it globally, so it stays where it is.
Still there is no strong reason "common.h" could exist, there is no doc explicitly mentions that.

Why can't we just put the prototype into the source since currently it is the only place used is common.c, so we should put it on top of the source. Again don't

No. You need the prototype (aka. declaration) for both the usage site _and_ the definition.

Do I really have to explain the basic C rules?

Quoted 9 lines

see strong reason why entire header exist for single function, even on future if more local definations come we should put on top of the source, if there is one single source file using it. This makes consistent across the entire kernel codebase which mostly do what i mentioned.

The only exception for local headers is if the source file using it is too large and using many structures, enums and prototypes, in that case it is acceptable.

So you define what's acceptable and not?

Quoted 6 lines

However the decision of creation of that local header with no exception makes the header pointless.

I didn't find any kernel doc that describes the decision, so we should make it consistent with other subsystems if there is no specific reason for that this makes the source file more organized.

I explained it to you already why this header exists and there is a strong emphasis in some subsystems to not expose functions globaly so that the internals of the subsystem are encapsulated. That's the only way you can do that in C and it makes a lot of sense.

This _is_ consistent with the rest of the code and you can argue until you're blue, this header with the declaration of that function stays.

Thanks,

tglx