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
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.
Signed-off-by: Khalid Ali <khaliidcaliy@gmail.com>
---
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
diff --git a/include/linux/syscall_user_dispatch.h b/include/linux/syscall_user_dispatch.h
index 3858a6ffdd5c..6fffca47b136 100644
--- a/include/linux/syscall_user_dispatch.h
+++ b/include/linux/syscall_user_dispatch.h
@@ -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 */
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index a8dd1f27417c..e774dc9e7eaf 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -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>
diff --git a/kernel/entry/common.h b/kernel/entry/common.h
deleted file mode 100644
index f6e6d02f07fe..000000000000
--- a/kernel/entry/common.h
+++ /dev/null
@@ -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
diff --git a/kernel/entry/syscall_user_dispatch.c b/kernel/entry/syscall_user_dispatch.c
index 5340c5aa89e7..b88a4b546d70 100644
--- a/kernel/entry/syscall_user_dispatch.c
+++ b/kernel/entry/syscall_user_dispatch.c
@@ -15,8 +15,6 @@
#include <asm/syscall.h>
-#include "common.h"
-
static void trigger_sigsys(struct pt_regs *regs)
{
struct kernel_siginfo info;
--
2.49.0
On Wed, Jun 11 2025 at 07:23, Khalid Ali wrote: > 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
> 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.
On Sat, Jun 14 2025 at 19:47, Khalid Ali wrote: >> 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? > 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? > 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
© 2016 - 2025 Red Hat, Inc.