Skip to content

Commit b5adb63

Browse files
svens-s390Avenger-285714
authored andcommitted
entry: Move syscall_enter_from_user_mode() to header file
mainline inclusion from mainline-v6.8-rc1 category: performance To allow inlining of syscall_enter_from_user_mode(), move it to entry-common.h. Signed-off-by: Sven Schnelle <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected] (cherry picked from commit 221a164) Signed-off-by: Wentao Guan <[email protected]>
1 parent 9799609 commit b5adb63

File tree

2 files changed

+26
-33
lines changed

2 files changed

+26
-33
lines changed

include/linux/entry-common.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ static __always_inline void enter_from_user_mode(struct pt_regs *regs)
134134
*/
135135
void syscall_enter_from_user_mode_prepare(struct pt_regs *regs);
136136

137+
long syscall_trace_enter(struct pt_regs *regs, long syscall,
138+
unsigned long work);
139+
137140
/**
138141
* syscall_enter_from_user_mode_work - Check and handle work before invoking
139142
* a syscall
@@ -157,7 +160,15 @@ void syscall_enter_from_user_mode_prepare(struct pt_regs *regs);
157160
* ptrace_report_syscall_entry(), __secure_computing(), trace_sys_enter()
158161
* 2) Invocation of audit_syscall_entry()
159162
*/
160-
long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall);
163+
static __always_inline long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall)
164+
{
165+
unsigned long work = READ_ONCE(current_thread_info()->syscall_work);
166+
167+
if (work & SYSCALL_WORK_ENTER)
168+
syscall = syscall_trace_enter(regs, syscall, work);
169+
170+
return syscall;
171+
}
161172

162173
/**
163174
* syscall_enter_from_user_mode - Establish state and check and handle work
@@ -176,7 +187,19 @@ long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall);
176187
* Returns: The original or a modified syscall number. See
177188
* syscall_enter_from_user_mode_work() for further explanation.
178189
*/
179-
long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall);
190+
static __always_inline long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
191+
{
192+
long ret;
193+
194+
enter_from_user_mode(regs);
195+
196+
instrumentation_begin();
197+
local_irq_enable();
198+
ret = syscall_enter_from_user_mode_work(regs, syscall);
199+
instrumentation_end();
200+
201+
return ret;
202+
}
180203

181204
/**
182205
* local_irq_enable_exit_to_user - Exit to user variant of local_irq_enable()

kernel/entry/common.c

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static inline void syscall_enter_audit(struct pt_regs *regs, long syscall)
2525
}
2626
}
2727

28-
static long syscall_trace_enter(struct pt_regs *regs, long syscall,
28+
long syscall_trace_enter(struct pt_regs *regs, long syscall,
2929
unsigned long work)
3030
{
3131
long ret = 0;
@@ -71,36 +71,6 @@ static long syscall_trace_enter(struct pt_regs *regs, long syscall,
7171
return ret ? : syscall;
7272
}
7373

74-
static __always_inline long
75-
__syscall_enter_from_user_work(struct pt_regs *regs, long syscall)
76-
{
77-
unsigned long work = READ_ONCE(current_thread_info()->syscall_work);
78-
79-
if (work & SYSCALL_WORK_ENTER)
80-
syscall = syscall_trace_enter(regs, syscall, work);
81-
82-
return syscall;
83-
}
84-
85-
long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall)
86-
{
87-
return __syscall_enter_from_user_work(regs, syscall);
88-
}
89-
90-
noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
91-
{
92-
long ret;
93-
94-
enter_from_user_mode(regs);
95-
96-
instrumentation_begin();
97-
local_irq_enable();
98-
ret = __syscall_enter_from_user_work(regs, syscall);
99-
instrumentation_end();
100-
101-
return ret;
102-
}
103-
10474
noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
10575
{
10676
enter_from_user_mode(regs);

0 commit comments

Comments
 (0)