Skip to content

Commit 612e7a4

Browse files
committed
Merge tag 'kernel-clone-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux
Pull kernel_clone() updates from Christian Brauner: "During the v5.9 merge window we reworked the process creation codepaths across multiple architectures. After this work we were only left with the _do_fork() helper based on the struct kernel_clone_args calling convention. As was pointed out _do_fork() isn't valid kernelese especially for a helper that isn't just static. This series removes the _do_fork() helper and introduces the new kernel_clone() helper. The process creation cleanup didn't change the name to something more reasonable mainly because _do_fork() was used in quite a few places. So sending this as a separate series seemed the better strategy. I originally intended to send this early in the v5.9 development cycle after the merge window had closed but given that this was touching quite a few places I decided to defer this until the v5.10 merge window" * tag 'kernel-clone-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux: sched: remove _do_fork() tracing: switch to kernel_clone() kgdbts: switch to kernel_clone() kprobes: switch to kernel_clone() x86: switch to kernel_clone() sparc: switch to kernel_clone() nios2: switch to kernel_clone() m68k: switch to kernel_clone() ia64: switch to kernel_clone() h8300: switch to kernel_clone() fork: introduce kernel_clone()
2 parents 9e51183 + 06fe456 commit 612e7a4

File tree

28 files changed

+88
-88
lines changed

28 files changed

+88
-88
lines changed

Documentation/trace/histogram.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ Extended error information
14951495
#
14961496

14971497
{ stacktrace:
1498-
_do_fork+0x18e/0x330
1498+
kernel_clone+0x18e/0x330
14991499
kernel_thread+0x29/0x30
15001500
kthreadd+0x154/0x1b0
15011501
ret_from_fork+0x3f/0x70
@@ -1588,7 +1588,7 @@ Extended error information
15881588
SYSC_sendto+0xef/0x170
15891589
} hitcount: 88
15901590
{ stacktrace:
1591-
_do_fork+0x18e/0x330
1591+
kernel_clone+0x18e/0x330
15921592
SyS_clone+0x19/0x20
15931593
entry_SYSCALL_64_fastpath+0x12/0x6a
15941594
} hitcount: 244

arch/h8300/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,5 @@ asmlinkage int sys_clone(unsigned long __user *args)
172172
kargs.exit_signal = (lower_32_bits(clone_flags) & CSIGNAL);
173173
kargs.stack = newsp;
174174

175-
return _do_fork(&kargs);
175+
return kernel_clone(&kargs);
176176
}

arch/ia64/kernel/process.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ ia64_load_extra (struct task_struct *task)
271271
*
272272
* <clone syscall> <some kernel call frames>
273273
* sys_clone :
274-
* _do_fork _do_fork
274+
* kernel_clone kernel_clone
275275
* copy_thread copy_thread
276276
*
277277
* This means that the stack layout is as follows:
@@ -411,7 +411,7 @@ asmlinkage long ia64_clone(unsigned long clone_flags, unsigned long stack_start,
411411
.tls = tls,
412412
};
413413

414-
return _do_fork(&args);
414+
return kernel_clone(&args);
415415
}
416416

417417
static void

arch/m68k/kernel/process.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ void flush_thread(void)
107107
* on top of pt_regs, which means that sys_clone() arguments would be
108108
* buried. We could, of course, copy them, but it's too costly for no
109109
* good reason - generic clone() would have to copy them *again* for
110-
* _do_fork() anyway. So in this case it's actually better to pass pt_regs *
111-
* and extract arguments for _do_fork() from there. Eventually we might
112-
* go for calling _do_fork() directly from the wrapper, but only after we
113-
* are finished with _do_fork() prototype conversion.
110+
* kernel_clone() anyway. So in this case it's actually better to pass pt_regs *
111+
* and extract arguments for kernel_clone() from there. Eventually we might
112+
* go for calling kernel_clone() directly from the wrapper, but only after we
113+
* are finished with kernel_clone() prototype conversion.
114114
*/
115115
asmlinkage int m68k_clone(struct pt_regs *regs)
116116
{
@@ -125,7 +125,7 @@ asmlinkage int m68k_clone(struct pt_regs *regs)
125125
.tls = regs->d5,
126126
};
127127

128-
return _do_fork(&args);
128+
return kernel_clone(&args);
129129
}
130130

131131
/*

arch/nios2/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,5 +266,5 @@ asmlinkage int nios2_clone(unsigned long clone_flags, unsigned long newsp,
266266
.tls = tls,
267267
};
268268

269-
return _do_fork(&args);
269+
return kernel_clone(&args);
270270
}

arch/sparc/kernel/process.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ asmlinkage long sparc_fork(struct pt_regs *regs)
2525
.stack = regs->u_regs[UREG_FP],
2626
};
2727

28-
ret = _do_fork(&args);
28+
ret = kernel_clone(&args);
2929

3030
/* If we get an error and potentially restart the system
3131
* call, we're screwed because copy_thread() clobbered
@@ -50,7 +50,7 @@ asmlinkage long sparc_vfork(struct pt_regs *regs)
5050
.stack = regs->u_regs[UREG_FP],
5151
};
5252

53-
ret = _do_fork(&args);
53+
ret = kernel_clone(&args);
5454

5555
/* If we get an error and potentially restart the system
5656
* call, we're screwed because copy_thread() clobbered
@@ -96,7 +96,7 @@ asmlinkage long sparc_clone(struct pt_regs *regs)
9696
else
9797
args.stack = regs->u_regs[UREG_FP];
9898

99-
ret = _do_fork(&args);
99+
ret = kernel_clone(&args);
100100

101101
/* If we get an error and potentially restart the system
102102
* call, we're screwed because copy_thread() clobbered

arch/x86/kernel/sys_ia32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,6 @@ COMPAT_SYSCALL_DEFINE5(ia32_clone, unsigned long, clone_flags,
251251
.tls = tls_val,
252252
};
253253

254-
return _do_fork(&args);
254+
return kernel_clone(&args);
255255
}
256256
#endif /* CONFIG_IA32_EMULATION */

drivers/misc/kgdbts.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@
3333
* You can also specify optional tests:
3434
* N## = Go to sleep with interrupts of for ## seconds
3535
* to test the HW NMI watchdog
36-
* F## = Break at do_fork for ## iterations
36+
* F## = Break at kernel_clone for ## iterations
3737
* S## = Break at sys_open for ## iterations
3838
* I## = Run the single step test ## iterations
3939
*
40-
* NOTE: that the do_fork and sys_open tests are mutually exclusive.
40+
* NOTE: that the kernel_clone and sys_open tests are mutually exclusive.
4141
*
4242
* To invoke the kgdb test suite from boot you use a kernel start
4343
* argument as follows:
4444
* kgdbts=V1 kgdbwait
45-
* Or if you wanted to perform the NMI test for 6 seconds and do_fork
45+
* Or if you wanted to perform the NMI test for 6 seconds and kernel_clone
4646
* test for 100 forks, you could use:
4747
* kgdbts=V1N6F100 kgdbwait
4848
*
@@ -74,7 +74,7 @@
7474
* echo kgdbts=V1S10000 > /sys/module/kgdbts/parameters/kgdbts
7575
* fg # and hit control-c
7676
* fg # and hit control-c
77-
* ## This tests break points on do_fork
77+
* ## This tests break points on kernel_clone
7878
* while [ 1 ] ; do date > /dev/null ; done &
7979
* while [ 1 ] ; do date > /dev/null ; done &
8080
* echo kgdbts=V1F1000 > /sys/module/kgdbts/parameters/kgdbts
@@ -209,8 +209,8 @@ static unsigned long lookup_addr(char *arg)
209209
addr = (unsigned long)kgdbts_break_test;
210210
else if (!strcmp(arg, "sys_open"))
211211
addr = (unsigned long)do_sys_open;
212-
else if (!strcmp(arg, "do_fork"))
213-
addr = (unsigned long)_do_fork;
212+
else if (!strcmp(arg, "kernel_clone"))
213+
addr = (unsigned long)kernel_clone;
214214
else if (!strcmp(arg, "hw_break_val"))
215215
addr = (unsigned long)&hw_break_val;
216216
addr = (unsigned long) dereference_function_descriptor((void *)addr);
@@ -310,7 +310,7 @@ static int check_and_rewind_pc(char *put_str, char *arg)
310310

311311
if (arch_needs_sstep_emulation && sstep_addr &&
312312
ip + offset == sstep_addr &&
313-
((!strcmp(arg, "sys_open") || !strcmp(arg, "do_fork")))) {
313+
((!strcmp(arg, "sys_open") || !strcmp(arg, "kernel_clone")))) {
314314
/* This is special case for emulated single step */
315315
v2printk("Emul: rewind hit single step bp\n");
316316
restart_from_top_after_write = 1;
@@ -596,19 +596,19 @@ static struct test_struct singlestep_break_test[] = {
596596
};
597597

598598
/*
599-
* Test for hitting a breakpoint at do_fork for what ever the number
599+
* Test for hitting a breakpoint at kernel_clone for what ever the number
600600
* of iterations required by the variable repeat_test.
601601
*/
602-
static struct test_struct do_fork_test[] = {
602+
static struct test_struct do_kernel_clone_test[] = {
603603
{ "?", "S0*" }, /* Clear break points */
604-
{ "do_fork", "OK", sw_break, }, /* set sw breakpoint */
604+
{ "kernel_clone", "OK", sw_break, }, /* set sw breakpoint */
605605
{ "c", "T0*", NULL, get_thread_id_continue }, /* Continue */
606-
{ "do_fork", "OK", sw_rem_break }, /*remove breakpoint */
607-
{ "g", "do_fork", NULL, check_and_rewind_pc }, /* check location */
606+
{ "kernel_clone", "OK", sw_rem_break }, /*remove breakpoint */
607+
{ "g", "kernel_clone", NULL, check_and_rewind_pc }, /* check location */
608608
{ "write", "OK", write_regs, emul_reset }, /* Write registers */
609609
{ "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */
610-
{ "g", "do_fork", NULL, check_single_step },
611-
{ "do_fork", "OK", sw_break, }, /* set sw breakpoint */
610+
{ "g", "kernel_clone", NULL, check_single_step },
611+
{ "kernel_clone", "OK", sw_break, }, /* set sw breakpoint */
612612
{ "7", "T0*", skip_back_repeat_test }, /* Loop based on repeat_test */
613613
{ "D", "OK", NULL, final_ack_set }, /* detach and unregister I/O */
614614
{ "", "", get_cont_catch, put_cont_catch },
@@ -935,11 +935,11 @@ static void run_bad_read_test(void)
935935
kgdb_breakpoint();
936936
}
937937

938-
static void run_do_fork_test(void)
938+
static void run_kernel_clone_test(void)
939939
{
940940
init_simple_test();
941-
ts.tst = do_fork_test;
942-
ts.name = "do_fork_test";
941+
ts.tst = do_kernel_clone_test;
942+
ts.name = "do_kernel_clone_test";
943943
/* Activate test with initial breakpoint */
944944
kgdb_breakpoint();
945945
}
@@ -967,7 +967,7 @@ static void run_singlestep_break_test(void)
967967
static void kgdbts_run_tests(void)
968968
{
969969
char *ptr;
970-
int fork_test = 0;
970+
int clone_test = 0;
971971
int do_sys_open_test = 0;
972972
int sstep_test = 1000;
973973
int nmi_sleep = 0;
@@ -981,7 +981,7 @@ static void kgdbts_run_tests(void)
981981

982982
ptr = strchr(config, 'F');
983983
if (ptr)
984-
fork_test = simple_strtol(ptr + 1, NULL, 10);
984+
clone_test = simple_strtol(ptr + 1, NULL, 10);
985985
ptr = strchr(config, 'S');
986986
if (ptr)
987987
do_sys_open_test = simple_strtol(ptr + 1, NULL, 10);
@@ -1025,16 +1025,16 @@ static void kgdbts_run_tests(void)
10251025
run_nmi_sleep_test(nmi_sleep);
10261026
}
10271027

1028-
/* If the do_fork test is run it will be the last test that is
1028+
/* If the kernel_clone test is run it will be the last test that is
10291029
* executed because a kernel thread will be spawned at the very
10301030
* end to unregister the debug hooks.
10311031
*/
1032-
if (fork_test) {
1033-
repeat_test = fork_test;
1034-
printk(KERN_INFO "kgdbts:RUN do_fork for %i breakpoints\n",
1032+
if (clone_test) {
1033+
repeat_test = clone_test;
1034+
printk(KERN_INFO "kgdbts:RUN kernel_clone for %i breakpoints\n",
10351035
repeat_test);
10361036
kthread_run(kgdbts_unreg_thread, NULL, "kgdbts_unreg");
1037-
run_do_fork_test();
1037+
run_kernel_clone_test();
10381038
return;
10391039
}
10401040

include/linux/sched/task.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ extern void do_group_exit(int);
8383
extern void exit_files(struct task_struct *);
8484
extern void exit_itimers(struct signal_struct *);
8585

86-
extern long _do_fork(struct kernel_clone_args *kargs);
86+
extern pid_t kernel_clone(struct kernel_clone_args *kargs);
8787
struct task_struct *fork_idle(int);
8888
struct mm_struct *copy_init_mm(void);
8989
extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);

kernel/fork.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,14 +2412,14 @@ struct mm_struct *copy_init_mm(void)
24122412
*
24132413
* args->exit_signal is expected to be checked for sanity by the caller.
24142414
*/
2415-
long _do_fork(struct kernel_clone_args *args)
2415+
pid_t kernel_clone(struct kernel_clone_args *args)
24162416
{
24172417
u64 clone_flags = args->flags;
24182418
struct completion vfork;
24192419
struct pid *pid;
24202420
struct task_struct *p;
24212421
int trace = 0;
2422-
long nr;
2422+
pid_t nr;
24232423

24242424
/*
24252425
* For legacy clone() calls, CLONE_PIDFD uses the parent_tid argument
@@ -2505,7 +2505,7 @@ pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
25052505
.stack_size = (unsigned long)arg,
25062506
};
25072507

2508-
return _do_fork(&args);
2508+
return kernel_clone(&args);
25092509
}
25102510

25112511
#ifdef __ARCH_WANT_SYS_FORK
@@ -2516,7 +2516,7 @@ SYSCALL_DEFINE0(fork)
25162516
.exit_signal = SIGCHLD,
25172517
};
25182518

2519-
return _do_fork(&args);
2519+
return kernel_clone(&args);
25202520
#else
25212521
/* can not support in nommu mode */
25222522
return -EINVAL;
@@ -2532,7 +2532,7 @@ SYSCALL_DEFINE0(vfork)
25322532
.exit_signal = SIGCHLD,
25332533
};
25342534

2535-
return _do_fork(&args);
2535+
return kernel_clone(&args);
25362536
}
25372537
#endif
25382538

@@ -2570,7 +2570,7 @@ SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
25702570
.tls = tls,
25712571
};
25722572

2573-
return _do_fork(&args);
2573+
return kernel_clone(&args);
25742574
}
25752575
#endif
25762576

@@ -2728,7 +2728,7 @@ SYSCALL_DEFINE2(clone3, struct clone_args __user *, uargs, size_t, size)
27282728
if (!clone3_args_valid(&kargs))
27292729
return -EINVAL;
27302730

2731-
return _do_fork(&kargs);
2731+
return kernel_clone(&kargs);
27322732
}
27332733
#endif
27342734

@@ -2891,7 +2891,7 @@ int unshare_fd(unsigned long unshare_flags, unsigned int max_fds,
28912891
/*
28922892
* unshare allows a process to 'unshare' part of the process
28932893
* context which was originally shared using clone. copy_*
2894-
* functions used by _do_fork() cannot be used here directly
2894+
* functions used by kernel_clone() cannot be used here directly
28952895
* because they modify an inactive task_struct that is being
28962896
* constructed. Here we are modifying the current, active,
28972897
* task_struct.

0 commit comments

Comments
 (0)