From: Sripathi Kodi <sripathik@in.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, patrics@interia.pl,
Linus Torvalds <torvalds@osdl.org>, Ingo Molnar <mingo@elte.hu>,
Roland McGrath <roland@redhat.com>
Subject: Re: [PATCH 2.6.13.1] Patch for invisible threads
Date: Tue, 13 Sep 2005 08:10:58 -0500 [thread overview]
Message-ID: <4326CFE2.6000908@in.ibm.com> (raw)
In-Reply-To: <20050912134954.7bbd15b2.akpm@osdl.org>
Andrew,
Andrew Morton wrote:
> Sripathi Kodi <sripathik@in.ibm.com> wrote:
>
>>Hi,
>>
>>When the main thread of a multi-threaded program calls 'pthread_exit' before
>>other threads have exited, it results in the other threads becoming
>>'invisible' to commands like 'ps'.
>
>
> This stuff is subtle. Let me cc some subtle people.
>
>
>>Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
>>
>>--- linux-2.6.13.1/kernel/exit.c 2005-09-12 02:46:26.000000000 -0500
>>+++ /home/sripathi/17794/patch_2.6.13.1/exit.c 2005-09-12 02:46:15.000000000
>>-0500
>>@@ -463,9 +463,11 @@ static inline void __exit_fs(struct task
>> struct fs_struct * fs = tsk->fs;
>>
>> if (fs) {
>>- task_lock(tsk);
>>- tsk->fs = NULL;
>>- task_unlock(tsk);
>>+ if (!thread_group_leader(tsk) || !atomic_read(&tsk->signal->live)) {
>>+ task_lock(tsk);
>>+ tsk->fs = NULL;
>>+ task_unlock(tsk);
>>+ }
>> __put_fs_struct(fs);
>> }
>> }
>
>
> A comment in there would be nice.
>
Below is the patch with a comment.
Thanks and regards,
Sripathi.
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
--- linux-2.6.13.1/kernel/exit.c 2005-09-13 15:39:48.738542872 -0500
+++ /home/sripathi/17794/patch_2.6.13.1/exit.c 2005-09-13 15:39:27.367791720
-0500
@@ -463,9 +463,13 @@ static inline void __exit_fs(struct task
struct fs_struct * fs = tsk->fs;
if (fs) {
- task_lock(tsk);
- tsk->fs = NULL;
- task_unlock(tsk);
+ /* If tsk is thread group leader and if group still has alive
+ * threads, those threads may use tsk->fs */
+ if (!thread_group_leader(tsk) || !atomic_read(&tsk->signal->live)) {
+ task_lock(tsk);
+ tsk->fs = NULL;
+ task_unlock(tsk);
+ }
__put_fs_struct(fs);
}
}
next prev parent reply other threads:[~2005-09-13 13:12 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-12 17:46 [PATCH 2.6.13.1] Patch for invisible threads Sripathi Kodi
2005-09-12 20:49 ` Andrew Morton
2005-09-13 13:10 ` Sripathi Kodi [this message]
2005-09-13 14:53 ` Linus Torvalds
2005-09-13 16:51 ` Al Viro
2005-09-13 17:01 ` Linus Torvalds
2005-09-13 17:12 ` Al Viro
2005-09-13 21:30 ` Sripathi Kodi
2005-09-13 21:56 ` Roland McGrath
2005-09-13 21:57 ` Al Viro
2005-09-13 23:10 ` Linus Torvalds
2005-09-14 1:47 ` Sripathi Kodi
2005-09-14 1:52 ` Al Viro
2005-09-14 14:37 ` Bill Davidsen
2005-09-15 0:30 ` Sripathi Kodi
2005-09-14 1:50 ` Al Viro
2005-09-15 0:31 ` Sripathi Kodi
2005-09-15 0:55 ` Roland McGrath
2005-09-15 1:38 ` Sripathi Kodi
2005-09-15 2:12 ` Al Viro
2005-09-15 7:29 ` Roland McGrath
2005-09-15 1:18 ` Al Viro
2005-09-16 0:54 ` Sripathi Kodi
2005-09-16 7:46 ` Al Viro
2005-09-16 15:06 ` Sripathi Kodi
2005-09-16 18:05 ` Daniel Jacobowitz
2005-09-16 18:14 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4326CFE2.6000908@in.ibm.com \
--to=sripathik@in.ibm.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=patrics@interia.pl \
--cc=roland@redhat.com \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox