Re: [PATCH] checkpatch: types found in one source file do not affect processing of others
On 18/05/15 20:42, Joe Perches wrote: On Mon, 2015-05-18 at 15:33 +0200, Alex Dowad wrote: checkpatch uses various cues in its input files to discover the names of user-defined types. It then uses that information when processing expressions, to discover more style issues. Unfortunately, in rare cases, this means that checkpatch may give different results if you run it on several files at the same time, or one by one! The reason is that it may identify a type (or something that looks like a type) in one file, and then carry this information over when processing a different file. As an example, drivers/staging/media/bcm2048/radio-bcm2048.c contains this line (in a macro): size value; Then drivers/staging/media/davinci_vpfe/vpfe_video.c has this line: while (size * *nbuffers > vpfe_dev->video_limit) If checkpatch processes these 2 files together, the (spurious) "size" type detected in the first file will cause it to flag the second file for improper use of the pointer dereference operator! Therefore, keep user-defined types in a separate array from built-in ones, and reset the array of user-defined types at the beginning of each new source file. I suggest this: --- scripts/checkpatch.pl | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 89b1df4..174d711 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -418,6 +418,7 @@ our @typeList = ( qr{${Ident}_handler_fn}, @typeListMisordered, ); +our @typeListFile = (); our @typeListWithAttr = ( @typeList, qr{struct\s+$InitAttribute\s+$Ident}, @@ -427,6 +428,7 @@ our @typeListWithAttr = ( our @modifierList = ( qr{fastcall}, ); +our @modifierListFile = (); our @mode_permission_funcs = ( ["module_param", 3], @@ -510,8 +512,8 @@ if ($codespell) { $misspellings = join("|", sort keys %spelling_fix) if keys %spelling_fix; sub build_types { - my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; - my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; + my $mods = "(?x: \n" . join("|\n ", (@modifierList, @modifierListFile)) . "\n)"; + my $all = "(?x: \n" . join("|\n ", (@typeList, @typeListFile)) . "\n)"; my $Misordered = "(?x: \n" . join("|\n ", @typeListMisordered) . "\n)"; my $allWithAttr = "(?x: \n" . join("|\n ", @typeListWithAttr) . "\n)"; $Modifier = qr{(?:$Attribute|$Sparse|$mods)}; @@ -746,6 +748,9 @@ for my $filename (@ARGV) { @fixed_inserted = (); @fixed_deleted = (); $fixlinenr = -1; + @modifierListFile = (); + @typeListFile = (); + build_types(); } exit($exit); @@ -1610,13 +1615,13 @@ sub possible { for my $modifier (split(' ', $possible)) { if ($modifier !~ $notPermitted) { warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible); - push(@modifierList, $modifier); + push(@modifierListFile, $modifier); } } } else { warn "POSSIBLE: $possible ($line)\n" if ($dbg_possible); - push(@typeList, $possible); + push(@typeListFile, $possible); } build_types(); } else { Looks good! AD -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] checkpatch: types found in one source file do not affect processing of others
checkpatch uses various cues in its input files to discover the names of user-defined types. It then uses that information when processing expressions, to discover more style issues. Unfortunately, in rare cases, this means that checkpatch may give different results if you run it on several files at the same time, or one by one! The reason is that it may identify a type (or something that looks like a type) in one file, and then carry this information over when processing a different file. As an example, drivers/staging/media/bcm2048/radio-bcm2048.c contains this line (in a macro): size value; Then drivers/staging/media/davinci_vpfe/vpfe_video.c has this line: while (size * *nbuffers > vpfe_dev->video_limit) If checkpatch processes these 2 files together, the (spurious) "size" type detected in the first file will cause it to flag the second file for improper use of the pointer dereference operator! Therefore, keep user-defined types in a separate array from built-in ones, and reset the array of user-defined types at the beginning of each new source file. Signed-off-by: Alex Dowad --- Dear patch checkers, I am not a Perl programmer -- please let me know if there is a better way to accomplish what I am trying to do here. Your feedback will be appreciated, Alex Dowad scripts/checkpatch.pl | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 89b1df4..5a5668f 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -424,6 +424,10 @@ our @typeListWithAttr = ( qr{union\s+$InitAttribute\s+$Ident}, ); +# includes user-defined types discovered in the code +# reset at the beginning of each source file +our @allTypeList = (@typeList); + our @modifierList = ( qr{fastcall}, ); @@ -511,7 +515,7 @@ $misspellings = join("|", sort keys %spelling_fix) if keys %spelling_fix; sub build_types { my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; - my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; + my $all = "(?x: \n" . join("|\n ", @allTypeList) . "\n)"; my $Misordered = "(?x: \n" . join("|\n ", @typeListMisordered) . "\n)"; my $allWithAttr = "(?x: \n" . join("|\n ", @typeListWithAttr) . "\n)"; $Modifier = qr{(?:$Attribute|$Sparse|$mods)}; @@ -745,6 +749,7 @@ for my $filename (@ARGV) { @fixed = (); @fixed_inserted = (); @fixed_deleted = (); + @allTypeList = (@typeList); $fixlinenr = -1; } @@ -1616,7 +1621,7 @@ sub possible { } else { warn "POSSIBLE: $possible ($line)\n" if ($dbg_possible); - push(@typeList, $possible); + push(@allTypeList, $possible); } build_types(); } else { -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] checkpatch: types found in one source file do not affect processing of others
checkpatch uses various cues in its input files to discover the names of user-defined types. It then uses that information when processing expressions, to discover more style issues. Unfortunately, in rare cases, this means that checkpatch may give different results if you run it on several files at the same time, or one by one! The reason is that it may identify a type (or something that looks like a type) in one file, and then carry this information over when processing a different file. As an example, drivers/staging/media/bcm2048/radio-bcm2048.c contains this line (in a macro): size value; Then drivers/staging/media/davinci_vpfe/vpfe_video.c has this line: while (size * *nbuffers vpfe_dev-video_limit) If checkpatch processes these 2 files together, the (spurious) size type detected in the first file will cause it to flag the second file for improper use of the pointer dereference operator! Therefore, keep user-defined types in a separate array from built-in ones, and reset the array of user-defined types at the beginning of each new source file. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- Dear patch checkers, I am not a Perl programmer -- please let me know if there is a better way to accomplish what I am trying to do here. Your feedback will be appreciated, Alex Dowad scripts/checkpatch.pl | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 89b1df4..5a5668f 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -424,6 +424,10 @@ our @typeListWithAttr = ( qr{union\s+$InitAttribute\s+$Ident}, ); +# includes user-defined types discovered in the code +# reset at the beginning of each source file +our @allTypeList = (@typeList); + our @modifierList = ( qr{fastcall}, ); @@ -511,7 +515,7 @@ $misspellings = join(|, sort keys %spelling_fix) if keys %spelling_fix; sub build_types { my $mods = (?x: \n . join(|\n , @modifierList) . \n); - my $all = (?x: \n . join(|\n , @typeList) . \n); + my $all = (?x: \n . join(|\n , @allTypeList) . \n); my $Misordered = (?x: \n . join(|\n , @typeListMisordered) . \n); my $allWithAttr = (?x: \n . join(|\n , @typeListWithAttr) . \n); $Modifier = qr{(?:$Attribute|$Sparse|$mods)}; @@ -745,6 +749,7 @@ for my $filename (@ARGV) { @fixed = (); @fixed_inserted = (); @fixed_deleted = (); + @allTypeList = (@typeList); $fixlinenr = -1; } @@ -1616,7 +1621,7 @@ sub possible { } else { warn POSSIBLE: $possible ($line)\n if ($dbg_possible); - push(@typeList, $possible); + push(@allTypeList, $possible); } build_types(); } else { -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] checkpatch: types found in one source file do not affect processing of others
On 18/05/15 20:42, Joe Perches wrote: On Mon, 2015-05-18 at 15:33 +0200, Alex Dowad wrote: checkpatch uses various cues in its input files to discover the names of user-defined types. It then uses that information when processing expressions, to discover more style issues. Unfortunately, in rare cases, this means that checkpatch may give different results if you run it on several files at the same time, or one by one! The reason is that it may identify a type (or something that looks like a type) in one file, and then carry this information over when processing a different file. As an example, drivers/staging/media/bcm2048/radio-bcm2048.c contains this line (in a macro): size value; Then drivers/staging/media/davinci_vpfe/vpfe_video.c has this line: while (size * *nbuffers vpfe_dev-video_limit) If checkpatch processes these 2 files together, the (spurious) size type detected in the first file will cause it to flag the second file for improper use of the pointer dereference operator! Therefore, keep user-defined types in a separate array from built-in ones, and reset the array of user-defined types at the beginning of each new source file. I suggest this: --- scripts/checkpatch.pl | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 89b1df4..174d711 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -418,6 +418,7 @@ our @typeList = ( qr{${Ident}_handler_fn}, @typeListMisordered, ); +our @typeListFile = (); our @typeListWithAttr = ( @typeList, qr{struct\s+$InitAttribute\s+$Ident}, @@ -427,6 +428,7 @@ our @typeListWithAttr = ( our @modifierList = ( qr{fastcall}, ); +our @modifierListFile = (); our @mode_permission_funcs = ( [module_param, 3], @@ -510,8 +512,8 @@ if ($codespell) { $misspellings = join(|, sort keys %spelling_fix) if keys %spelling_fix; sub build_types { - my $mods = (?x: \n . join(|\n , @modifierList) . \n); - my $all = (?x: \n . join(|\n , @typeList) . \n); + my $mods = (?x: \n . join(|\n , (@modifierList, @modifierListFile)) . \n); + my $all = (?x: \n . join(|\n , (@typeList, @typeListFile)) . \n); my $Misordered = (?x: \n . join(|\n , @typeListMisordered) . \n); my $allWithAttr = (?x: \n . join(|\n , @typeListWithAttr) . \n); $Modifier = qr{(?:$Attribute|$Sparse|$mods)}; @@ -746,6 +748,9 @@ for my $filename (@ARGV) { @fixed_inserted = (); @fixed_deleted = (); $fixlinenr = -1; + @modifierListFile = (); + @typeListFile = (); + build_types(); } exit($exit); @@ -1610,13 +1615,13 @@ sub possible { for my $modifier (split(' ', $possible)) { if ($modifier !~ $notPermitted) { warn MODIFIER: $modifier ($possible) ($line)\n if ($dbg_possible); - push(@modifierList, $modifier); + push(@modifierListFile, $modifier); } } } else { warn POSSIBLE: $possible ($line)\n if ($dbg_possible); - push(@typeList, $possible); + push(@typeListFile, $possible); } build_types(); } else { Looks good! AD -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Remove empty branch from conditional
This fixes a checkpatch style warning in ft1000_ioctl. Signed-off-by: Alex Dowad --- drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index 2d758fb..2593413 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -588,8 +588,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command, /* Check message qtype type which is the lower byte within qos_class */ qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff; /* pr_debug("qtype = %d\n", qtype); */ - if (qtype) { - } else { + if (!qtype) { /* Put message into Slow Queue */ /* Only put a message into the DPRAM if msg doorbell is available */ status = ft1000_read_register(ft1000dev, , FT1000_REG_DOORBELL); -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Clarify expression which uses both multiplication and pointer dereference
This fixes a checkpatch style error in vpfe_buffer_queue_setup. Signed-off-by: Alex Dowad --- drivers/staging/media/davinci_vpfe/vpfe_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index 06d48d5..04a687c 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -1095,7 +1095,7 @@ vpfe_buffer_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, size = video->fmt.fmt.pix.sizeimage; if (vpfe_dev->video_limit) { - while (size * *nbuffers > vpfe_dev->video_limit) + while (size * (*nbuffers) > vpfe_dev->video_limit) (*nbuffers)--; } if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS) { -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Remove empty branch from conditional
This fixes a checkpatch style warning in ft1000_ioctl. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index 2d758fb..2593413 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -588,8 +588,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command, /* Check message qtype type which is the lower byte within qos_class */ qtype = ntohs(dpram_data-pseudohdr.qos_class) 0xff; /* pr_debug(qtype = %d\n, qtype); */ - if (qtype) { - } else { + if (!qtype) { /* Put message into Slow Queue */ /* Only put a message into the DPRAM if msg doorbell is available */ status = ft1000_read_register(ft1000dev, tempword, FT1000_REG_DOORBELL); -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Clarify expression which uses both multiplication and pointer dereference
This fixes a checkpatch style error in vpfe_buffer_queue_setup. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- drivers/staging/media/davinci_vpfe/vpfe_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index 06d48d5..04a687c 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -1095,7 +1095,7 @@ vpfe_buffer_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, size = video-fmt.fmt.pix.sizeimage; if (vpfe_dev-video_limit) { - while (size * *nbuffers vpfe_dev-video_limit) + while (size * (*nbuffers) vpfe_dev-video_limit) (*nbuffers)--; } if (pipe-state == VPFE_PIPELINE_STREAM_CONTINUOUS) { -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] sched/fair: correct inaccurate comment in __update_group_entity_contrib
Signed-off-by: Alex Dowad --- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index bcfe320..1bae5ea 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2648,7 +2648,7 @@ static inline void __update_group_entity_contrib(struct sched_entity *se) * lower-bound on the true value. * * Consider the aggregate of 2 contributions. Either they are disjoint -* (and the sum represents true value) or they are disjoint and we are +* (and the sum represents true value) or they intersect and we are * understating by the aggregate of their overlap. * * Extending this to N cpus, for a given overlap, the maximum amount we -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] sched/fair: correct inaccurate comment in __update_group_entity_contrib
Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index bcfe320..1bae5ea 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2648,7 +2648,7 @@ static inline void __update_group_entity_contrib(struct sched_entity *se) * lower-bound on the true value. * * Consider the aggregate of 2 contributions. Either they are disjoint -* (and the sum represents true value) or they are disjoint and we are +* (and the sum represents true value) or they intersect and we are * understating by the aggregate of their overlap. * * Extending this to N cpus, for a given overlap, the maximum amount we -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 03/32v2] arc: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity. Signed-off-by: Alex Dowad --- arch/arc/kernel/process.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c index fdd8971..cf366bd 100644 --- a/arch/arc/kernel/process.c +++ b/arch/arc/kernel/process.c @@ -49,7 +49,9 @@ void arch_cpu_idle(void) asmlinkage void ret_from_fork(void); -/* Layout of Child kernel mode stack as setup at the end of this function is +/* Copy architecture-specific thread state + * + * Layout of Child kernel mode stack as setup at the end of this function is * * | ...| * | ...| @@ -81,7 +83,7 @@ asmlinkage void ret_from_fork(void); * -- <= END of PAGE */ int copy_thread(unsigned long clone_flags, - unsigned long usp, unsigned long arg, + unsigned long usp, unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *c_regs;/* child's pt_regs */ @@ -110,9 +112,10 @@ int copy_thread(unsigned long clone_flags, childksp[1] = (unsigned long)ret_from_fork; /* blink */ if (unlikely(p->flags & PF_KTHREAD)) { memset(c_regs, 0, sizeof(struct pt_regs)); - c_callee->r13 = arg; /* argument to kernel thread */ + c_callee->r13 = kthread_arg; c_callee->r14 = usp; /* function */ return 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 03/32] arc: copy_thread(): rename 'arg' argument to 'kthread_arg'
On 25/03/15 13:47, Vineet Gupta wrote: On Friday 13 March 2015 11:35 PM, Alex Dowad wrote: The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/arc/kernel/process.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c index fdd8971..cf366bd 100644 --- a/arch/arc/kernel/process.c +++ b/arch/arc/kernel/process.c @@ -49,7 +49,9 @@ void arch_cpu_idle(void) asmlinkage void ret_from_fork(void); -/* Layout of Child kernel mode stack as setup at the end of this function is +/* Copy architecture-specific thread state + * + * Layout of Child kernel mode stack as setup at the end of this function is * * | ...| * | ...| @@ -81,7 +83,7 @@ asmlinkage void ret_from_fork(void); * -- <= END of PAGE */ int copy_thread(unsigned long clone_flags, - unsigned long usp, unsigned long arg, + unsigned long usp, unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *c_regs;/* child's pt_regs */ @@ -110,9 +112,10 @@ int copy_thread(unsigned long clone_flags, childksp[1] = (unsigned long)ret_from_fork; /* blink */ if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ This seems extraneous given that PF_KTHREAD above check makes is obvious that this is a kernel thread. memset(c_regs, 0, sizeof(struct pt_regs)); - c_callee->r13 = arg; /* argument to kernel thread */ + c_callee->r13 = kthread_arg; c_callee->r14 = usp; /* function */ return 0; Applied to for-next after pruning the comment above. Thank you. Is it too late for me to tweak the commit comment? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 03/32v2] arc: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/arc/kernel/process.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c index fdd8971..cf366bd 100644 --- a/arch/arc/kernel/process.c +++ b/arch/arc/kernel/process.c @@ -49,7 +49,9 @@ void arch_cpu_idle(void) asmlinkage void ret_from_fork(void); -/* Layout of Child kernel mode stack as setup at the end of this function is +/* Copy architecture-specific thread state + * + * Layout of Child kernel mode stack as setup at the end of this function is * * | ...| * | ...| @@ -81,7 +83,7 @@ asmlinkage void ret_from_fork(void); * -- = END of PAGE */ int copy_thread(unsigned long clone_flags, - unsigned long usp, unsigned long arg, + unsigned long usp, unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *c_regs;/* child's pt_regs */ @@ -110,9 +112,10 @@ int copy_thread(unsigned long clone_flags, childksp[1] = (unsigned long)ret_from_fork; /* blink */ if (unlikely(p-flags PF_KTHREAD)) { memset(c_regs, 0, sizeof(struct pt_regs)); - c_callee-r13 = arg; /* argument to kernel thread */ + c_callee-r13 = kthread_arg; c_callee-r14 = usp; /* function */ return 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 03/32] arc: copy_thread(): rename 'arg' argument to 'kthread_arg'
On 25/03/15 13:47, Vineet Gupta wrote: On Friday 13 March 2015 11:35 PM, Alex Dowad wrote: The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/arc/kernel/process.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c index fdd8971..cf366bd 100644 --- a/arch/arc/kernel/process.c +++ b/arch/arc/kernel/process.c @@ -49,7 +49,9 @@ void arch_cpu_idle(void) asmlinkage void ret_from_fork(void); -/* Layout of Child kernel mode stack as setup at the end of this function is +/* Copy architecture-specific thread state + * + * Layout of Child kernel mode stack as setup at the end of this function is * * | ...| * | ...| @@ -81,7 +83,7 @@ asmlinkage void ret_from_fork(void); * -- = END of PAGE */ int copy_thread(unsigned long clone_flags, - unsigned long usp, unsigned long arg, + unsigned long usp, unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *c_regs;/* child's pt_regs */ @@ -110,9 +112,10 @@ int copy_thread(unsigned long clone_flags, childksp[1] = (unsigned long)ret_from_fork; /* blink */ if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ This seems extraneous given that PF_KTHREAD above check makes is obvious that this is a kernel thread. memset(c_regs, 0, sizeof(struct pt_regs)); - c_callee-r13 = arg; /* argument to kernel thread */ + c_callee-r13 = kthread_arg; c_callee-r14 = usp; /* function */ return 0; Applied to for-next after pruning the comment above. Thank you. Is it too late for me to tweak the commit comment? -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [23/32] powerpc: copy_thread(): rename 'arg' argument to 'kthread_arg'
On 20/03/15 01:54, Michael Ellerman wrote: On Thu, 2015-03-19 at 09:22 +0200, Alex Dowad wrote: On 19/03/15 08:45, Michael Ellerman wrote: On Fri, 2015-13-03 at 18:14:46 UTC, Alex Dowad wrote: The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). I don't understand the bit about consistency with do_fork() ? This series of patches includes one patch which renames the arg for do_fork(), and others which rename the same arg for each arch-specific implementation of copy_thread(). So if all of them are accepted and merged, then all will be consistent. If only some of the patches are accepted, I will rewrite the commit message so it doesn't mention "consistency". Ah OK, I only got patch 23, so I missed the context of the whole series. I'll apply this one to the powerpc tree. Dear M. Ellerman, sorry for not replying promptly. If you would like to apply this directly to the powerpc tree, that is fine, but can I edit the commit message to remove the mention of 'consistency'? I doubt that all 30+ archs will ever merge this change. Thanks, Alex -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [23/32] powerpc: copy_thread(): rename 'arg' argument to 'kthread_arg'
On 20/03/15 01:54, Michael Ellerman wrote: On Thu, 2015-03-19 at 09:22 +0200, Alex Dowad wrote: On 19/03/15 08:45, Michael Ellerman wrote: On Fri, 2015-13-03 at 18:14:46 UTC, Alex Dowad wrote: The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). I don't understand the bit about consistency with do_fork() ? This series of patches includes one patch which renames the arg for do_fork(), and others which rename the same arg for each arch-specific implementation of copy_thread(). So if all of them are accepted and merged, then all will be consistent. If only some of the patches are accepted, I will rewrite the commit message so it doesn't mention consistency. Ah OK, I only got patch 23, so I missed the context of the whole series. I'll apply this one to the powerpc tree. Dear M. Ellerman, sorry for not replying promptly. If you would like to apply this directly to the powerpc tree, that is fine, but can I edit the commit message to remove the mention of 'consistency'? I doubt that all 30+ archs will ever merge this change. Thanks, Alex -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [23/32] powerpc: copy_thread(): rename 'arg' argument to 'kthread_arg'
On 19/03/15 08:45, Michael Ellerman wrote: On Fri, 2015-13-03 at 18:14:46 UTC, Alex Dowad wrote: The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). I don't understand the bit about consistency with do_fork() ? This series of patches includes one patch which renames the arg for do_fork(), and others which rename the same arg for each arch-specific implementation of copy_thread(). So if all of them are accepted and merged, then all will be consistent. If only some of the patches are accepted, I will rewrite the commit message so it doesn't mention "consistency". Thanks! AD Otherwise it looks fine. cheers -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [23/32] powerpc: copy_thread(): rename 'arg' argument to 'kthread_arg'
On 19/03/15 08:45, Michael Ellerman wrote: On Fri, 2015-13-03 at 18:14:46 UTC, Alex Dowad wrote: The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). I don't understand the bit about consistency with do_fork() ? This series of patches includes one patch which renames the arg for do_fork(), and others which rename the same arg for each arch-specific implementation of copy_thread(). So if all of them are accepted and merged, then all will be consistent. If only some of the patches are accepted, I will rewrite the commit message so it doesn't mention consistency. Thanks! AD Otherwise it looks fine. cheers -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 28/32] tile: copy_thread(): rename 'arg' argument to 'kthread_arg'
On 16/03/15 22:19, Chris Metcalf wrote: On 3/13/2015 2:14 PM, Alex Dowad wrote: The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/tile/kernel/process.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) Acked-by: Chris Metcalf If you would prefer me to take this into the tile tree, let me know, and I am happy to do so. Hi Chris, Thanks for your kind offer. I am a 100% genuine true-blue kernel newbie and have no idea whether a change like this should be merged individually by each arch maintainer, or all together at some point upstream (or is it downstream? I'm not sure about my streams). Do you have any suggestion? Thank you again! AD -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCHv2 16/32] metag: copy_thread(): rename 'arg' argument to 'kthread_arg'
On 16/03/15 16:31, James Hogan wrote: Hi Alex, On 16/03/15 13:13, Alex Dowad wrote: The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity. Signed-off-by: Alex Dowad --- James Hogan, Thanks for reviewing this patch. The comment has been updated as you suggested. You said: "I'll assume you plan to get all these patches merged together rather than via individual arch trees..." The truth is that I am as green as green can be and have no idea how I plan to get these patches merged. I was just reading the Linux source and saw what looked like an opportunity to make the code a tiny bit easier to read. If you have any suggestions on how to proceed, please let me know. I guess there are 3 main paths: 1) Ask individual arch maintainers to apply the patches if possible, since it doesn't have dependencies on other patches you're submitting. 2) Gather acks from maintainers for the remaining patches and ask Andrew Morton or another relevant maintainer to apply them (Andrew often picks up misc patches like this I believe). 3) Or gather acks for remaining patches and send a pull request to Linus yourself during the next merge window. Btw, the whitespace seems to be corrupted here, so the patch won't apply: Grrr. Sending again. Thanks for the pointers on merge workflow. I doubt that I will get the attention of each and every arch maintainer, but let's see what will happen. Thanks again. - /* Set D1Ar1=arg and D1RtP=usp (fn) */ ^^^ currently this is indented with tabs not spaces + /* Set D1Ar1=kthread_arg and D1RtP=usp (fn) */ ^^^ and this has a space before a tab Cheers James -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCHv3 16/32] metag: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity. Signed-off-by: Alex Dowad --- Fixed problem with whitespace, sending again. AD arch/metag/kernel/process.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/metag/kernel/process.c b/arch/metag/kernel/process.c index 483dff9..dcb4609 100644 --- a/arch/metag/kernel/process.c +++ b/arch/metag/kernel/process.c @@ -174,8 +174,11 @@ void show_regs(struct pt_regs *regs) show_trace(NULL, (unsigned long *)regs->ctx.AX[0].U0, regs); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *tsk) + unsigned long kthread_arg, struct task_struct *tsk) { struct pt_regs *childregs = task_pt_regs(tsk); void *kernel_context = ((void *) childregs + @@ -204,10 +207,11 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, childregs->ctx.AX[0].U0 = (unsigned long) kernel_context; - /* Set D1Ar1=arg and D1RtP=usp (fn) */ + /* Set D1Ar1=kthread_arg and D1RtP=usp (fn) */ childregs->ctx.DX[4].U1 = usp; - childregs->ctx.DX[3].U1 = arg; + childregs->ctx.DX[3].U1 = kthread_arg; tsk->thread.int_depth = 2; return 0; } + /* * Get a pointer to where the new child's register block should have * been pushed. -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCHv2 16/32] metag: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity. Signed-off-by: Alex Dowad --- James Hogan, Thanks for reviewing this patch. The comment has been updated as you suggested. You said: "I'll assume you plan to get all these patches merged together rather than via individual arch trees..." The truth is that I am as green as green can be and have no idea how I plan to get these patches merged. I was just reading the Linux source and saw what looked like an opportunity to make the code a tiny bit easier to read. If you have any suggestions on how to proceed, please let me know. Kind regards, Alex Dowad arch/metag/kernel/process.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/metag/kernel/process.c b/arch/metag/kernel/process.c index 483dff9..dcb4609 100644 --- a/arch/metag/kernel/process.c +++ b/arch/metag/kernel/process.c @@ -174,8 +174,11 @@ void show_regs(struct pt_regs *regs) show_trace(NULL, (unsigned long *)regs->ctx.AX[0].U0, regs); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *tsk) + unsigned long kthread_arg, struct task_struct *tsk) { struct pt_regs *childregs = task_pt_regs(tsk); void *kernel_context = ((void *) childregs + @@ -204,10 +207,11 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, childregs->ctx.AX[0].U0 = (unsigned long) kernel_context; - /* Set D1Ar1=arg and D1RtP=usp (fn) */ + /* Set D1Ar1=kthread_arg and D1RtP=usp (fn) */ childregs->ctx.DX[4].U1 = usp; - childregs->ctx.DX[3].U1 = arg; + childregs->ctx.DX[3].U1 = kthread_arg; tsk->thread.int_depth = 2; return 0; } + /* * Get a pointer to where the new child's register block should have * been pushed. -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCHv2 06/32] avr32: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity. Signed-off-by: Alex Dowad --- Dear Hans-Christian Egtvedt, Thanks for your feedback! I have removed the unneeded comments. AD arch/avr32/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/avr32/kernel/process.c b/arch/avr32/kernel/process.c index 42a53e74..a255bd3 100644 --- a/arch/avr32/kernel/process.c +++ b/arch/avr32/kernel/process.c @@ -279,20 +279,25 @@ asmlinkage void ret_from_fork(void); asmlinkage void ret_from_kernel_thread(void); asmlinkage void syscall_return(void); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); if (unlikely(p->flags & PF_KTHREAD)) { memset(childregs, 0, sizeof(struct pt_regs)); - p->thread.cpu_context.r0 = arg; + p->thread.cpu_context.r0 = kthread_arg; p->thread.cpu_context.r1 = usp; /* fn */ p->thread.cpu_context.r2 = (unsigned long)syscall_return; p->thread.cpu_context.pc = (unsigned long)ret_from_kernel_thread; childregs->sr = MODE_SUPERVISOR; } else { *childregs = *current_pt_regs(); if (usp) childregs->sp = usp; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCHv2 16/32] metag: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- James Hogan, Thanks for reviewing this patch. The comment has been updated as you suggested. You said: I'll assume you plan to get all these patches merged together rather than via individual arch trees... The truth is that I am as green as green can be and have no idea how I plan to get these patches merged. I was just reading the Linux source and saw what looked like an opportunity to make the code a tiny bit easier to read. If you have any suggestions on how to proceed, please let me know. Kind regards, Alex Dowad arch/metag/kernel/process.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/metag/kernel/process.c b/arch/metag/kernel/process.c index 483dff9..dcb4609 100644 --- a/arch/metag/kernel/process.c +++ b/arch/metag/kernel/process.c @@ -174,8 +174,11 @@ void show_regs(struct pt_regs *regs) show_trace(NULL, (unsigned long *)regs-ctx.AX[0].U0, regs); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *tsk) + unsigned long kthread_arg, struct task_struct *tsk) { struct pt_regs *childregs = task_pt_regs(tsk); void *kernel_context = ((void *) childregs + @@ -204,10 +207,11 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, childregs-ctx.AX[0].U0 = (unsigned long) kernel_context; - /* Set D1Ar1=arg and D1RtP=usp (fn) */ + /* Set D1Ar1=kthread_arg and D1RtP=usp (fn) */ childregs-ctx.DX[4].U1 = usp; - childregs-ctx.DX[3].U1 = arg; + childregs-ctx.DX[3].U1 = kthread_arg; tsk-thread.int_depth = 2; return 0; } + /* * Get a pointer to where the new child's register block should have * been pushed. -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCHv2 16/32] metag: copy_thread(): rename 'arg' argument to 'kthread_arg'
On 16/03/15 16:31, James Hogan wrote: Hi Alex, On 16/03/15 13:13, Alex Dowad wrote: The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- James Hogan, Thanks for reviewing this patch. The comment has been updated as you suggested. You said: I'll assume you plan to get all these patches merged together rather than via individual arch trees... The truth is that I am as green as green can be and have no idea how I plan to get these patches merged. I was just reading the Linux source and saw what looked like an opportunity to make the code a tiny bit easier to read. If you have any suggestions on how to proceed, please let me know. I guess there are 3 main paths: 1) Ask individual arch maintainers to apply the patches if possible, since it doesn't have dependencies on other patches you're submitting. 2) Gather acks from maintainers for the remaining patches and ask Andrew Morton or another relevant maintainer to apply them (Andrew often picks up misc patches like this I believe). 3) Or gather acks for remaining patches and send a pull request to Linus yourself during the next merge window. Btw, the whitespace seems to be corrupted here, so the patch won't apply: Grrr. Sending again. Thanks for the pointers on merge workflow. I doubt that I will get the attention of each and every arch maintainer, but let's see what will happen. Thanks again. - /* Set D1Ar1=arg and D1RtP=usp (fn) */ ^^^ currently this is indented with tabs not spaces + /* Set D1Ar1=kthread_arg and D1RtP=usp (fn) */ ^^^ and this has a space before a tab Cheers James -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCHv3 16/32] metag: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- Fixed problem with whitespace, sending again. AD arch/metag/kernel/process.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/metag/kernel/process.c b/arch/metag/kernel/process.c index 483dff9..dcb4609 100644 --- a/arch/metag/kernel/process.c +++ b/arch/metag/kernel/process.c @@ -174,8 +174,11 @@ void show_regs(struct pt_regs *regs) show_trace(NULL, (unsigned long *)regs-ctx.AX[0].U0, regs); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *tsk) + unsigned long kthread_arg, struct task_struct *tsk) { struct pt_regs *childregs = task_pt_regs(tsk); void *kernel_context = ((void *) childregs + @@ -204,10 +207,11 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, childregs-ctx.AX[0].U0 = (unsigned long) kernel_context; - /* Set D1Ar1=arg and D1RtP=usp (fn) */ + /* Set D1Ar1=kthread_arg and D1RtP=usp (fn) */ childregs-ctx.DX[4].U1 = usp; - childregs-ctx.DX[3].U1 = arg; + childregs-ctx.DX[3].U1 = kthread_arg; tsk-thread.int_depth = 2; return 0; } + /* * Get a pointer to where the new child's register block should have * been pushed. -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 28/32] tile: copy_thread(): rename 'arg' argument to 'kthread_arg'
On 16/03/15 22:19, Chris Metcalf wrote: On 3/13/2015 2:14 PM, Alex Dowad wrote: The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowadalexinbeij...@gmail.com --- arch/tile/kernel/process.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) Acked-by: Chris Metcalf cmetc...@ezchip.com If you would prefer me to take this into the tile tree, let me know, and I am happy to do so. Hi Chris, Thanks for your kind offer. I am a 100% genuine true-blue kernel newbie and have no idea whether a change like this should be merged individually by each arch maintainer, or all together at some point upstream (or is it downstream? I'm not sure about my streams). Do you have any suggestion? Thank you again! AD -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCHv2 06/32] avr32: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- Dear Hans-Christian Egtvedt, Thanks for your feedback! I have removed the unneeded comments. AD arch/avr32/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/avr32/kernel/process.c b/arch/avr32/kernel/process.c index 42a53e74..a255bd3 100644 --- a/arch/avr32/kernel/process.c +++ b/arch/avr32/kernel/process.c @@ -279,20 +279,25 @@ asmlinkage void ret_from_fork(void); asmlinkage void ret_from_kernel_thread(void); asmlinkage void syscall_return(void); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); if (unlikely(p-flags PF_KTHREAD)) { memset(childregs, 0, sizeof(struct pt_regs)); - p-thread.cpu_context.r0 = arg; + p-thread.cpu_context.r0 = kthread_arg; p-thread.cpu_context.r1 = usp; /* fn */ p-thread.cpu_context.r2 = (unsigned long)syscall_return; p-thread.cpu_context.pc = (unsigned long)ret_from_kernel_thread; childregs-sr = MODE_SUPERVISOR; } else { *childregs = *current_pt_regs(); if (usp) childregs-sp = usp; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 13/32] ia64: copy_thread(): rename 'user_stack_size' argument to 'kthread_arg'
Sorry, this patch was in error. (I learned about the IA64-only clone2 syscall too late.) Please disregard. Thanks! Alex Dowad On 13/03/15 20:14, Alex Dowad wrote: 'user_stack_size' is very misleading, since the argument is never used for the size of the user stack. Rather, it is an argument which is passed to the main function executed by a newly forked kernel thread. Hence, rename it to 'kthread_arg'. When forking a new user thread, the kernel thread arg was (uselessly) added to the new user stack pointer. This "worked", since the kernel thread arg is always zero when forking a user thread, but it was obviously not intended. Signed-off-by: Alex Dowad --- arch/ia64/kernel/process.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c index b515149..d4a78da 100644 --- a/arch/ia64/kernel/process.c +++ b/arch/ia64/kernel/process.c @@ -300,7 +300,7 @@ ia64_load_extra (struct task_struct *task) } /* - * Copy the state of an ia-64 thread. + * Copy the architecture-specific state of an ia-64 thread. * * We get here through the following call chain: * @@ -332,7 +332,7 @@ ia64_load_extra (struct task_struct *task) */ int copy_thread(unsigned long clone_flags, -unsigned long user_stack_base, unsigned long user_stack_size, +unsigned long user_stack_base, unsigned long kthread_arg, struct task_struct *p) { extern char ia64_ret_from_clone; @@ -376,13 +376,14 @@ copy_thread(unsigned long clone_flags, ia64_drop_fpu(p); /* don't pick up stale state from a CPU's fph */ if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ if (unlikely(!user_stack_base)) { /* fork_idle() called us */ return 0; } memset(child_stack, 0, sizeof(*child_ptregs) + sizeof(*child_stack)); child_stack->r4 = user_stack_base; /* payload */ - child_stack->r5 = user_stack_size; /* argument */ + child_stack->r5 = kthread_arg; /* * Preserve PSR bits, except for bits 32-34 and 37-45, * which we can't read. @@ -406,6 +407,8 @@ copy_thread(unsigned long clone_flags, return 0; } + + /* user thread */ stack = ((struct switch_stack *) regs) - 1; /* copy parent's switch_stack & pt_regs to child: */ memcpy(child_stack, stack, sizeof(*child_ptregs) + sizeof(*child_stack)); @@ -416,7 +419,7 @@ copy_thread(unsigned long clone_flags, if (clone_flags & CLONE_SETTLS) child_ptregs->r13 = regs->r16;/* see sys_clone2() in entry.S */ if (user_stack_base) { - child_ptregs->r12 = user_stack_base + user_stack_size - 16; + child_ptregs->r12 = user_stack_base - 16; child_ptregs->ar_bspstore = user_stack_base; child_ptregs->ar_rnat = 0; child_ptregs->loadrs = 0; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 01/32] do_fork(): Rename 'stack_size' argument to reflect actual use
On 14/03/15 01:21, David Rientjes wrote: On Fri, 13 Mar 2015, j...@joshtriplett.org wrote: On Fri, Mar 13, 2015 at 08:04:16PM +0200, Alex Dowad wrote: The 'stack_size' argument is never used to pass a stack size. It's only used when forking a kernel thread, in which case it is an argument which should be passed to the 'main' function which the kernel thread executes. Hence, rename it to 'kthread_arg'. That's not the only use of stack_size. Take a look at the clone2 system call (very minimally documented in the clone manpage) and the implementation of copy_thread on ia64, which does use stack_size in the non-kthread path. Exactly, and it seems like Alex just disregarded this early feedback when this was first raised that suggested it just be named "arg" and to comment the individual usage in the functions that get called with the formal. David, just to clarify: your feedback was much appreciated and has not been disregarded. I am still not convinced that "arg" is the best name for the argument now called "stack_start"; I think there must be a better name, but can't think of what it is. If you or others have more suggestions, that would be helpful. Because of the uncertainty, I have avoided modifying that part of the code, and have focused on what seems like a more clear and unequivocal win for readability: renaming the "stack_size" argument. Josh Triplett kindly pointed out that "stack_size" is in fact used for a stack size when processing one particular syscall on one arch. However, rather than naming the args according to that rare case, it seems like a better idea to name them according to the 99.9% case, and add a comment mentioning the 0.1% case. Or maybe "arg1" and "arg2" are really best. If the other maintainers concur with that, I would be happy to rewrite this set of patches accordingly. Again, I appreciate your feedback and hope to receive more (if you have more to give). Thanks, Alex Dowad -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 01/32] do_fork(): Rename 'stack_size' argument to reflect actual use
On 14/03/15 01:04, j...@joshtriplett.org wrote: On Fri, Mar 13, 2015 at 08:04:16PM +0200, Alex Dowad wrote: The 'stack_size' argument is never used to pass a stack size. It's only used when forking a kernel thread, in which case it is an argument which should be passed to the 'main' function which the kernel thread executes. Hence, rename it to 'kthread_arg'. That's not the only use of stack_size. Take a look at the clone2 system call (very minimally documented in the clone manpage) and the implementation of copy_thread on ia64, which does use stack_size in the non-kthread path. Thanks for pointing that out. I searched for all uses with cscope but missed sys_clone2 (which is implemented in asm). Won't make that mistake again... I've just been searching for history on sys_clone2() but have come up empty. "git blame" isn't helping, either... the current code dates back before the start of the git history. So out of curiosity, if you are willing to explain more: why does clone2 only exist on IA-64? Is there some characteristic of the architecture that makes being able to specify the size of the user-mode stack especially valuable, as compared to other archs? Is it used much (such as being called from the C library)? Thanks for your feedback, Alex Dowad -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 01/32] do_fork(): Rename 'stack_size' argument to reflect actual use
On 14/03/15 01:21, David Rientjes wrote: On Fri, 13 Mar 2015, j...@joshtriplett.org wrote: On Fri, Mar 13, 2015 at 08:04:16PM +0200, Alex Dowad wrote: The 'stack_size' argument is never used to pass a stack size. It's only used when forking a kernel thread, in which case it is an argument which should be passed to the 'main' function which the kernel thread executes. Hence, rename it to 'kthread_arg'. That's not the only use of stack_size. Take a look at the clone2 system call (very minimally documented in the clone manpage) and the implementation of copy_thread on ia64, which does use stack_size in the non-kthread path. Exactly, and it seems like Alex just disregarded this early feedback when this was first raised that suggested it just be named arg and to comment the individual usage in the functions that get called with the formal. David, just to clarify: your feedback was much appreciated and has not been disregarded. I am still not convinced that arg is the best name for the argument now called stack_start; I think there must be a better name, but can't think of what it is. If you or others have more suggestions, that would be helpful. Because of the uncertainty, I have avoided modifying that part of the code, and have focused on what seems like a more clear and unequivocal win for readability: renaming the stack_size argument. Josh Triplett kindly pointed out that stack_size is in fact used for a stack size when processing one particular syscall on one arch. However, rather than naming the args according to that rare case, it seems like a better idea to name them according to the 99.9% case, and add a comment mentioning the 0.1% case. Or maybe arg1 and arg2 are really best. If the other maintainers concur with that, I would be happy to rewrite this set of patches accordingly. Again, I appreciate your feedback and hope to receive more (if you have more to give). Thanks, Alex Dowad -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 01/32] do_fork(): Rename 'stack_size' argument to reflect actual use
On 14/03/15 01:04, j...@joshtriplett.org wrote: On Fri, Mar 13, 2015 at 08:04:16PM +0200, Alex Dowad wrote: The 'stack_size' argument is never used to pass a stack size. It's only used when forking a kernel thread, in which case it is an argument which should be passed to the 'main' function which the kernel thread executes. Hence, rename it to 'kthread_arg'. That's not the only use of stack_size. Take a look at the clone2 system call (very minimally documented in the clone manpage) and the implementation of copy_thread on ia64, which does use stack_size in the non-kthread path. Thanks for pointing that out. I searched for all uses with cscope but missed sys_clone2 (which is implemented in asm). Won't make that mistake again... I've just been searching for history on sys_clone2() but have come up empty. git blame isn't helping, either... the current code dates back before the start of the git history. So out of curiosity, if you are willing to explain more: why does clone2 only exist on IA-64? Is there some characteristic of the architecture that makes being able to specify the size of the user-mode stack especially valuable, as compared to other archs? Is it used much (such as being called from the C library)? Thanks for your feedback, Alex Dowad -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 13/32] ia64: copy_thread(): rename 'user_stack_size' argument to 'kthread_arg'
Sorry, this patch was in error. (I learned about the IA64-only clone2 syscall too late.) Please disregard. Thanks! Alex Dowad On 13/03/15 20:14, Alex Dowad wrote: 'user_stack_size' is very misleading, since the argument is never used for the size of the user stack. Rather, it is an argument which is passed to the main function executed by a newly forked kernel thread. Hence, rename it to 'kthread_arg'. When forking a new user thread, the kernel thread arg was (uselessly) added to the new user stack pointer. This worked, since the kernel thread arg is always zero when forking a user thread, but it was obviously not intended. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/ia64/kernel/process.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c index b515149..d4a78da 100644 --- a/arch/ia64/kernel/process.c +++ b/arch/ia64/kernel/process.c @@ -300,7 +300,7 @@ ia64_load_extra (struct task_struct *task) } /* - * Copy the state of an ia-64 thread. + * Copy the architecture-specific state of an ia-64 thread. * * We get here through the following call chain: * @@ -332,7 +332,7 @@ ia64_load_extra (struct task_struct *task) */ int copy_thread(unsigned long clone_flags, -unsigned long user_stack_base, unsigned long user_stack_size, +unsigned long user_stack_base, unsigned long kthread_arg, struct task_struct *p) { extern char ia64_ret_from_clone; @@ -376,13 +376,14 @@ copy_thread(unsigned long clone_flags, ia64_drop_fpu(p); /* don't pick up stale state from a CPU's fph */ if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ if (unlikely(!user_stack_base)) { /* fork_idle() called us */ return 0; } memset(child_stack, 0, sizeof(*child_ptregs) + sizeof(*child_stack)); child_stack-r4 = user_stack_base; /* payload */ - child_stack-r5 = user_stack_size; /* argument */ + child_stack-r5 = kthread_arg; /* * Preserve PSR bits, except for bits 32-34 and 37-45, * which we can't read. @@ -406,6 +407,8 @@ copy_thread(unsigned long clone_flags, return 0; } + + /* user thread */ stack = ((struct switch_stack *) regs) - 1; /* copy parent's switch_stack pt_regs to child: */ memcpy(child_stack, stack, sizeof(*child_ptregs) + sizeof(*child_stack)); @@ -416,7 +419,7 @@ copy_thread(unsigned long clone_flags, if (clone_flags CLONE_SETTLS) child_ptregs-r13 = regs-r16;/* see sys_clone2() in entry.S */ if (user_stack_base) { - child_ptregs-r12 = user_stack_base + user_stack_size - 16; + child_ptregs-r12 = user_stack_base - 16; child_ptregs-ar_bspstore = user_stack_base; child_ptregs-ar_rnat = 0; child_ptregs-loadrs = 0; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 17/32] microblaze: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/microblaze/kernel/process.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c index b2dd371..d4ecb98 100644 --- a/arch/microblaze/kernel/process.c +++ b/arch/microblaze/kernel/process.c @@ -51,20 +51,22 @@ void flush_thread(void) { } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); struct thread_info *ti = task_thread_info(p); if (unlikely(p->flags & PF_KTHREAD)) { - /* if we're creating a new kernel thread then just zeroing all -* the registers. That's OK for a brand new thread.*/ + /* kernel thread: just zero all the registers */ memset(childregs, 0, sizeof(struct pt_regs)); memset(>cpu_context, 0, sizeof(struct cpu_context)); ti->cpu_context.r1 = (unsigned long)childregs; ti->cpu_context.r20 = (unsigned long)usp; /* fn */ - ti->cpu_context.r19 = (unsigned long)arg; + ti->cpu_context.r19 = kthread_arg; childregs->pt_mode = 1; local_save_flags(childregs->msr); #ifdef CONFIG_MMU @@ -73,6 +75,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, ti->cpu_context.r15 = (unsigned long)ret_from_kernel_thread - 8; return 0; } + + /* user thread */ *childregs = *current_pt_regs(); if (usp) childregs->r1 = usp; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 21/32] openrisc: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/openrisc/kernel/process.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c index 386af25..59098c4 100644 --- a/arch/openrisc/kernel/process.c +++ b/arch/openrisc/kernel/process.c @@ -114,7 +114,7 @@ extern asmlinkage void ret_from_fork(void); * copy_thread * @clone_flags: flags * @usp: user stack pointer or fn for kernel thread - * @arg: arg to fn for kernel thread; always NULL for userspace thread + * @kthread_arg: arg to fn for kernel thread; always NULL for userspace thread * @p: the newly created task * @regs: CPU context to copy for userspace thread; always NULL for kthread * @@ -140,10 +140,9 @@ extern asmlinkage void ret_from_fork(void); * below); ret_from_fork will then continue its execution causing the * 'kernel thread' to return to userspace as a userspace thread. */ - int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *userregs; struct pt_regs *kregs; @@ -165,10 +164,12 @@ copy_thread(unsigned long clone_flags, unsigned long usp, kregs = (struct pt_regs *)sp; if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ memset(kregs, 0, sizeof(struct pt_regs)); kregs->gpr[20] = usp; /* fn, kernel thread */ - kregs->gpr[22] = arg; + kregs->gpr[22] = kthread_arg; } else { + /* user thread */ *userregs = *current_pt_regs(); if (usp) -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 19/32] mn10300: copy_thread(): rename 'ustk_size' argument to 'kthread_arg'
'ustk_size' is misleading, since this argument is never used for a user stack size. Rather, it is an argument passed to the main function executed by a new kernel thread. Therefore, rename it to 'kthread_arg'. Signed-off-by: Alex Dowad --- arch/mn10300/kernel/process.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c index 3707da5..d08a9b1 100644 --- a/arch/mn10300/kernel/process.c +++ b/arch/mn10300/kernel/process.c @@ -137,11 +137,10 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) } /* - * set up the kernel stack for a new thread and copy arch-specific thread - * control information + * Copy architecture-specific thread state */ int copy_thread(unsigned long clone_flags, - unsigned long c_usp, unsigned long ustk_size, + unsigned long c_usp, unsigned long kthread_arg, struct task_struct *p) { struct thread_info *ti = task_thread_info(p); @@ -164,14 +163,17 @@ int copy_thread(unsigned long clone_flags, p->thread.usp = c_usp; if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ memset(c_regs, 0, sizeof(struct pt_regs)); c_regs->a0 = c_usp; /* function */ - c_regs->d0 = ustk_size; /* argument */ + c_regs->d0 = kthread_arg; local_save_flags(c_regs->epsw); c_regs->epsw |= EPSW_IE | EPSW_IM_7; p->thread.pc= (unsigned long) ret_from_kernel_thread; return 0; } + + /* user thread */ *c_regs = *current_pt_regs(); if (c_usp) c_regs->sp = c_usp; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 14/32] m32r: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/m32r/kernel/process.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/m32r/kernel/process.c b/arch/m32r/kernel/process.c index e69221d..6d5edf2 100644 --- a/arch/m32r/kernel/process.c +++ b/arch/m32r/kernel/process.c @@ -128,21 +128,25 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu) return 0; /* Task didn't use the fpu at all. */ } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long spu, - unsigned long arg, struct task_struct *tsk) + unsigned long kthread_arg, struct task_struct *tsk) { struct pt_regs *childregs = task_pt_regs(tsk); extern void ret_from_fork(void); extern void ret_from_kernel_thread(void); if (unlikely(tsk->flags & PF_KTHREAD)) { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); childregs->psw = M32R_PSW_BIE; childregs->r1 = spu;/* fn */ - childregs->r0 = arg; + childregs->r0 = kthread_arg; tsk->thread.lr = (unsigned long)ret_from_kernel_thread; } else { - /* Copy registers */ + /* user thread: copy registers */ *childregs = *current_pt_regs(); if (spu) childregs->spu = spu; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 29/32] um: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/um/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index f17bca8..80ac9fe 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c @@ -149,8 +149,11 @@ void fork_handler(void) userspace(>thread.regs.regs); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long sp, - unsigned long arg, struct task_struct * p) + unsigned long kthread_arg, struct task_struct *p) { void (*handler)(void); int kthread = current->flags & PF_KTHREAD; @@ -159,6 +162,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p->thread = (struct thread_struct) INIT_THREAD; if (!kthread) { + /* user thread */ memcpy(>thread.regs.regs, current_pt_regs(), sizeof(p->thread.regs.regs)); PT_REGS_SET_SYSCALL_RETURN(>thread.regs, 0); @@ -169,9 +173,10 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, arch_copy_thread(>thread.arch, >thread.arch); } else { + /* kernel thread */ get_safe_registers(p->thread.regs.regs.gp, p->thread.regs.regs.fp); p->thread.request.u.thread.proc = (int (*)(void *))sp; - p->thread.request.u.thread.arg = (void *)arg; + p->thread.request.u.thread.arg = (void *)kthread_arg; handler = new_thread_handler; } -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 30/32] unicore32: copy_thread(): rename 'stk_sz' argument to 'kthread_arg'
'stk_sz' is misleading, since this argument is never used for a stack size. Rather, it is an argument passed to the main function executed by a new kernel thread. Therefore, rename it to 'kthread_arg'. Signed-off-by: Alex Dowad --- arch/unicore32/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/unicore32/kernel/process.c b/arch/unicore32/kernel/process.c index b008e99..11e19e0 100644 --- a/arch/unicore32/kernel/process.c +++ b/arch/unicore32/kernel/process.c @@ -227,9 +227,12 @@ void release_thread(struct task_struct *dead_task) asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread"); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long stack_start, - unsigned long stk_sz, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *thread = task_thread_info(p); struct pt_regs *childregs = task_pt_regs(p); @@ -237,11 +240,13 @@ copy_thread(unsigned long clone_flags, unsigned long stack_start, memset(>cpu_context, 0, sizeof(struct cpu_context_save)); thread->cpu_context.sp = (unsigned long)childregs; if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ thread->cpu_context.pc = (unsigned long)ret_from_kernel_thread; thread->cpu_context.r4 = stack_start; - thread->cpu_context.r5 = stk_sz; + thread->cpu_context.r5 = kthread_arg; memset(childregs, 0, sizeof(struct pt_regs)); } else { + /* user thread */ thread->cpu_context.pc = (unsigned long)ret_from_fork; *childregs = *current_pt_regs(); childregs->UCreg_00 = 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 27/32] sparc: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/sparc/kernel/process_32.c | 10 -- arch/sparc/kernel/process_64.c | 6 -- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c index 50e7b62..ba6492f 100644 --- a/arch/sparc/kernel/process_32.c +++ b/arch/sparc/kernel/process_32.c @@ -305,8 +305,11 @@ asmlinkage int sparc_do_fork(unsigned long clone_flags, extern void ret_from_fork(void); extern void ret_from_kernel_thread(void); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long sp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *ti = task_thread_info(p); struct pt_regs *childregs, *regs = current_pt_regs(); @@ -343,6 +346,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p->thread.kregs = childregs; if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ extern int nwindows; unsigned long psr; memset(new_stack, 0, STACKFRAME_SZ + TRACEREG_SZ); @@ -350,12 +354,14 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p->thread.current_ds = KERNEL_DS; ti->kpc = (((unsigned long) ret_from_kernel_thread) - 0x8); childregs->u_regs[UREG_G1] = sp; /* function */ - childregs->u_regs[UREG_G2] = arg; + childregs->u_regs[UREG_G2] = kthread_arg; psr = childregs->psr = get_psr(); ti->kpsr = psr | PSR_PIL; ti->kwim = 1 << (((psr & PSR_CWP) + 1) % nwindows); return 0; } + + /* user thread */ memcpy(new_stack, (char *)regs - STACKFRAME_SZ, STACKFRAME_SZ + TRACEREG_SZ); childregs->u_regs[UREG_FP] = sp; p->thread.flags &= ~SPARC_FLAG_KTHREAD; diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c index 0be7bf9..3f203c8 100644 --- a/arch/sparc/kernel/process_64.c +++ b/arch/sparc/kernel/process_64.c @@ -613,7 +613,7 @@ asmlinkage long sparc_do_fork(unsigned long clone_flags, * Child --> %o0 == parents pid, %o1 == 1 */ int copy_thread(unsigned long clone_flags, unsigned long sp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *t = task_thread_info(p); struct pt_regs *regs = current_pt_regs(); @@ -633,15 +633,17 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, t->fpsaved[0] = 0; if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ memset(child_trap_frame, 0, child_stack_sz); __thread_flag_byte_ptr(t)[TI_FLAG_BYTE_CWP] = (current_pt_regs()->tstate + 1) & TSTATE_CWP; t->current_ds = ASI_P; t->kregs->u_regs[UREG_G1] = sp; /* function */ - t->kregs->u_regs[UREG_G2] = arg; + t->kregs->u_regs[UREG_G2] = kthread_arg; return 0; } + /* user thread */ parent_sf = ((struct sparc_stackf *) regs) - 1; memcpy(child_trap_frame, parent_sf, child_stack_sz); if (t->flags & _TIF_32BIT) { -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 28/32] tile: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/tile/kernel/process.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c index 48e5773..bff52e4 100644 --- a/arch/tile/kernel/process.c +++ b/arch/tile/kernel/process.c @@ -97,8 +97,11 @@ void arch_release_thread_info(struct thread_info *info) static void save_arch_state(struct thread_struct *t); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long sp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); unsigned long ksp; @@ -130,15 +133,15 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, memset(_regs[2], 0, (CALLEE_SAVED_REGS_COUNT - 2) * sizeof(unsigned long)); callee_regs[0] = sp; /* r30 = function */ - callee_regs[1] = arg; /* r31 = arg */ + callee_regs[1] = kthread_arg; /* r31 = arg */ childregs->ex1 = PL_ICS_EX1(KERNEL_PL, 0); p->thread.pc = (unsigned long) ret_from_kernel_thread; return 0; } /* -* Start new thread in ret_from_fork so it schedules properly -* and then return from interrupt like the parent. +* user thread: start in ret_from_fork so it schedules properly +* and then returns from interrupt like the parent. */ p->thread.pc = (unsigned long) ret_from_fork; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 25/32] score: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/score/kernel/process.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c index a1519ad3..a72d15f 100644 --- a/arch/score/kernel/process.c +++ b/arch/score/kernel/process.c @@ -66,10 +66,10 @@ void exit_thread(void) {} void flush_thread(void) {} /* - * set up the kernel stack and exception frames for a new process + * Copy architecture-specific thread state */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *ti = task_thread_info(p); struct pt_regs *childregs = task_pt_regs(p); @@ -77,11 +77,13 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, p->thread.reg0 = (unsigned long) childregs; if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); p->thread.reg12 = usp; - p->thread.reg13 = arg; + p->thread.reg13 = kthread_arg; p->thread.reg3 = (unsigned long) ret_from_kernel_thread; } else { + /* user thread */ *childregs = *current_pt_regs(); childregs->regs[7] = 0; /* Clear error flag */ childregs->regs[4] = 0; /* Child gets zero as return value */ -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 23/32] powerpc: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/powerpc/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index b4cc7be..febb50d 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -1114,8 +1114,11 @@ static void setup_ksp_vsid(struct task_struct *p, unsigned long sp) */ extern unsigned long dscr_default; /* defined in arch/powerpc/kernel/sysfs.c */ +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs, *kregs; extern void ret_from_fork(void); @@ -1127,6 +1130,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, sp -= sizeof(struct pt_regs); childregs = (struct pt_regs *) sp; if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ struct thread_info *ti = (void *)task_stack_page(p); memset(childregs, 0, sizeof(struct pt_regs)); childregs->gpr[1] = sp + sizeof(struct pt_regs); @@ -1137,11 +1141,12 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, clear_tsk_thread_flag(p, TIF_32BIT); childregs->softe = 1; #endif - childregs->gpr[15] = arg; + childregs->gpr[15] = kthread_arg; p->thread.regs = NULL; /* no user register state */ ti->flags |= _TIF_RESTOREALL; f = ret_from_kernel_thread; } else { + /* user thread */ struct pt_regs *regs = current_pt_regs(); CHECK_FULL_REGS(regs); *childregs = *regs; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 31/32] x86: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/x86/kernel/process_32.c | 9 +++-- arch/x86/kernel/process_64.c | 9 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index 603c4f9..efb4a6b 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -129,8 +129,11 @@ void release_thread(struct task_struct *dead_task) release_vm86_irqs(dead_task); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long sp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); struct task_struct *tsk; @@ -149,13 +152,15 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, childregs->es = __USER_DS; childregs->fs = __KERNEL_PERCPU; childregs->bx = sp; /* function */ - childregs->bp = arg; + childregs->bp = kthread_arg; childregs->orig_ax = -1; childregs->cs = __KERNEL_CS | get_kernel_rpl(); childregs->flags = X86_EFLAGS_IF | X86_EFLAGS_FIXED; p->thread.io_bitmap_ptr = NULL; return 0; } + + /* user thread */ *childregs = *current_pt_regs(); childregs->ax = 0; if (sp) diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 67fcc43..a27abb6 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -151,8 +151,11 @@ static inline u32 read_32bit_tls(struct task_struct *t, int tls) return get_desc_base(>thread.tls_array[tls]); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long sp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { int err; struct pt_regs *childregs; @@ -179,12 +182,14 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, childregs->sp = (unsigned long)childregs; childregs->ss = __KERNEL_DS; childregs->bx = sp; /* function */ - childregs->bp = arg; + childregs->bp = kthread_arg; childregs->orig_ax = -1; childregs->cs = __KERNEL_CS | get_kernel_rpl(); childregs->flags = X86_EFLAGS_IF | X86_EFLAGS_FIXED; return 0; } + + /* user thread */ *childregs = *current_pt_regs(); childregs->ax = 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 32/32] xtensa: copy_thread(): rename 'arg' argument to 'kthread_arg'
Rename the 'thread_fn_arg' it to 'kthread_arg' for consistency with do_fork() and other arch-specific implementations of copy_thread(). Signed-off-by: Alex Dowad --- arch/xtensa/kernel/process.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c index 1c85323..b12f5dc 100644 --- a/arch/xtensa/kernel/process.c +++ b/arch/xtensa/kernel/process.c @@ -147,7 +147,7 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) } /* - * Copy thread. + * Copy architecture-specific thread state * * There are two modes in which this function is called: * 1) Userspace thread creation, @@ -156,7 +156,7 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) *in the clone_flags) and set up passed usp in the childregs. * 2) Kernel thread creation, *regs == NULL, usp_thread_fn is the function to run in the new thread - *and thread_fn_arg is its parameter. + *and kthread_arg is its parameter. *childregs are not used for the kernel threads. * * The stack layout for the new thread looks like this: @@ -187,9 +187,8 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) * One solution is to spill windows to the parent stack, but that's fairly * involved. Much simpler to just not copy those live frames across. */ - int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn, - unsigned long thread_fn_arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); @@ -204,6 +203,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn, p->thread.sp = (unsigned long)childregs; if (!(p->flags & PF_KTHREAD)) { + /* user thread */ struct pt_regs *regs = current_pt_regs(); unsigned long usp = usp_thread_fn ? usp_thread_fn : regs->areg[1]; @@ -254,13 +254,14 @@ int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn, if (clone_flags & CLONE_SETTLS) childregs->threadptr = childregs->areg[5]; } else { + /* kernel thread */ p->thread.ra = MAKE_RA_FOR_CALL( (unsigned long)ret_from_kernel_thread, 1); /* pass parameters to ret_from_kernel_thread: * a2 = thread_fn, a3 = thread_fn arg */ - *((int *)childregs - 1) = thread_fn_arg; + *((int *)childregs - 1) = kthread_arg; *((int *)childregs - 2) = usp_thread_fn; /* Childregs are only used when we're going to userspace -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 26/32] sh: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/sh/kernel/process_32.c | 10 -- arch/sh/kernel/process_64.c | 12 +--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/sh/kernel/process_32.c b/arch/sh/kernel/process_32.c index 2885fc9..fded1b4 100644 --- a/arch/sh/kernel/process_32.c +++ b/arch/sh/kernel/process_32.c @@ -123,8 +123,11 @@ EXPORT_SYMBOL(dump_fpu); asmlinkage void ret_from_fork(void); asmlinkage void ret_from_kernel_thread(void); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *ti = task_thread_info(p); struct pt_regs *childregs; @@ -146,9 +149,10 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, childregs = task_pt_regs(p); p->thread.sp = (unsigned long) childregs; if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); p->thread.pc = (unsigned long) ret_from_kernel_thread; - childregs->regs[4] = arg; + childregs->regs[4] = kthread_arg; childregs->regs[5] = usp; childregs->sr = SR_MD; #if defined(CONFIG_SH_FPU) @@ -159,6 +163,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, p->thread.fpu_counter = 0; return 0; } + + /* user thread */ *childregs = *current_pt_regs(); if (usp) diff --git a/arch/sh/kernel/process_64.c b/arch/sh/kernel/process_64.c index e2062e6..693105d 100644 --- a/arch/sh/kernel/process_64.c +++ b/arch/sh/kernel/process_64.c @@ -371,8 +371,11 @@ EXPORT_SYMBOL(dump_fpu); asmlinkage void ret_from_fork(void); asmlinkage void ret_from_kernel_thread(void); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs; @@ -391,14 +394,17 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, p->thread.sp = (unsigned long) childregs; if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); - childregs->regs[2] = (unsigned long)arg; - childregs->regs[3] = (unsigned long)usp; + childregs->regs[2] = kthread_arg; + childregs->regs[3] = usp; childregs->sr = (1 << 30); /* not user_mode */ childregs->sr |= SR_FD; /* Invalidate FPU flag */ p->thread.pc = (unsigned long) ret_from_kernel_thread; return 0; } + + /* user thread */ *childregs = *current_pt_regs(); /* -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 16/32] metag: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/metag/kernel/process.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/metag/kernel/process.c b/arch/metag/kernel/process.c index 483dff9..dcb4609 100644 --- a/arch/metag/kernel/process.c +++ b/arch/metag/kernel/process.c @@ -174,8 +174,11 @@ void show_regs(struct pt_regs *regs) show_trace(NULL, (unsigned long *)regs->ctx.AX[0].U0, regs); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *tsk) + unsigned long kthread_arg, struct task_struct *tsk) { struct pt_regs *childregs = task_pt_regs(tsk); void *kernel_context = ((void *) childregs + @@ -204,10 +207,11 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, childregs->ctx.AX[0].U0 = (unsigned long) kernel_context; /* Set D1Ar1=arg and D1RtP=usp (fn) */ childregs->ctx.DX[4].U1 = usp; - childregs->ctx.DX[3].U1 = arg; + childregs->ctx.DX[3].U1 = kthread_arg; tsk->thread.int_depth = 2; return 0; } + /* * Get a pointer to where the new child's register block should have * been pushed. -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 18/32] mips: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/mips/kernel/process.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index bf85cc1..d295bd1 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -107,8 +107,11 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) return 0; } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *ti = task_thread_info(p); struct pt_regs *childregs, *regs = current_pt_regs(); @@ -123,11 +126,12 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, childksp = (unsigned long) childregs; p->thread.cp0_status = read_c0_status() & ~(ST0_CU2|ST0_CU1); if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ unsigned long status = p->thread.cp0_status; memset(childregs, 0, sizeof(struct pt_regs)); ti->addr_limit = KERNEL_DS; p->thread.reg16 = usp; /* fn */ - p->thread.reg17 = arg; + p->thread.reg17 = kthread_arg; p->thread.reg29 = childksp; p->thread.reg31 = (unsigned long) ret_from_kernel_thread; #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX) @@ -139,6 +143,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, childregs->cp0_status = status; return 0; } + + /* user thread */ *childregs = *regs; childregs->regs[7] = 0; /* Clear error flag */ childregs->regs[2] = 0; /* Child gets zero as return value */ -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 11/32] frv: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/frv/kernel/process.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c index 5d40aeb77..bca9f55 100644 --- a/arch/frv/kernel/process.c +++ b/arch/frv/kernel/process.c @@ -123,10 +123,10 @@ inline unsigned long user_stack(const struct pt_regs *regs) } /* - * set up the kernel stack and exception frames for a new process + * Copy architecture-specific thread state */ int copy_thread(unsigned long clone_flags, - unsigned long usp, unsigned long arg, + unsigned long usp, unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs; @@ -145,8 +145,9 @@ int copy_thread(unsigned long clone_flags, p->thread.frame0 = childregs; if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ childregs->gr9 = usp; /* function */ - childregs->gr8 = arg; + childregs->gr8 = kthread_arg; p->thread.pc = (unsigned long) ret_from_kernel_thread; save_user_regs(p->thread.user); return 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 13/32] ia64: copy_thread(): rename 'user_stack_size' argument to 'kthread_arg'
'user_stack_size' is very misleading, since the argument is never used for the size of the user stack. Rather, it is an argument which is passed to the main function executed by a newly forked kernel thread. Hence, rename it to 'kthread_arg'. When forking a new user thread, the kernel thread arg was (uselessly) added to the new user stack pointer. This "worked", since the kernel thread arg is always zero when forking a user thread, but it was obviously not intended. Signed-off-by: Alex Dowad --- arch/ia64/kernel/process.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c index b515149..d4a78da 100644 --- a/arch/ia64/kernel/process.c +++ b/arch/ia64/kernel/process.c @@ -300,7 +300,7 @@ ia64_load_extra (struct task_struct *task) } /* - * Copy the state of an ia-64 thread. + * Copy the architecture-specific state of an ia-64 thread. * * We get here through the following call chain: * @@ -332,7 +332,7 @@ ia64_load_extra (struct task_struct *task) */ int copy_thread(unsigned long clone_flags, -unsigned long user_stack_base, unsigned long user_stack_size, +unsigned long user_stack_base, unsigned long kthread_arg, struct task_struct *p) { extern char ia64_ret_from_clone; @@ -376,13 +376,14 @@ copy_thread(unsigned long clone_flags, ia64_drop_fpu(p); /* don't pick up stale state from a CPU's fph */ if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ if (unlikely(!user_stack_base)) { /* fork_idle() called us */ return 0; } memset(child_stack, 0, sizeof(*child_ptregs) + sizeof(*child_stack)); child_stack->r4 = user_stack_base; /* payload */ - child_stack->r5 = user_stack_size; /* argument */ + child_stack->r5 = kthread_arg; /* * Preserve PSR bits, except for bits 32-34 and 37-45, * which we can't read. @@ -406,6 +407,8 @@ copy_thread(unsigned long clone_flags, return 0; } + + /* user thread */ stack = ((struct switch_stack *) regs) - 1; /* copy parent's switch_stack & pt_regs to child: */ memcpy(child_stack, stack, sizeof(*child_ptregs) + sizeof(*child_stack)); @@ -416,7 +419,7 @@ copy_thread(unsigned long clone_flags, if (clone_flags & CLONE_SETTLS) child_ptregs->r13 = regs->r16; /* see sys_clone2() in entry.S */ if (user_stack_base) { - child_ptregs->r12 = user_stack_base + user_stack_size - 16; + child_ptregs->r12 = user_stack_base - 16; child_ptregs->ar_bspstore = user_stack_base; child_ptregs->ar_rnat = 0; child_ptregs->loadrs = 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 12/32] hexagon: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/hexagon/kernel/process.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/hexagon/kernel/process.c b/arch/hexagon/kernel/process.c index 0a0dd5c..6f27358 100644 --- a/arch/hexagon/kernel/process.c +++ b/arch/hexagon/kernel/process.c @@ -71,7 +71,7 @@ unsigned long thread_saved_pc(struct task_struct *tsk) * Copy architecture-specific thread state */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *ti = task_thread_info(p); struct hexagon_switch_stack *ss; @@ -94,10 +94,11 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, ss->lr = (unsigned long)ret_from_fork; p->thread.switch_sp = ss; if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); /* r24 <- fn, r25 <- arg */ ss->r24 = usp; - ss->r25 = arg; + ss->r25 = kthread_arg; pt_set_kmode(childregs); return 0; } -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 15/32] m68k: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/m68k/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c index c55ff71..92bf7b4 100644 --- a/arch/m68k/kernel/process.c +++ b/arch/m68k/kernel/process.c @@ -129,8 +129,11 @@ asmlinkage int m68k_clone(struct pt_regs *regs) (int __user *)regs->d3, (int __user *)regs->d4); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, -unsigned long arg, struct task_struct *p) +unsigned long kthread_arg, struct task_struct *p) { struct fork_frame { struct switch_stack sw; @@ -153,11 +156,13 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, memset(frame, 0, sizeof(struct fork_frame)); frame->regs.sr = PS_S; frame->sw.a3 = usp; /* function */ - frame->sw.d7 = arg; + frame->sw.d7 = kthread_arg; frame->sw.retpc = (unsigned long)ret_from_kernel_thread; p->thread.usp = 0; return 0; } + + /* user thread */ memcpy(frame, container_of(current_pt_regs(), struct fork_frame, regs), sizeof(struct fork_frame)); frame->regs.d0 = 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 20/32] nios2: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/nios2/kernel/process.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/nios2/kernel/process.c b/arch/nios2/kernel/process.c index 0e075b5..f5a0e28 100644 --- a/arch/nios2/kernel/process.c +++ b/arch/nios2/kernel/process.c @@ -97,8 +97,12 @@ void flush_thread(void) set_fs(USER_DS); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, - unsigned long usp, unsigned long arg, struct task_struct *p) + unsigned long usp, unsigned long kthread_arg, + struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); struct pt_regs *regs; @@ -107,11 +111,12 @@ int copy_thread(unsigned long clone_flags, ((struct switch_stack *)childregs) - 1; if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ memset(childstack, 0, sizeof(struct switch_stack) + sizeof(struct pt_regs)); childstack->r16 = usp; /* fn */ - childstack->r17 = arg; + childstack->r17 = kthread_arg; childstack->ra = (unsigned long) ret_from_kernel_thread; childregs->estatus = STATUS_PIE; childregs->sp = (unsigned long) childstack; @@ -121,6 +126,7 @@ int copy_thread(unsigned long clone_flags, return 0; } + /* user thread */ regs = current_pt_regs(); *childregs = *regs; childregs->r2 = 0; /* Set the return value for the child. */ -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 24/32] s390: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/s390/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c index 13fc097..a1ca7cf 100644 --- a/arch/s390/kernel/process.c +++ b/arch/s390/kernel/process.c @@ -87,8 +87,11 @@ void arch_release_task_struct(struct task_struct *tsk) } #endif +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long new_stackp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *ti; struct fake_frame @@ -127,12 +130,14 @@ int copy_thread(unsigned long clone_flags, unsigned long new_stackp, frame->childregs.psw.addr = PSW_ADDR_AMODE | (unsigned long) kernel_thread_starter; frame->childregs.gprs[9] = new_stackp; /* function */ - frame->childregs.gprs[10] = arg; + frame->childregs.gprs[10] = kthread_arg; frame->childregs.gprs[11] = (unsigned long) do_exit; frame->childregs.orig_gpr2 = -1; return 0; } + + /* user thread */ frame->childregs = *current_pt_regs(); frame->childregs.gprs[2] = 0; /* child returns 0 on fork. */ frame->childregs.flags = 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 22/32] parisc: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/parisc/kernel/process.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c index 8a488c2..809905a 100644 --- a/arch/parisc/kernel/process.c +++ b/arch/parisc/kernel/process.c @@ -181,9 +181,12 @@ int dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *r) return 1; } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *cregs = &(p->thread.regs); void *stack = task_stack_page(p); @@ -195,11 +198,10 @@ copy_thread(unsigned long clone_flags, unsigned long usp, extern void * const child_return; if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ memset(cregs, 0, sizeof(struct pt_regs)); if (!usp) /* idle thread */ return 0; - - /* kernel thread */ /* Must exit via ret_from_kernel_thread in order * to call schedule_tail() */ @@ -215,7 +217,7 @@ copy_thread(unsigned long clone_flags, unsigned long usp, #else cregs->gr[26] = usp; #endif - cregs->gr[25] = arg; + cregs->gr[25] = kthread_arg; } else { /* user thread */ /* usp must be word aligned. This also prevents users from -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 10/32] cris/arch-v32: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/cris/arch-v32/kernel/process.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/cris/arch-v32/kernel/process.c b/arch/cris/arch-v32/kernel/process.c index cebd32e..dc55e6c 100644 --- a/arch/cris/arch-v32/kernel/process.c +++ b/arch/cris/arch-v32/kernel/process.c @@ -101,9 +101,12 @@ unsigned long thread_saved_pc(struct task_struct *t) extern asmlinkage void ret_from_fork(void); extern asmlinkage void ret_from_kernel_thread(void); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); struct switch_stack *swstack = ((struct switch_stack *) childregs) - 1; @@ -114,10 +117,11 @@ copy_thread(unsigned long clone_flags, unsigned long usp, * task. */ if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ memset(swstack, 0, sizeof(struct switch_stack) + sizeof(struct pt_regs)); swstack->r1 = usp; - swstack->r2 = arg; + swstack->r2 = kthread_arg; childregs->ccs = 1 << (I_CCS_BITNR + CCS_SHIFT); swstack->return_ip = (unsigned long) ret_from_kernel_thread; p->thread.ksp = (unsigned long) swstack; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 07/32] blackfin: copy_thread(): rename 'topstk' argument to 'kthread_arg'
'topstk' is a misnomer: it is not a pointer to the top of a stack. Rather, it is an argument passed to the main function executed by a new kernel thread. Signed-off-by: Alex Dowad --- arch/blackfin/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/blackfin/kernel/process.c b/arch/blackfin/kernel/process.c index 4aa5545..81cdd5f 100644 --- a/arch/blackfin/kernel/process.c +++ b/arch/blackfin/kernel/process.c @@ -109,9 +109,12 @@ asmlinkage int bfin_clone(unsigned long clone_flags, unsigned long newsp) return do_fork(clone_flags, newsp, 0, NULL, NULL); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, - unsigned long usp, unsigned long topstk, + unsigned long usp, unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs; @@ -120,14 +123,16 @@ copy_thread(unsigned long clone_flags, childregs = (struct pt_regs *) (task_stack_page(p) + THREAD_SIZE) - 1; v = ((unsigned long *)childregs) - 2; if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); v[0] = usp; - v[1] = topstk; + v[1] = kthread_arg; childregs->orig_p0 = -1; childregs->ipend = 0x8000; __asm__ __volatile__("%0 = syscfg;":"=da"(childregs->syscfg):); p->thread.usp = 0; } else { + /* user thread */ *childregs = *current_pt_regs(); childregs->r0 = 0; p->thread.usp = usp ? : rdusp(); -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 01/32] do_fork(): Rename 'stack_size' argument to reflect actual use
The 'stack_size' argument is never used to pass a stack size. It's only used when forking a kernel thread, in which case it is an argument which should be passed to the 'main' function which the kernel thread executes. Hence, rename it to 'kthread_arg'. Signed-off-by: Alex Dowad --- Hi, The following patches in this series perform a similar cleanup for the arch-specific implementations of copy_thread(). Each patch has been sent to the maintainers for the relevant arch. Thanks, AD kernel/fork.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index cf65139..5a40dfd 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1186,10 +1186,12 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid) * It copies the registers, and all the appropriate * parts of the process environment (as per the clone * flags). The actual kick-off is left to the caller. */ static struct task_struct *copy_process(unsigned long clone_flags, unsigned long stack_start, - unsigned long stack_size, + unsigned long kthread_arg, int __user *child_tidptr, struct pid *pid, int trace) @@ -1401,7 +1403,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, retval = copy_io(clone_flags, p); if (retval) goto bad_fork_cleanup_namespaces; - retval = copy_thread(clone_flags, stack_start, stack_size, p); + retval = copy_thread(clone_flags, stack_start, kthread_arg, p); if (retval) goto bad_fork_cleanup_io; @@ -1630,7 +1632,7 @@ struct task_struct *fork_idle(int cpu) */ long do_fork(unsigned long clone_flags, unsigned long stack_start, - unsigned long stack_size, + unsigned long kthread_arg, int __user *parent_tidptr, int __user *child_tidptr) { @@ -1656,7 +1658,7 @@ long do_fork(unsigned long clone_flags, trace = 0; } - p = copy_process(clone_flags, stack_start, stack_size, + p = copy_process(clone_flags, stack_start, kthread_arg, child_tidptr, NULL, trace); /* * Do this prior waking up the new thread - the thread pointer @@ -1740,7 +1742,7 @@ SYSCALL_DEFINE5(clone, unsigned long, newsp, unsigned long, clone_flags, int, tls_val) #elif defined(CONFIG_CLONE_BACKWARDS3) SYSCALL_DEFINE6(clone, unsigned long, clone_flags, unsigned long, newsp, - int, stack_size, + int, ignored, int __user *, parent_tidptr, int __user *, child_tidptr, int, tls_val) -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 06/32] avr32: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/avr32/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/avr32/kernel/process.c b/arch/avr32/kernel/process.c index 42a53e74..a255bd3 100644 --- a/arch/avr32/kernel/process.c +++ b/arch/avr32/kernel/process.c @@ -279,20 +279,25 @@ asmlinkage void ret_from_fork(void); asmlinkage void ret_from_kernel_thread(void); asmlinkage void syscall_return(void); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); - p->thread.cpu_context.r0 = arg; + p->thread.cpu_context.r0 = kthread_arg; p->thread.cpu_context.r1 = usp; /* fn */ p->thread.cpu_context.r2 = (unsigned long)syscall_return; p->thread.cpu_context.pc = (unsigned long)ret_from_kernel_thread; childregs->sr = MODE_SUPERVISOR; } else { + /* user thread */ *childregs = *current_pt_regs(); if (usp) childregs->sp = usp; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 04/32] arm: copy_thread(): rename 'stk_sz' argument to 'kthread_arg'
'stk_sz' is a misnomer: it is never used for a stack size. Rather, it is an argument which is passed to the main function executed by a kernel thread, when forking a new kthread. The most appropriate name is 'kthread_arg'. Signed-off-by: Alex Dowad --- arch/arm/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index fdfa3a7..4183ebd 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -342,9 +342,12 @@ void release_thread(struct task_struct *dead_task) asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long stack_start, - unsigned long stk_sz, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *thread = task_thread_info(p); struct pt_regs *childregs = task_pt_regs(p); @@ -352,13 +355,15 @@ copy_thread(unsigned long clone_flags, unsigned long stack_start, memset(>cpu_context, 0, sizeof(struct cpu_context_save)); if (likely(!(p->flags & PF_KTHREAD))) { + /* user thread */ *childregs = *current_pt_regs(); childregs->ARM_r0 = 0; if (stack_start) childregs->ARM_sp = stack_start; } else { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); - thread->cpu_context.r4 = stk_sz; + thread->cpu_context.r4 = kthread_arg; thread->cpu_context.r5 = stack_start; childregs->ARM_cpsr = SVC_MODE; } -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 09/32] cris/arch-v10: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/cris/arch-v10/kernel/process.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/cris/arch-v10/kernel/process.c b/arch/cris/arch-v10/kernel/process.c index 02b7834..c8c73d3 100644 --- a/arch/cris/arch-v10/kernel/process.c +++ b/arch/cris/arch-v10/kernel/process.c @@ -94,8 +94,11 @@ unsigned long thread_saved_pc(struct task_struct *t) asmlinkage void ret_from_fork(void); asmlinkage void ret_from_kernel_thread(void); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); struct switch_stack *swstack = ((struct switch_stack *)childregs) - 1; @@ -105,10 +108,11 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, */ if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ memset(swstack, 0, sizeof(struct switch_stack) + sizeof(struct pt_regs)); swstack->r1 = usp; - swstack->r2 = arg; + swstack->r2 = kthread_arg; childregs->dccr = 1 << I_DCCR_BITNR; swstack->return_ip = (unsigned long) ret_from_kernel_thread; p->thread.ksp = (unsigned long) swstack; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 08/32] c6x: copy_thread(): rename 'ustk_size' argument to 'kthread_arg'
'ustk_size' is a misnomer: it is never used for the size of the user stack. It is only used when forking a new kernel thread, as the argument passed to the kthread's main function. Signed-off-by: Alex Dowad --- arch/c6x/kernel/process.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/c6x/kernel/process.c b/arch/c6x/kernel/process.c index 57d2ea8..b519377 100644 --- a/arch/c6x/kernel/process.c +++ b/arch/c6x/kernel/process.c @@ -109,10 +109,10 @@ void start_thread(struct pt_regs *regs, unsigned int pc, unsigned long usp) } /* - * Copy a new thread context in its stack. + * Copy architecture-specific thread state */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long ustk_size, + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs; @@ -125,9 +125,9 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, childregs->sp = (unsigned long)(childregs + 1); p->thread.pc = (unsigned long) ret_from_kernel_thread; childregs->a0 = usp;/* function */ - childregs->a1 = ustk_size; /* argument */ + childregs->a1 = kthread_arg; } else { - /* Otherwise use the given stack */ + /* user thread: use the given stack */ *childregs = *current_pt_regs(); if (usp) childregs->sp = usp; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 03/32] arc: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/arc/kernel/process.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c index fdd8971..cf366bd 100644 --- a/arch/arc/kernel/process.c +++ b/arch/arc/kernel/process.c @@ -49,7 +49,9 @@ void arch_cpu_idle(void) asmlinkage void ret_from_fork(void); -/* Layout of Child kernel mode stack as setup at the end of this function is +/* Copy architecture-specific thread state + * + * Layout of Child kernel mode stack as setup at the end of this function is * * | ...| * | ...| @@ -81,7 +83,7 @@ asmlinkage void ret_from_fork(void); * -- <= END of PAGE */ int copy_thread(unsigned long clone_flags, - unsigned long usp, unsigned long arg, + unsigned long usp, unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *c_regs;/* child's pt_regs */ @@ -110,9 +112,10 @@ int copy_thread(unsigned long clone_flags, childksp[1] = (unsigned long)ret_from_fork; /* blink */ if (unlikely(p->flags & PF_KTHREAD)) { + /* kernel thread */ memset(c_regs, 0, sizeof(struct pt_regs)); - c_callee->r13 = arg; /* argument to kernel thread */ + c_callee->r13 = kthread_arg; c_callee->r14 = usp; /* function */ return 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 05/32] arm64: copy_thread(): rename 'stk_sz' argument to 'kthread_arg'
'stk_sz' is a misnomer: it is never used for a stack size. Rather, it is an argument which is passed to the main function executed by a kernel thread, when forking a new kthread. The most appropriate name is 'kthread_arg'. Signed-off-by: Alex Dowad --- arch/arm64/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index fde9923..734e2b6 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -242,8 +242,11 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) asmlinkage void ret_from_fork(void) asm("ret_from_fork"); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long stack_start, - unsigned long stk_sz, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); unsigned long tls = p->thread.tp_value; @@ -251,6 +254,7 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start, memset(>thread.cpu_context, 0, sizeof(struct cpu_context)); if (likely(!(p->flags & PF_KTHREAD))) { + /* user thread */ *childregs = *current_pt_regs(); childregs->regs[0] = 0; if (is_compat_thread(task_thread_info(p))) { @@ -276,10 +280,11 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start, if (clone_flags & CLONE_SETTLS) tls = childregs->regs[3]; } else { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); childregs->pstate = PSR_MODE_EL1h; p->thread.cpu_context.x19 = stack_start; - p->thread.cpu_context.x20 = stk_sz; + p->thread.cpu_context.x20 = kthread_arg; } p->thread.cpu_context.pc = (unsigned long)ret_from_fork; p->thread.cpu_context.sp = (unsigned long)childregs; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 02/32] alpha: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/alpha/kernel/process.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c index 1941a07..84d1326 100644 --- a/arch/alpha/kernel/process.c +++ b/arch/alpha/kernel/process.c @@ -236,12 +236,11 @@ release_thread(struct task_struct *dead_task) } /* - * Copy an alpha thread.. + * Copy architecture-specific thread state */ - int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, + unsigned long kthread_arg, struct task_struct *p) { extern void ret_from_fork(void); @@ -262,7 +261,7 @@ copy_thread(unsigned long clone_flags, unsigned long usp, sizeof(struct switch_stack) + sizeof(struct pt_regs)); childstack->r26 = (unsigned long) ret_from_kernel_thread; childstack->r9 = usp; /* function */ - childstack->r10 = arg; + childstack->r10 = kthread_arg; childregs->hae = alpha_mv.hae_cache, childti->pcb.usp = 0; return 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 01/32] do_fork(): Rename 'stack_size' argument to reflect actual use
The 'stack_size' argument is never used to pass a stack size. It's only used when forking a kernel thread, in which case it is an argument which should be passed to the 'main' function which the kernel thread executes. Hence, rename it to 'kthread_arg'. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- Hi, The following patches in this series perform a similar cleanup for the arch-specific implementations of copy_thread(). Each patch has been sent to the maintainers for the relevant arch. Thanks, AD kernel/fork.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index cf65139..5a40dfd 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1186,10 +1186,12 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid) * It copies the registers, and all the appropriate * parts of the process environment (as per the clone * flags). The actual kick-off is left to the caller. */ static struct task_struct *copy_process(unsigned long clone_flags, unsigned long stack_start, - unsigned long stack_size, + unsigned long kthread_arg, int __user *child_tidptr, struct pid *pid, int trace) @@ -1401,7 +1403,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, retval = copy_io(clone_flags, p); if (retval) goto bad_fork_cleanup_namespaces; - retval = copy_thread(clone_flags, stack_start, stack_size, p); + retval = copy_thread(clone_flags, stack_start, kthread_arg, p); if (retval) goto bad_fork_cleanup_io; @@ -1630,7 +1632,7 @@ struct task_struct *fork_idle(int cpu) */ long do_fork(unsigned long clone_flags, unsigned long stack_start, - unsigned long stack_size, + unsigned long kthread_arg, int __user *parent_tidptr, int __user *child_tidptr) { @@ -1656,7 +1658,7 @@ long do_fork(unsigned long clone_flags, trace = 0; } - p = copy_process(clone_flags, stack_start, stack_size, + p = copy_process(clone_flags, stack_start, kthread_arg, child_tidptr, NULL, trace); /* * Do this prior waking up the new thread - the thread pointer @@ -1740,7 +1742,7 @@ SYSCALL_DEFINE5(clone, unsigned long, newsp, unsigned long, clone_flags, int, tls_val) #elif defined(CONFIG_CLONE_BACKWARDS3) SYSCALL_DEFINE6(clone, unsigned long, clone_flags, unsigned long, newsp, - int, stack_size, + int, ignored, int __user *, parent_tidptr, int __user *, child_tidptr, int, tls_val) -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 06/32] avr32: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/avr32/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/avr32/kernel/process.c b/arch/avr32/kernel/process.c index 42a53e74..a255bd3 100644 --- a/arch/avr32/kernel/process.c +++ b/arch/avr32/kernel/process.c @@ -279,20 +279,25 @@ asmlinkage void ret_from_fork(void); asmlinkage void ret_from_kernel_thread(void); asmlinkage void syscall_return(void); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); - p-thread.cpu_context.r0 = arg; + p-thread.cpu_context.r0 = kthread_arg; p-thread.cpu_context.r1 = usp; /* fn */ p-thread.cpu_context.r2 = (unsigned long)syscall_return; p-thread.cpu_context.pc = (unsigned long)ret_from_kernel_thread; childregs-sr = MODE_SUPERVISOR; } else { + /* user thread */ *childregs = *current_pt_regs(); if (usp) childregs-sp = usp; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 04/32] arm: copy_thread(): rename 'stk_sz' argument to 'kthread_arg'
'stk_sz' is a misnomer: it is never used for a stack size. Rather, it is an argument which is passed to the main function executed by a kernel thread, when forking a new kthread. The most appropriate name is 'kthread_arg'. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/arm/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index fdfa3a7..4183ebd 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -342,9 +342,12 @@ void release_thread(struct task_struct *dead_task) asmlinkage void ret_from_fork(void) __asm__(ret_from_fork); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long stack_start, - unsigned long stk_sz, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *thread = task_thread_info(p); struct pt_regs *childregs = task_pt_regs(p); @@ -352,13 +355,15 @@ copy_thread(unsigned long clone_flags, unsigned long stack_start, memset(thread-cpu_context, 0, sizeof(struct cpu_context_save)); if (likely(!(p-flags PF_KTHREAD))) { + /* user thread */ *childregs = *current_pt_regs(); childregs-ARM_r0 = 0; if (stack_start) childregs-ARM_sp = stack_start; } else { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); - thread-cpu_context.r4 = stk_sz; + thread-cpu_context.r4 = kthread_arg; thread-cpu_context.r5 = stack_start; childregs-ARM_cpsr = SVC_MODE; } -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 09/32] cris/arch-v10: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/cris/arch-v10/kernel/process.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/cris/arch-v10/kernel/process.c b/arch/cris/arch-v10/kernel/process.c index 02b7834..c8c73d3 100644 --- a/arch/cris/arch-v10/kernel/process.c +++ b/arch/cris/arch-v10/kernel/process.c @@ -94,8 +94,11 @@ unsigned long thread_saved_pc(struct task_struct *t) asmlinkage void ret_from_fork(void); asmlinkage void ret_from_kernel_thread(void); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); struct switch_stack *swstack = ((struct switch_stack *)childregs) - 1; @@ -105,10 +108,11 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, */ if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ memset(swstack, 0, sizeof(struct switch_stack) + sizeof(struct pt_regs)); swstack-r1 = usp; - swstack-r2 = arg; + swstack-r2 = kthread_arg; childregs-dccr = 1 I_DCCR_BITNR; swstack-return_ip = (unsigned long) ret_from_kernel_thread; p-thread.ksp = (unsigned long) swstack; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 08/32] c6x: copy_thread(): rename 'ustk_size' argument to 'kthread_arg'
'ustk_size' is a misnomer: it is never used for the size of the user stack. It is only used when forking a new kernel thread, as the argument passed to the kthread's main function. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/c6x/kernel/process.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/c6x/kernel/process.c b/arch/c6x/kernel/process.c index 57d2ea8..b519377 100644 --- a/arch/c6x/kernel/process.c +++ b/arch/c6x/kernel/process.c @@ -109,10 +109,10 @@ void start_thread(struct pt_regs *regs, unsigned int pc, unsigned long usp) } /* - * Copy a new thread context in its stack. + * Copy architecture-specific thread state */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long ustk_size, + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs; @@ -125,9 +125,9 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, childregs-sp = (unsigned long)(childregs + 1); p-thread.pc = (unsigned long) ret_from_kernel_thread; childregs-a0 = usp;/* function */ - childregs-a1 = ustk_size; /* argument */ + childregs-a1 = kthread_arg; } else { - /* Otherwise use the given stack */ + /* user thread: use the given stack */ *childregs = *current_pt_regs(); if (usp) childregs-sp = usp; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 27/32] sparc: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/sparc/kernel/process_32.c | 10 -- arch/sparc/kernel/process_64.c | 6 -- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c index 50e7b62..ba6492f 100644 --- a/arch/sparc/kernel/process_32.c +++ b/arch/sparc/kernel/process_32.c @@ -305,8 +305,11 @@ asmlinkage int sparc_do_fork(unsigned long clone_flags, extern void ret_from_fork(void); extern void ret_from_kernel_thread(void); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long sp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *ti = task_thread_info(p); struct pt_regs *childregs, *regs = current_pt_regs(); @@ -343,6 +346,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p-thread.kregs = childregs; if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ extern int nwindows; unsigned long psr; memset(new_stack, 0, STACKFRAME_SZ + TRACEREG_SZ); @@ -350,12 +354,14 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p-thread.current_ds = KERNEL_DS; ti-kpc = (((unsigned long) ret_from_kernel_thread) - 0x8); childregs-u_regs[UREG_G1] = sp; /* function */ - childregs-u_regs[UREG_G2] = arg; + childregs-u_regs[UREG_G2] = kthread_arg; psr = childregs-psr = get_psr(); ti-kpsr = psr | PSR_PIL; ti-kwim = 1 (((psr PSR_CWP) + 1) % nwindows); return 0; } + + /* user thread */ memcpy(new_stack, (char *)regs - STACKFRAME_SZ, STACKFRAME_SZ + TRACEREG_SZ); childregs-u_regs[UREG_FP] = sp; p-thread.flags = ~SPARC_FLAG_KTHREAD; diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c index 0be7bf9..3f203c8 100644 --- a/arch/sparc/kernel/process_64.c +++ b/arch/sparc/kernel/process_64.c @@ -613,7 +613,7 @@ asmlinkage long sparc_do_fork(unsigned long clone_flags, * Child -- %o0 == parents pid, %o1 == 1 */ int copy_thread(unsigned long clone_flags, unsigned long sp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *t = task_thread_info(p); struct pt_regs *regs = current_pt_regs(); @@ -633,15 +633,17 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, t-fpsaved[0] = 0; if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ memset(child_trap_frame, 0, child_stack_sz); __thread_flag_byte_ptr(t)[TI_FLAG_BYTE_CWP] = (current_pt_regs()-tstate + 1) TSTATE_CWP; t-current_ds = ASI_P; t-kregs-u_regs[UREG_G1] = sp; /* function */ - t-kregs-u_regs[UREG_G2] = arg; + t-kregs-u_regs[UREG_G2] = kthread_arg; return 0; } + /* user thread */ parent_sf = ((struct sparc_stackf *) regs) - 1; memcpy(child_trap_frame, parent_sf, child_stack_sz); if (t-flags _TIF_32BIT) { -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 28/32] tile: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/tile/kernel/process.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c index 48e5773..bff52e4 100644 --- a/arch/tile/kernel/process.c +++ b/arch/tile/kernel/process.c @@ -97,8 +97,11 @@ void arch_release_thread_info(struct thread_info *info) static void save_arch_state(struct thread_struct *t); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long sp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); unsigned long ksp; @@ -130,15 +133,15 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, memset(callee_regs[2], 0, (CALLEE_SAVED_REGS_COUNT - 2) * sizeof(unsigned long)); callee_regs[0] = sp; /* r30 = function */ - callee_regs[1] = arg; /* r31 = arg */ + callee_regs[1] = kthread_arg; /* r31 = arg */ childregs-ex1 = PL_ICS_EX1(KERNEL_PL, 0); p-thread.pc = (unsigned long) ret_from_kernel_thread; return 0; } /* -* Start new thread in ret_from_fork so it schedules properly -* and then return from interrupt like the parent. +* user thread: start in ret_from_fork so it schedules properly +* and then returns from interrupt like the parent. */ p-thread.pc = (unsigned long) ret_from_fork; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 32/32] xtensa: copy_thread(): rename 'arg' argument to 'kthread_arg'
Rename the 'thread_fn_arg' it to 'kthread_arg' for consistency with do_fork() and other arch-specific implementations of copy_thread(). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/xtensa/kernel/process.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c index 1c85323..b12f5dc 100644 --- a/arch/xtensa/kernel/process.c +++ b/arch/xtensa/kernel/process.c @@ -147,7 +147,7 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) } /* - * Copy thread. + * Copy architecture-specific thread state * * There are two modes in which this function is called: * 1) Userspace thread creation, @@ -156,7 +156,7 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) *in the clone_flags) and set up passed usp in the childregs. * 2) Kernel thread creation, *regs == NULL, usp_thread_fn is the function to run in the new thread - *and thread_fn_arg is its parameter. + *and kthread_arg is its parameter. *childregs are not used for the kernel threads. * * The stack layout for the new thread looks like this: @@ -187,9 +187,8 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) * One solution is to spill windows to the parent stack, but that's fairly * involved. Much simpler to just not copy those live frames across. */ - int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn, - unsigned long thread_fn_arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); @@ -204,6 +203,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn, p-thread.sp = (unsigned long)childregs; if (!(p-flags PF_KTHREAD)) { + /* user thread */ struct pt_regs *regs = current_pt_regs(); unsigned long usp = usp_thread_fn ? usp_thread_fn : regs-areg[1]; @@ -254,13 +254,14 @@ int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn, if (clone_flags CLONE_SETTLS) childregs-threadptr = childregs-areg[5]; } else { + /* kernel thread */ p-thread.ra = MAKE_RA_FOR_CALL( (unsigned long)ret_from_kernel_thread, 1); /* pass parameters to ret_from_kernel_thread: * a2 = thread_fn, a3 = thread_fn arg */ - *((int *)childregs - 1) = thread_fn_arg; + *((int *)childregs - 1) = kthread_arg; *((int *)childregs - 2) = usp_thread_fn; /* Childregs are only used when we're going to userspace -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 25/32] score: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/score/kernel/process.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c index a1519ad3..a72d15f 100644 --- a/arch/score/kernel/process.c +++ b/arch/score/kernel/process.c @@ -66,10 +66,10 @@ void exit_thread(void) {} void flush_thread(void) {} /* - * set up the kernel stack and exception frames for a new process + * Copy architecture-specific thread state */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *ti = task_thread_info(p); struct pt_regs *childregs = task_pt_regs(p); @@ -77,11 +77,13 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, p-thread.reg0 = (unsigned long) childregs; if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); p-thread.reg12 = usp; - p-thread.reg13 = arg; + p-thread.reg13 = kthread_arg; p-thread.reg3 = (unsigned long) ret_from_kernel_thread; } else { + /* user thread */ *childregs = *current_pt_regs(); childregs-regs[7] = 0; /* Clear error flag */ childregs-regs[4] = 0; /* Child gets zero as return value */ -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 30/32] unicore32: copy_thread(): rename 'stk_sz' argument to 'kthread_arg'
'stk_sz' is misleading, since this argument is never used for a stack size. Rather, it is an argument passed to the main function executed by a new kernel thread. Therefore, rename it to 'kthread_arg'. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/unicore32/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/unicore32/kernel/process.c b/arch/unicore32/kernel/process.c index b008e99..11e19e0 100644 --- a/arch/unicore32/kernel/process.c +++ b/arch/unicore32/kernel/process.c @@ -227,9 +227,12 @@ void release_thread(struct task_struct *dead_task) asmlinkage void ret_from_fork(void) __asm__(ret_from_fork); asmlinkage void ret_from_kernel_thread(void) __asm__(ret_from_kernel_thread); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long stack_start, - unsigned long stk_sz, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *thread = task_thread_info(p); struct pt_regs *childregs = task_pt_regs(p); @@ -237,11 +240,13 @@ copy_thread(unsigned long clone_flags, unsigned long stack_start, memset(thread-cpu_context, 0, sizeof(struct cpu_context_save)); thread-cpu_context.sp = (unsigned long)childregs; if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ thread-cpu_context.pc = (unsigned long)ret_from_kernel_thread; thread-cpu_context.r4 = stack_start; - thread-cpu_context.r5 = stk_sz; + thread-cpu_context.r5 = kthread_arg; memset(childregs, 0, sizeof(struct pt_regs)); } else { + /* user thread */ thread-cpu_context.pc = (unsigned long)ret_from_fork; *childregs = *current_pt_regs(); childregs-UCreg_00 = 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 29/32] um: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/um/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index f17bca8..80ac9fe 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c @@ -149,8 +149,11 @@ void fork_handler(void) userspace(current-thread.regs.regs); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long sp, - unsigned long arg, struct task_struct * p) + unsigned long kthread_arg, struct task_struct *p) { void (*handler)(void); int kthread = current-flags PF_KTHREAD; @@ -159,6 +162,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, p-thread = (struct thread_struct) INIT_THREAD; if (!kthread) { + /* user thread */ memcpy(p-thread.regs.regs, current_pt_regs(), sizeof(p-thread.regs.regs)); PT_REGS_SET_SYSCALL_RETURN(p-thread.regs, 0); @@ -169,9 +173,10 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, arch_copy_thread(current-thread.arch, p-thread.arch); } else { + /* kernel thread */ get_safe_registers(p-thread.regs.regs.gp, p-thread.regs.regs.fp); p-thread.request.u.thread.proc = (int (*)(void *))sp; - p-thread.request.u.thread.arg = (void *)arg; + p-thread.request.u.thread.arg = (void *)kthread_arg; handler = new_thread_handler; } -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 23/32] powerpc: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/powerpc/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index b4cc7be..febb50d 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -1114,8 +1114,11 @@ static void setup_ksp_vsid(struct task_struct *p, unsigned long sp) */ extern unsigned long dscr_default; /* defined in arch/powerpc/kernel/sysfs.c */ +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs, *kregs; extern void ret_from_fork(void); @@ -1127,6 +1130,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, sp -= sizeof(struct pt_regs); childregs = (struct pt_regs *) sp; if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ struct thread_info *ti = (void *)task_stack_page(p); memset(childregs, 0, sizeof(struct pt_regs)); childregs-gpr[1] = sp + sizeof(struct pt_regs); @@ -1137,11 +1141,12 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, clear_tsk_thread_flag(p, TIF_32BIT); childregs-softe = 1; #endif - childregs-gpr[15] = arg; + childregs-gpr[15] = kthread_arg; p-thread.regs = NULL; /* no user register state */ ti-flags |= _TIF_RESTOREALL; f = ret_from_kernel_thread; } else { + /* user thread */ struct pt_regs *regs = current_pt_regs(); CHECK_FULL_REGS(regs); *childregs = *regs; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 31/32] x86: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/x86/kernel/process_32.c | 9 +++-- arch/x86/kernel/process_64.c | 9 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index 603c4f9..efb4a6b 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -129,8 +129,11 @@ void release_thread(struct task_struct *dead_task) release_vm86_irqs(dead_task); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long sp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); struct task_struct *tsk; @@ -149,13 +152,15 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, childregs-es = __USER_DS; childregs-fs = __KERNEL_PERCPU; childregs-bx = sp; /* function */ - childregs-bp = arg; + childregs-bp = kthread_arg; childregs-orig_ax = -1; childregs-cs = __KERNEL_CS | get_kernel_rpl(); childregs-flags = X86_EFLAGS_IF | X86_EFLAGS_FIXED; p-thread.io_bitmap_ptr = NULL; return 0; } + + /* user thread */ *childregs = *current_pt_regs(); childregs-ax = 0; if (sp) diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 67fcc43..a27abb6 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -151,8 +151,11 @@ static inline u32 read_32bit_tls(struct task_struct *t, int tls) return get_desc_base(t-thread.tls_array[tls]); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long sp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { int err; struct pt_regs *childregs; @@ -179,12 +182,14 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, childregs-sp = (unsigned long)childregs; childregs-ss = __KERNEL_DS; childregs-bx = sp; /* function */ - childregs-bp = arg; + childregs-bp = kthread_arg; childregs-orig_ax = -1; childregs-cs = __KERNEL_CS | get_kernel_rpl(); childregs-flags = X86_EFLAGS_IF | X86_EFLAGS_FIXED; return 0; } + + /* user thread */ *childregs = *current_pt_regs(); childregs-ax = 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 26/32] sh: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/sh/kernel/process_32.c | 10 -- arch/sh/kernel/process_64.c | 12 +--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/sh/kernel/process_32.c b/arch/sh/kernel/process_32.c index 2885fc9..fded1b4 100644 --- a/arch/sh/kernel/process_32.c +++ b/arch/sh/kernel/process_32.c @@ -123,8 +123,11 @@ EXPORT_SYMBOL(dump_fpu); asmlinkage void ret_from_fork(void); asmlinkage void ret_from_kernel_thread(void); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *ti = task_thread_info(p); struct pt_regs *childregs; @@ -146,9 +149,10 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, childregs = task_pt_regs(p); p-thread.sp = (unsigned long) childregs; if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); p-thread.pc = (unsigned long) ret_from_kernel_thread; - childregs-regs[4] = arg; + childregs-regs[4] = kthread_arg; childregs-regs[5] = usp; childregs-sr = SR_MD; #if defined(CONFIG_SH_FPU) @@ -159,6 +163,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, p-thread.fpu_counter = 0; return 0; } + + /* user thread */ *childregs = *current_pt_regs(); if (usp) diff --git a/arch/sh/kernel/process_64.c b/arch/sh/kernel/process_64.c index e2062e6..693105d 100644 --- a/arch/sh/kernel/process_64.c +++ b/arch/sh/kernel/process_64.c @@ -371,8 +371,11 @@ EXPORT_SYMBOL(dump_fpu); asmlinkage void ret_from_fork(void); asmlinkage void ret_from_kernel_thread(void); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs; @@ -391,14 +394,17 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, p-thread.sp = (unsigned long) childregs; if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); - childregs-regs[2] = (unsigned long)arg; - childregs-regs[3] = (unsigned long)usp; + childregs-regs[2] = kthread_arg; + childregs-regs[3] = usp; childregs-sr = (1 30); /* not user_mode */ childregs-sr |= SR_FD; /* Invalidate FPU flag */ p-thread.pc = (unsigned long) ret_from_kernel_thread; return 0; } + + /* user thread */ *childregs = *current_pt_regs(); /* -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 14/32] m32r: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/m32r/kernel/process.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/m32r/kernel/process.c b/arch/m32r/kernel/process.c index e69221d..6d5edf2 100644 --- a/arch/m32r/kernel/process.c +++ b/arch/m32r/kernel/process.c @@ -128,21 +128,25 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu) return 0; /* Task didn't use the fpu at all. */ } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long spu, - unsigned long arg, struct task_struct *tsk) + unsigned long kthread_arg, struct task_struct *tsk) { struct pt_regs *childregs = task_pt_regs(tsk); extern void ret_from_fork(void); extern void ret_from_kernel_thread(void); if (unlikely(tsk-flags PF_KTHREAD)) { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); childregs-psw = M32R_PSW_BIE; childregs-r1 = spu;/* fn */ - childregs-r0 = arg; + childregs-r0 = kthread_arg; tsk-thread.lr = (unsigned long)ret_from_kernel_thread; } else { - /* Copy registers */ + /* user thread: copy registers */ *childregs = *current_pt_regs(); if (spu) childregs-spu = spu; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 07/32] blackfin: copy_thread(): rename 'topstk' argument to 'kthread_arg'
'topstk' is a misnomer: it is not a pointer to the top of a stack. Rather, it is an argument passed to the main function executed by a new kernel thread. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/blackfin/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/blackfin/kernel/process.c b/arch/blackfin/kernel/process.c index 4aa5545..81cdd5f 100644 --- a/arch/blackfin/kernel/process.c +++ b/arch/blackfin/kernel/process.c @@ -109,9 +109,12 @@ asmlinkage int bfin_clone(unsigned long clone_flags, unsigned long newsp) return do_fork(clone_flags, newsp, 0, NULL, NULL); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, - unsigned long usp, unsigned long topstk, + unsigned long usp, unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs; @@ -120,14 +123,16 @@ copy_thread(unsigned long clone_flags, childregs = (struct pt_regs *) (task_stack_page(p) + THREAD_SIZE) - 1; v = ((unsigned long *)childregs) - 2; if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); v[0] = usp; - v[1] = topstk; + v[1] = kthread_arg; childregs-orig_p0 = -1; childregs-ipend = 0x8000; __asm__ __volatile__(%0 = syscfg;:=da(childregs-syscfg):); p-thread.usp = 0; } else { + /* user thread */ *childregs = *current_pt_regs(); childregs-r0 = 0; p-thread.usp = usp ? : rdusp(); -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 10/32] cris/arch-v32: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/cris/arch-v32/kernel/process.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/cris/arch-v32/kernel/process.c b/arch/cris/arch-v32/kernel/process.c index cebd32e..dc55e6c 100644 --- a/arch/cris/arch-v32/kernel/process.c +++ b/arch/cris/arch-v32/kernel/process.c @@ -101,9 +101,12 @@ unsigned long thread_saved_pc(struct task_struct *t) extern asmlinkage void ret_from_fork(void); extern asmlinkage void ret_from_kernel_thread(void); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); struct switch_stack *swstack = ((struct switch_stack *) childregs) - 1; @@ -114,10 +117,11 @@ copy_thread(unsigned long clone_flags, unsigned long usp, * task. */ if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ memset(swstack, 0, sizeof(struct switch_stack) + sizeof(struct pt_regs)); swstack-r1 = usp; - swstack-r2 = arg; + swstack-r2 = kthread_arg; childregs-ccs = 1 (I_CCS_BITNR + CCS_SHIFT); swstack-return_ip = (unsigned long) ret_from_kernel_thread; p-thread.ksp = (unsigned long) swstack; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 17/32] microblaze: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/microblaze/kernel/process.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c index b2dd371..d4ecb98 100644 --- a/arch/microblaze/kernel/process.c +++ b/arch/microblaze/kernel/process.c @@ -51,20 +51,22 @@ void flush_thread(void) { } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); struct thread_info *ti = task_thread_info(p); if (unlikely(p-flags PF_KTHREAD)) { - /* if we're creating a new kernel thread then just zeroing all -* the registers. That's OK for a brand new thread.*/ + /* kernel thread: just zero all the registers */ memset(childregs, 0, sizeof(struct pt_regs)); memset(ti-cpu_context, 0, sizeof(struct cpu_context)); ti-cpu_context.r1 = (unsigned long)childregs; ti-cpu_context.r20 = (unsigned long)usp; /* fn */ - ti-cpu_context.r19 = (unsigned long)arg; + ti-cpu_context.r19 = kthread_arg; childregs-pt_mode = 1; local_save_flags(childregs-msr); #ifdef CONFIG_MMU @@ -73,6 +75,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, ti-cpu_context.r15 = (unsigned long)ret_from_kernel_thread - 8; return 0; } + + /* user thread */ *childregs = *current_pt_regs(); if (usp) childregs-r1 = usp; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 21/32] openrisc: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/openrisc/kernel/process.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c index 386af25..59098c4 100644 --- a/arch/openrisc/kernel/process.c +++ b/arch/openrisc/kernel/process.c @@ -114,7 +114,7 @@ extern asmlinkage void ret_from_fork(void); * copy_thread * @clone_flags: flags * @usp: user stack pointer or fn for kernel thread - * @arg: arg to fn for kernel thread; always NULL for userspace thread + * @kthread_arg: arg to fn for kernel thread; always NULL for userspace thread * @p: the newly created task * @regs: CPU context to copy for userspace thread; always NULL for kthread * @@ -140,10 +140,9 @@ extern asmlinkage void ret_from_fork(void); * below); ret_from_fork will then continue its execution causing the * 'kernel thread' to return to userspace as a userspace thread. */ - int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *userregs; struct pt_regs *kregs; @@ -165,10 +164,12 @@ copy_thread(unsigned long clone_flags, unsigned long usp, kregs = (struct pt_regs *)sp; if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ memset(kregs, 0, sizeof(struct pt_regs)); kregs-gpr[20] = usp; /* fn, kernel thread */ - kregs-gpr[22] = arg; + kregs-gpr[22] = kthread_arg; } else { + /* user thread */ *userregs = *current_pt_regs(); if (usp) -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 19/32] mn10300: copy_thread(): rename 'ustk_size' argument to 'kthread_arg'
'ustk_size' is misleading, since this argument is never used for a user stack size. Rather, it is an argument passed to the main function executed by a new kernel thread. Therefore, rename it to 'kthread_arg'. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/mn10300/kernel/process.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c index 3707da5..d08a9b1 100644 --- a/arch/mn10300/kernel/process.c +++ b/arch/mn10300/kernel/process.c @@ -137,11 +137,10 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) } /* - * set up the kernel stack for a new thread and copy arch-specific thread - * control information + * Copy architecture-specific thread state */ int copy_thread(unsigned long clone_flags, - unsigned long c_usp, unsigned long ustk_size, + unsigned long c_usp, unsigned long kthread_arg, struct task_struct *p) { struct thread_info *ti = task_thread_info(p); @@ -164,14 +163,17 @@ int copy_thread(unsigned long clone_flags, p-thread.usp = c_usp; if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ memset(c_regs, 0, sizeof(struct pt_regs)); c_regs-a0 = c_usp; /* function */ - c_regs-d0 = ustk_size; /* argument */ + c_regs-d0 = kthread_arg; local_save_flags(c_regs-epsw); c_regs-epsw |= EPSW_IE | EPSW_IM_7; p-thread.pc= (unsigned long) ret_from_kernel_thread; return 0; } + + /* user thread */ *c_regs = *current_pt_regs(); if (c_usp) c_regs-sp = c_usp; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 05/32] arm64: copy_thread(): rename 'stk_sz' argument to 'kthread_arg'
'stk_sz' is a misnomer: it is never used for a stack size. Rather, it is an argument which is passed to the main function executed by a kernel thread, when forking a new kthread. The most appropriate name is 'kthread_arg'. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/arm64/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index fde9923..734e2b6 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -242,8 +242,11 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) asmlinkage void ret_from_fork(void) asm(ret_from_fork); +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long stack_start, - unsigned long stk_sz, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); unsigned long tls = p-thread.tp_value; @@ -251,6 +254,7 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start, memset(p-thread.cpu_context, 0, sizeof(struct cpu_context)); if (likely(!(p-flags PF_KTHREAD))) { + /* user thread */ *childregs = *current_pt_regs(); childregs-regs[0] = 0; if (is_compat_thread(task_thread_info(p))) { @@ -276,10 +280,11 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start, if (clone_flags CLONE_SETTLS) tls = childregs-regs[3]; } else { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); childregs-pstate = PSR_MODE_EL1h; p-thread.cpu_context.x19 = stack_start; - p-thread.cpu_context.x20 = stk_sz; + p-thread.cpu_context.x20 = kthread_arg; } p-thread.cpu_context.pc = (unsigned long)ret_from_fork; p-thread.cpu_context.sp = (unsigned long)childregs; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 03/32] arc: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/arc/kernel/process.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c index fdd8971..cf366bd 100644 --- a/arch/arc/kernel/process.c +++ b/arch/arc/kernel/process.c @@ -49,7 +49,9 @@ void arch_cpu_idle(void) asmlinkage void ret_from_fork(void); -/* Layout of Child kernel mode stack as setup at the end of this function is +/* Copy architecture-specific thread state + * + * Layout of Child kernel mode stack as setup at the end of this function is * * | ...| * | ...| @@ -81,7 +83,7 @@ asmlinkage void ret_from_fork(void); * -- = END of PAGE */ int copy_thread(unsigned long clone_flags, - unsigned long usp, unsigned long arg, + unsigned long usp, unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *c_regs;/* child's pt_regs */ @@ -110,9 +112,10 @@ int copy_thread(unsigned long clone_flags, childksp[1] = (unsigned long)ret_from_fork; /* blink */ if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ memset(c_regs, 0, sizeof(struct pt_regs)); - c_callee-r13 = arg; /* argument to kernel thread */ + c_callee-r13 = kthread_arg; c_callee-r14 = usp; /* function */ return 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 02/32] alpha: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/alpha/kernel/process.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c index 1941a07..84d1326 100644 --- a/arch/alpha/kernel/process.c +++ b/arch/alpha/kernel/process.c @@ -236,12 +236,11 @@ release_thread(struct task_struct *dead_task) } /* - * Copy an alpha thread.. + * Copy architecture-specific thread state */ - int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, + unsigned long kthread_arg, struct task_struct *p) { extern void ret_from_fork(void); @@ -262,7 +261,7 @@ copy_thread(unsigned long clone_flags, unsigned long usp, sizeof(struct switch_stack) + sizeof(struct pt_regs)); childstack-r26 = (unsigned long) ret_from_kernel_thread; childstack-r9 = usp; /* function */ - childstack-r10 = arg; + childstack-r10 = kthread_arg; childregs-hae = alpha_mv.hae_cache, childti-pcb.usp = 0; return 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 22/32] parisc: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/parisc/kernel/process.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c index 8a488c2..809905a 100644 --- a/arch/parisc/kernel/process.c +++ b/arch/parisc/kernel/process.c @@ -181,9 +181,12 @@ int dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *r) return 1; } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *cregs = (p-thread.regs); void *stack = task_stack_page(p); @@ -195,11 +198,10 @@ copy_thread(unsigned long clone_flags, unsigned long usp, extern void * const child_return; if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ memset(cregs, 0, sizeof(struct pt_regs)); if (!usp) /* idle thread */ return 0; - - /* kernel thread */ /* Must exit via ret_from_kernel_thread in order * to call schedule_tail() */ @@ -215,7 +217,7 @@ copy_thread(unsigned long clone_flags, unsigned long usp, #else cregs-gr[26] = usp; #endif - cregs-gr[25] = arg; + cregs-gr[25] = kthread_arg; } else { /* user thread */ /* usp must be word aligned. This also prevents users from -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 13/32] ia64: copy_thread(): rename 'user_stack_size' argument to 'kthread_arg'
'user_stack_size' is very misleading, since the argument is never used for the size of the user stack. Rather, it is an argument which is passed to the main function executed by a newly forked kernel thread. Hence, rename it to 'kthread_arg'. When forking a new user thread, the kernel thread arg was (uselessly) added to the new user stack pointer. This worked, since the kernel thread arg is always zero when forking a user thread, but it was obviously not intended. Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/ia64/kernel/process.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c index b515149..d4a78da 100644 --- a/arch/ia64/kernel/process.c +++ b/arch/ia64/kernel/process.c @@ -300,7 +300,7 @@ ia64_load_extra (struct task_struct *task) } /* - * Copy the state of an ia-64 thread. + * Copy the architecture-specific state of an ia-64 thread. * * We get here through the following call chain: * @@ -332,7 +332,7 @@ ia64_load_extra (struct task_struct *task) */ int copy_thread(unsigned long clone_flags, -unsigned long user_stack_base, unsigned long user_stack_size, +unsigned long user_stack_base, unsigned long kthread_arg, struct task_struct *p) { extern char ia64_ret_from_clone; @@ -376,13 +376,14 @@ copy_thread(unsigned long clone_flags, ia64_drop_fpu(p); /* don't pick up stale state from a CPU's fph */ if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ if (unlikely(!user_stack_base)) { /* fork_idle() called us */ return 0; } memset(child_stack, 0, sizeof(*child_ptregs) + sizeof(*child_stack)); child_stack-r4 = user_stack_base; /* payload */ - child_stack-r5 = user_stack_size; /* argument */ + child_stack-r5 = kthread_arg; /* * Preserve PSR bits, except for bits 32-34 and 37-45, * which we can't read. @@ -406,6 +407,8 @@ copy_thread(unsigned long clone_flags, return 0; } + + /* user thread */ stack = ((struct switch_stack *) regs) - 1; /* copy parent's switch_stack pt_regs to child: */ memcpy(child_stack, stack, sizeof(*child_ptregs) + sizeof(*child_stack)); @@ -416,7 +419,7 @@ copy_thread(unsigned long clone_flags, if (clone_flags CLONE_SETTLS) child_ptregs-r13 = regs-r16; /* see sys_clone2() in entry.S */ if (user_stack_base) { - child_ptregs-r12 = user_stack_base + user_stack_size - 16; + child_ptregs-r12 = user_stack_base - 16; child_ptregs-ar_bspstore = user_stack_base; child_ptregs-ar_rnat = 0; child_ptregs-loadrs = 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 12/32] hexagon: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/hexagon/kernel/process.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/hexagon/kernel/process.c b/arch/hexagon/kernel/process.c index 0a0dd5c..6f27358 100644 --- a/arch/hexagon/kernel/process.c +++ b/arch/hexagon/kernel/process.c @@ -71,7 +71,7 @@ unsigned long thread_saved_pc(struct task_struct *tsk) * Copy architecture-specific thread state */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *ti = task_thread_info(p); struct hexagon_switch_stack *ss; @@ -94,10 +94,11 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, ss-lr = (unsigned long)ret_from_fork; p-thread.switch_sp = ss; if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ memset(childregs, 0, sizeof(struct pt_regs)); /* r24 - fn, r25 - arg */ ss-r24 = usp; - ss-r25 = arg; + ss-r25 = kthread_arg; pt_set_kmode(childregs); return 0; } -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 15/32] m68k: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/m68k/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c index c55ff71..92bf7b4 100644 --- a/arch/m68k/kernel/process.c +++ b/arch/m68k/kernel/process.c @@ -129,8 +129,11 @@ asmlinkage int m68k_clone(struct pt_regs *regs) (int __user *)regs-d3, (int __user *)regs-d4); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, -unsigned long arg, struct task_struct *p) +unsigned long kthread_arg, struct task_struct *p) { struct fork_frame { struct switch_stack sw; @@ -153,11 +156,13 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, memset(frame, 0, sizeof(struct fork_frame)); frame-regs.sr = PS_S; frame-sw.a3 = usp; /* function */ - frame-sw.d7 = arg; + frame-sw.d7 = kthread_arg; frame-sw.retpc = (unsigned long)ret_from_kernel_thread; p-thread.usp = 0; return 0; } + + /* user thread */ memcpy(frame, container_of(current_pt_regs(), struct fork_frame, regs), sizeof(struct fork_frame)); frame-regs.d0 = 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 20/32] nios2: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/nios2/kernel/process.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/nios2/kernel/process.c b/arch/nios2/kernel/process.c index 0e075b5..f5a0e28 100644 --- a/arch/nios2/kernel/process.c +++ b/arch/nios2/kernel/process.c @@ -97,8 +97,12 @@ void flush_thread(void) set_fs(USER_DS); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, - unsigned long usp, unsigned long arg, struct task_struct *p) + unsigned long usp, unsigned long kthread_arg, + struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); struct pt_regs *regs; @@ -107,11 +111,12 @@ int copy_thread(unsigned long clone_flags, ((struct switch_stack *)childregs) - 1; if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ memset(childstack, 0, sizeof(struct switch_stack) + sizeof(struct pt_regs)); childstack-r16 = usp; /* fn */ - childstack-r17 = arg; + childstack-r17 = kthread_arg; childstack-ra = (unsigned long) ret_from_kernel_thread; childregs-estatus = STATUS_PIE; childregs-sp = (unsigned long) childstack; @@ -121,6 +126,7 @@ int copy_thread(unsigned long clone_flags, return 0; } + /* user thread */ regs = current_pt_regs(); *childregs = *regs; childregs-r2 = 0; /* Set the return value for the child. */ -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 24/32] s390: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/s390/kernel/process.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c index 13fc097..a1ca7cf 100644 --- a/arch/s390/kernel/process.c +++ b/arch/s390/kernel/process.c @@ -87,8 +87,11 @@ void arch_release_task_struct(struct task_struct *tsk) } #endif +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long new_stackp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *ti; struct fake_frame @@ -127,12 +130,14 @@ int copy_thread(unsigned long clone_flags, unsigned long new_stackp, frame-childregs.psw.addr = PSW_ADDR_AMODE | (unsigned long) kernel_thread_starter; frame-childregs.gprs[9] = new_stackp; /* function */ - frame-childregs.gprs[10] = arg; + frame-childregs.gprs[10] = kthread_arg; frame-childregs.gprs[11] = (unsigned long) do_exit; frame-childregs.orig_gpr2 = -1; return 0; } + + /* user thread */ frame-childregs = *current_pt_regs(); frame-childregs.gprs[2] = 0; /* child returns 0 on fork. */ frame-childregs.flags = 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 16/32] metag: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/metag/kernel/process.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/metag/kernel/process.c b/arch/metag/kernel/process.c index 483dff9..dcb4609 100644 --- a/arch/metag/kernel/process.c +++ b/arch/metag/kernel/process.c @@ -174,8 +174,11 @@ void show_regs(struct pt_regs *regs) show_trace(NULL, (unsigned long *)regs-ctx.AX[0].U0, regs); } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *tsk) + unsigned long kthread_arg, struct task_struct *tsk) { struct pt_regs *childregs = task_pt_regs(tsk); void *kernel_context = ((void *) childregs + @@ -204,10 +207,11 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, childregs-ctx.AX[0].U0 = (unsigned long) kernel_context; /* Set D1Ar1=arg and D1RtP=usp (fn) */ childregs-ctx.DX[4].U1 = usp; - childregs-ctx.DX[3].U1 = arg; + childregs-ctx.DX[3].U1 = kthread_arg; tsk-thread.int_depth = 2; return 0; } + /* * Get a pointer to where the new child's register block should have * been pushed. -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 18/32] mips: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/mips/kernel/process.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index bf85cc1..d295bd1 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -107,8 +107,11 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) return 0; } +/* + * Copy architecture-specific thread state + */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, struct task_struct *p) + unsigned long kthread_arg, struct task_struct *p) { struct thread_info *ti = task_thread_info(p); struct pt_regs *childregs, *regs = current_pt_regs(); @@ -123,11 +126,12 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, childksp = (unsigned long) childregs; p-thread.cp0_status = read_c0_status() ~(ST0_CU2|ST0_CU1); if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ unsigned long status = p-thread.cp0_status; memset(childregs, 0, sizeof(struct pt_regs)); ti-addr_limit = KERNEL_DS; p-thread.reg16 = usp; /* fn */ - p-thread.reg17 = arg; + p-thread.reg17 = kthread_arg; p-thread.reg29 = childksp; p-thread.reg31 = (unsigned long) ret_from_kernel_thread; #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX) @@ -139,6 +143,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, childregs-cp0_status = status; return 0; } + + /* user thread */ *childregs = *regs; childregs-regs[7] = 0; /* Clear error flag */ childregs-regs[2] = 0; /* Child gets zero as return value */ -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 11/32] frv: copy_thread(): rename 'arg' argument to 'kthread_arg'
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad alexinbeij...@gmail.com --- arch/frv/kernel/process.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c index 5d40aeb77..bca9f55 100644 --- a/arch/frv/kernel/process.c +++ b/arch/frv/kernel/process.c @@ -123,10 +123,10 @@ inline unsigned long user_stack(const struct pt_regs *regs) } /* - * set up the kernel stack and exception frames for a new process + * Copy architecture-specific thread state */ int copy_thread(unsigned long clone_flags, - unsigned long usp, unsigned long arg, + unsigned long usp, unsigned long kthread_arg, struct task_struct *p) { struct pt_regs *childregs; @@ -145,8 +145,9 @@ int copy_thread(unsigned long clone_flags, p-thread.frame0 = childregs; if (unlikely(p-flags PF_KTHREAD)) { + /* kernel thread */ childregs-gr9 = usp; /* function */ - childregs-gr8 = arg; + childregs-gr8 = kthread_arg; p-thread.pc = (unsigned long) ret_from_kernel_thread; save_user_regs(p-thread.user); return 0; -- 2.0.0.GIT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] do_fork(): Rename 'stack_size' argument to reflect actual use
On 05/03/15 22:29, David Rientjes wrote: On Thu, 5 Mar 2015, Alex Dowad wrote: diff --git a/kernel/fork.c b/kernel/fork.c index cf65139..b38a2ae 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1186,10 +1186,12 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid) * It copies the registers, and all the appropriate * parts of the process environment (as per the clone * flags). The actual kick-off is left to the caller. + * + * When copying a kernel thread, 'stack_start' is the function to run. */ static struct task_struct *copy_process(unsigned long clone_flags, unsigned long stack_start, - unsigned long stack_size, + unsigned long kthread_arg, int __user *child_tidptr, struct pid *pid, int trace) @@ -1401,7 +1403,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, retval = copy_io(clone_flags, p); if (retval) goto bad_fork_cleanup_namespaces; - retval = copy_thread(clone_flags, stack_start, stack_size, p); + retval = copy_thread(clone_flags, stack_start, kthread_arg, p); if (retval) goto bad_fork_cleanup_io; @@ -1629,8 +1631,8 @@ struct task_struct *fork_idle(int cpu) * it and waits for it to finish using the VM if required. */ long do_fork(unsigned long clone_flags, - unsigned long stack_start, - unsigned long stack_size, + unsigned long stack_start, /* or function for kthread to run */ + unsigned long kthread_arg, int __user *parent_tidptr, int __user *child_tidptr) { Looks fine, but I'm not sure about commenting functional formals. Since copy_process() and do_fork() can have formals with different meanings, then why not just rename them "arg1" and "arg2" respectively and then define in the comment above the function what the possible combinations are? The second argument is *only* ever used for one thing: an argument passed to a kernel thread. That's why I would like to rename it to "kthread_arg". The previous argument (currently named "stack_start") is indeed used for 2 different things: a new stack pointer for a user thread, or a function to be executed by a kernel thread. Rather than "arg1", what would you think of something like "sp_or_fn", or "usp_or_fn"? I would recommend exactly "arg" since it can be used for multiple purposes and if the formal could ever be used for a third purpose we don't want to go through another re-naming patch to change it from sp_or_fn or usp_or_fn. If that's done, then the comment above the function could define what arg can represent. Do others concur with this idea? Personally, I feel the code will be more readable/maintainable if the naming of args/variables/etc reflects what they are actually used for. (Case in point: on IA64, copy_thread() adds the kernel thread arg to the user stack pointer. The kernel thread arg is always 0 when forking a user process, so this "works", but it's certainly not what the author intended. Good names make it harder to write buggy code!) For readability, using the same arg for 2 different purposes is a bad practice (though it might be good for keeping the object code small). I hate to think that "arg" might be co-opted for another purpose again. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] do_fork(): Rename 'stack_size' argument to reflect actual use
On 05/03/15 01:07, David Rientjes wrote: On Wed, 4 Mar 2015, Alex Dowad wrote: The 'stack_size' argument is never used to pass a stack size. It's only used when forking a kernel thread, in which case it is an argument which should be passed to the 'main' function which the kernel thread executes. Hence, rename it to 'kthread_arg'. Signed-off-by: Alex Dowad --- Hi, Please have a look at this patch. If this is accepted, I have a series of patches ready for a similar cleanup to all the arch-specific implementations of copy_thread() (as suggested by Andrew Morton in a private e-mail). Thank you, Alex Dowad kernel/fork.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index cf65139..b38a2ae 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1186,10 +1186,12 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid) * It copies the registers, and all the appropriate * parts of the process environment (as per the clone * flags). The actual kick-off is left to the caller. + * + * When copying a kernel thread, 'stack_start' is the function to run. */ static struct task_struct *copy_process(unsigned long clone_flags, unsigned long stack_start, - unsigned long stack_size, + unsigned long kthread_arg, int __user *child_tidptr, struct pid *pid, int trace) @@ -1401,7 +1403,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, retval = copy_io(clone_flags, p); if (retval) goto bad_fork_cleanup_namespaces; - retval = copy_thread(clone_flags, stack_start, stack_size, p); + retval = copy_thread(clone_flags, stack_start, kthread_arg, p); if (retval) goto bad_fork_cleanup_io; @@ -1629,8 +1631,8 @@ struct task_struct *fork_idle(int cpu) * it and waits for it to finish using the VM if required. */ long do_fork(unsigned long clone_flags, - unsigned long stack_start, - unsigned long stack_size, + unsigned long stack_start, /* or function for kthread to run */ + unsigned long kthread_arg, int __user *parent_tidptr, int __user *child_tidptr) { Looks fine, but I'm not sure about commenting functional formals. Since copy_process() and do_fork() can have formals with different meanings, then why not just rename them "arg1" and "arg2" respectively and then define in the comment above the function what the possible combinations are? The second argument is *only* ever used for one thing: an argument passed to a kernel thread. That's why I would like to rename it to "kthread_arg". The previous argument (currently named "stack_start") is indeed used for 2 different things: a new stack pointer for a user thread, or a function to be executed by a kernel thread. Rather than "arg1", what would you think of something like "sp_or_fn", or "usp_or_fn"? Thanks for your feedback! @@ -1656,7 +1658,7 @@ long do_fork(unsigned long clone_flags, trace = 0; } - p = copy_process(clone_flags, stack_start, stack_size, + p = copy_process(clone_flags, stack_start, kthread_arg, child_tidptr, NULL, trace); /* * Do this prior waking up the new thread - the thread pointer @@ -1740,7 +1742,7 @@ SYSCALL_DEFINE5(clone, unsigned long, newsp, unsigned long, clone_flags, int, tls_val) #elif defined(CONFIG_CLONE_BACKWARDS3) SYSCALL_DEFINE6(clone, unsigned long, clone_flags, unsigned long, newsp, - int, stack_size, + int, ignored, int __user *, parent_tidptr, int __user *, child_tidptr, int, tls_val) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/