sched: clarify ptrace's effect on task_struct->parent
PATCH 1/1 sched: clarify ptrace's effect on task_struct->parent
The current comment for the parent field does not explain that it can be temporarily replaced by the tracer when the task is being ptraced.
This can lead to confusion, so clarify the comment to document this important behavior.
No functional change.
--- include/linux/sched.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/linux/sched.h +5 -1
@@ -1093,7 +1093,11 @@ struct task_struct {/* Real parent process: */ struct task_struct __rcu *real_parent; -/* Recipient of SIGCHLD, wait4() reports: */ +/* +* Recipient of SIGCHLD, wait4() reports. Normally the same as +* real_parent, but temporarily replaced by the tracer while the +* task is ptraced. +*/ struct task_struct __rcu *parent;/*
Signature · 1 line
2.51.0
Quoted 18 lines · Ziran Zhang
The current comment for the parent field does not explain that it can be temporarily replaced by the tracer when the task is being ptraced.
This can lead to confusion, so clarify the comment to document this important behavior.
No functional change.
Signed-off-by Ziran Zhang <[email protected]>--- include/linux/sched.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)include/linux/sched.h +0
-0
include/linux/sched.h struct task_struct { · line 1101
Quoted 10 lines
include/linux/sched.h +5
-1@@ -1093,7 +1093,11 @@ struct task_struct {/* Real parent process: */ struct task_struct __rcu *real_parent; -/* Recipient of SIGCHLD, wait4() reports: */ +/* +* Recipient of SIGCHLD, wait4() reports. Normally the same as +* real_parent, but temporarily replaced by the tracer while the +* task is ptraced. +*/ struct task_struct __rcu *parent;
Well. Not sure this comment needs to be updated...
Anyway, this looks like overdocumentation to me. Perhaps just
/* Recipient of SIGCHLD, wait4() reports: ->real_parent or ptracer */
?
Oleg.
Quoted 9 lines · Oleg Nesterov
Well. Not sure this comment needs to be updated...
Anyway, this looks like overdocumentation to me. Perhaps just
/* Recipient of SIGCHLD, wait4() reports: ->real_parent or ptracer */?
Oleg.
Agreed, the long form is overdocumenting it. I'll send a v2 patch with your suggestion.
Best,
Ziran Zhang
PATCH v2 1/1 sched: clarify ptrace's effect on task_struct->parent
In reply to Ziran ZhangThe current comment for the parent field does not explain that it can be temporarily replaced by the tracer when the task is being ptraced.
This can lead to confusion, so clarify the comment to document this important behavior.
No functional change.
---
Changes in v2:
- Use Oleg's minimal wording suggestion to adjust comment.
include/linux/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sched.h +1 -1
@@ -1093,7 +1093,7 @@ struct task_struct {/* Real parent process: */ struct task_struct __rcu *real_parent; -/* Recipient of SIGCHLD, wait4() reports: */ +/* Recipient of SIGCHLD, wait4() reports: ->real_parent or ptracer */ struct task_struct __rcu *parent;/*
Signature · 1 line
2.51.0
Quoted 32 lines
The current comment for the parent field does not explain that it can be temporarily replaced by the tracer when the task is being ptraced.
This can lead to confusion, so clarify the comment to document this important behavior.
No functional change.
Suggested-by Oleg Nesterov <[email protected]>Signed-off-by Ziran Zhang <[email protected]>---
Changes in v2:
- Use Oleg's minimal wording suggestion to adjust comment.include/linux/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/sched.h +1
-1@@ -1093,7 +1093,7 @@ struct task_struct {/* Real parent process: */ struct task_struct __rcu *real_parent; -/* Recipient of SIGCHLD, wait4() reports: */ +/* Recipient of SIGCHLD, wait4() reports: ->real_parent or ptracer */ struct task_struct __rcu *parent;/* Signature · 1 line
2.51.0
Ping on this v2 patch. Suggested-by ptrace maintainer since September.
Sorry for the noise.
Thanks,
Ziran Zhang
Oleg Nesterov
Acked-byQuoted 30 lines · Ziran Zhang
Quoted 30 lines
The current comment for the parent field does not explain that it can be temporarily replaced by the tracer when the task is being ptraced.
This can lead to confusion, so clarify the comment to document this important behavior.
No functional change.
Suggested-by Oleg Nesterov <[email protected]>Signed-off-by Ziran Zhang <[email protected]>---
Changes in v2:
- Use Oleg's minimal wording suggestion to adjust comment.include/linux/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/sched.h +1
-1@@ -1093,7 +1093,7 @@ struct task_struct {/* Real parent process: */ struct task_struct __rcu *real_parent; -/* Recipient of SIGCHLD, wait4() reports: */ +/* Recipient of SIGCHLD, wait4() reports: ->real_parent or ptracer */ struct task_struct __rcu *parent;
Quoted 5 lines
Quoted 3 lines
include/linux/sched.h +0
-1/* -- 2.51.0
Ping on this v2 patch. Suggested-by ptrace maintainer since September.
Well, I only suggested to simplify the comment you proposed in V1 ;) So please remove the Suggested-by tag, feel free to add
Quoted 4 lines
Well, I only suggested to simplify the comment you proposed in V1 ;) So please remove the Suggested-by tag, feel free to add
Acked-by Oleg Nesterov <[email protected]>
Hi Oleg,
Thanks for the clarification. I'll drop the Suggested-by tag and add your Acked-by in v3.
Regards,
Ziran Zhang
PATCH v3 1/1 sched: clarify ptrace's effect on task_struct->parent
In reply to Ziran ZhangThe current comment for the parent field does not explain that it can be temporarily replaced by the tracer when the task is being ptraced.
This can lead to confusion, so clarify the comment to document this important behavior.
No functional change.
---
Changes in v3:
- Remove Suggested-by tag as requested by Oleg and add his Acked-by.
include/linux/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sched.h +1 -1
@@ -1093,7 +1093,7 @@ struct task_struct {/* Real parent process: */ struct task_struct __rcu *real_parent; -/* Recipient of SIGCHLD, wait4() reports: */ +/* Recipient of SIGCHLD, wait4() reports: ->real_parent or ptracer */ struct task_struct __rcu *parent;/*
Signature · 1 line
2.51.0