All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Robert White" <rwhite@casabyte.com>
To: "'Linus Torvalds'" <torvalds@osdl.org>,
	"'Albert Cahalan'" <albert@users.sourceforge.net>
Cc: "'Ulrich Drepper'" <drepper@redhat.com>,
	"'Mikael Pettersson'" <mikpe@csd.uu.se>,
	"'Kernel Mailing List'" <linux-kernel@vger.kernel.org>
Subject: RE: Who changed /proc/<pid>/ in 2.6.0-test5-bk9?
Date: Tue, 7 Oct 2003 16:08:27 -0700	[thread overview]
Message-ID: <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAA2ZSI4XW+fk25FhAf9BqjtMKAAAAQAAAAS8Bo1alFyEeioqtYx4I/JwEAAAAA@casabyte.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0310021720510.7833-100000@home.osdl.org>

Howdy,

All threads within the same process must have the same (single) list of open
files or bad things will happen.  I understand that CLONE_FILES makes this
true at the time of the clone but I don't know if that keeps this true
thereafter (e.g I don't know if this is a copy-that or a share-that
operation).  If it doesn't, the some mechanism that does needs to be added.

If all the co-joined threads of a process share the same file descriptor
list then /proc/self/fd/* will have unity for the overall process and the
bulk of the argument disappears completely.

The reason the threads must share the file descriptor table involves the
fact that data may, and likely will, flow between the threads.  After the
open(2) call the file descriptor is just data and it will get shared.

For instance, I have a seriously multi-threaded server application.  The
listen() operation for new clients happens in one thread.  When a connection
is accept()ed I take the request (first bit of data) and match it to the
service (and therefore thread) that it should be attached too.  Then I had
that socket over to that thread.

Without the shared file descriptors this would break very badly.

Conversely, there is virtually no sane model where having a disjoint file
descriptor list but otherwise conjoined data space makes sense.  The file
descriptors are going to be "tarnishing" the data space if you do this, and
that is just begging for exploits and "surprises".  That is, you will end up
with little tidbits of data that are conditionally meaningful scattered
throughout your data space.

Where you need to have the initial data shared but differing descriptor
tables you *should* be "stuck" with a classic fork() operation.

What possible win could you have in having a variable contain a particular
integral quantity that is a data file open for reading in one thread, a
mapped segment of memory in another, and invalid in the rest?  If you don't
constrain that behavior now the resulting code that "depends" on this
behavior will plague this platform for years (see Windows Dynamic Data
Exchange) and lots of existing expectations for thread behavior will be
violated day-1 of the release.

IMHO of course 8-)

Rob.


-----Original Message-----
From: linux-kernel-owner@vger.kernel.org
[mailto:linux-kernel-owner@vger.kernel.org] On Behalf Of Linus Torvalds
Sent: Thursday, October 02, 2003 5:41 PM
To: Albert Cahalan
Cc: Ulrich Drepper; Mikael Pettersson; Kernel Mailing List
Subject: Re: Who changed /proc/<pid>/ in 2.6.0-test5-bk9?


On 2 Oct 2003, Albert Cahalan wrote:
> 
> No. I mean "ban" like we ban CLONE_THREAD w/o CLONE_DETACHED.

No. Let's not do that.

We ban only things that do not make sense. That was true of trying to 
share signal handlers with different address spaces. But it is _not_ true 
of having separate file descriptors for different threads.

I don't imagine anybody cares _that_ deeply about fuser that it can't 
afford to recurse into thread directories.

And it may or may not make sense to not have a "/proc/<nn>/task/<yy>/fd"
directory at all if the thread shares file descriptors with the thread 
group leader. That would be a fairly easy optimization.

		Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



  parent reply	other threads:[~2003-10-07 23:09 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-28  1:27 Linux 2.6.0-test6 Linus Torvalds
2003-09-28  7:03 ` Con Kolivas
2003-09-28 10:02   ` Rob Landley
2003-09-29  4:55     ` Nick Piggin
2003-09-29  7:35       ` Rob Landley
2003-09-29 16:55       ` Ed Sweetman
2003-09-30  0:03         ` Nick Piggin
2003-10-02  0:41         ` Pedro Larroy
2003-10-02  3:05           ` Nick Piggin
2003-10-02 19:07             ` Pedro Larroy
2003-10-03  0:07               ` Nick Piggin
2003-10-03 19:34                 ` Pedro Larroy
2003-09-29 18:45       ` bill davidsen
2003-09-30  1:12         ` Nick Piggin
2003-10-01 21:13           ` bill davidsen
2003-10-02  2:45             ` Nick Piggin
2003-09-28  8:26 ` Markus Hästbacka
2003-09-28 10:54   ` Jeff Garzik
2003-09-28  8:59 ` keyboard repeat / sound [was Re: Linux 2.6.0-test6] Roger Luethi
2003-09-29 15:16   ` Vojtech Pavlik
2003-09-30  7:50     ` Paul
2003-09-30 12:51       ` Vojtech Pavlik
2003-09-30 13:21         ` Aristeu Sergio Rozanski Filho
2003-09-30 13:44           ` Vojtech Pavlik
2003-09-30 14:05             ` Aristeu Sergio Rozanski Filho
2003-09-30 14:16               ` Vojtech Pavlik
2003-10-01 23:51                 ` Aristeu Sergio Rozanski Filho
2003-09-30 18:16               ` Mark W. Alexander
2003-10-01 23:52                 ` Aristeu Sergio Rozanski Filho
2003-09-28 10:09 ` Linux 2.6.0-test6 Rafał 'rmrmg' Roszak
2003-09-28 11:05 ` Andreas Jellinghaus
2003-09-28 12:34   ` Dave Jones
2003-09-28 16:12     ` Andreas Jellinghaus
2003-09-28 17:51       ` Andries Brouwer
2003-09-28 16:42 ` Ivan Gyurdiev
2003-09-28 20:26 ` [patch] 2.6.0-test6: correct hdlcdrv.h prototypes Adrian Bunk
2003-09-29 13:23 ` Linux 2.6.0-test6 Florin Iucha
2003-09-29 13:55   ` Muli Ben-Yehuda
2003-09-29 14:01     ` Jaroslav Kysela
2003-09-29 14:18       ` Muli Ben-Yehuda
2003-09-29 19:04         ` bill davidsen
2003-09-29 14:30       ` Takashi Iwai
2003-09-29 13:58   ` Jaroslav Kysela
2003-09-29 16:30 ` Linux 2.6.0-test6 (compile statistics) John Cherry
2003-09-29 17:44   ` Jesper Juhl
2003-10-06 20:39     ` John Cherry
2003-10-01  8:58 ` Who changed /proc/<pid>/ in 2.6.0-test5-bk9? Mikael Pettersson
2003-10-01 11:52   ` John Levon
2003-10-01 20:21     ` bill davidsen
2003-10-02  1:00       ` John Levon
2003-10-06  3:01         ` bill davidsen
2003-10-01 15:11   ` Linus Torvalds
2003-10-01 20:58     ` bill davidsen
2003-10-01 23:42     ` Albert Cahalan
2003-10-02  0:38       ` Linus Torvalds
2003-10-02  0:57         ` Albert Cahalan
2003-10-02  3:35     ` Ulrich Drepper
2003-10-02  4:12       ` Albert Cahalan
2003-10-02  4:58         ` Ulrich Drepper
2003-10-02 13:48           ` Albert Cahalan
2003-10-02 17:30             ` Ulrich Drepper
2003-10-03  0:03               ` Albert Cahalan
2003-10-03  0:40                 ` Linus Torvalds
2003-10-03  2:53                   ` Jamie Lokier
2003-10-06  4:54                     ` Mike Fedyk
2003-10-06  2:52                   ` bill davidsen
2003-10-07 23:08                   ` Robert White [this message]
2003-10-07 22:46                 ` Robert White
2003-10-07 23:25                   ` Linus Torvalds
2003-10-08  0:41                     ` Robert White
2003-10-08  0:54                       ` Linus Torvalds
2003-10-08  2:31                         ` Robert White
2003-10-08  2:39                           ` David Lang
2003-10-08  2:59                             ` Robert White
2003-10-09 18:25                               ` bill davidsen
2003-10-08  2:47                           ` Who changed /proc/<pid>/ in 2.6.0-test5-bk9? (SIGPIPE?) Robert White
2003-10-08  2:57                             ` Linus Torvalds
2003-10-08  4:01                               ` Robert White
2003-10-08  4:08                                 ` Linus Torvalds
2003-10-08 10:47                         ` Who changed /proc/<pid>/ in 2.6.0-test5-bk9? bert hubert
2003-10-08 19:12                           ` Ulrich Drepper
2003-10-09 18:43                             ` bill davidsen
2003-10-08 21:54                           ` Robert White
2003-10-09 18:12                         ` bill davidsen
2003-10-10  4:39                           ` Jamie Lokier
2003-10-09 17:59                       ` bill davidsen
2003-10-11  3:02                       ` Here is a case that proves my previous position wrong regurading CLONE_THREAD and CLONE_FILES Robert White
2003-10-11  3:48                         ` viro
2003-10-12 11:41                         ` Jamie Lokier
2003-10-02  8:46       ` Who changed /proc/<pid>/ in 2.6.0-test5-bk9? Miquel van Smoorenburg
2003-10-02 22:35         ` Jamie Lokier
2003-10-02 23:43           ` Miquel van Smoorenburg
2003-10-06  2:57         ` bill davidsen
2003-10-02  3:38     ` Ulrich Drepper

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=''\!'~'\!'UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAA2ZSI4XW+fk25FhAf9BqjtMKAAAAQAAAAS8Bo1alFyEeioqtYx4I/JwEAAAAA@casabyte.com' \
    --to=rwhite@casabyte.com \
    --cc=albert@users.sourceforge.net \
    --cc=drepper@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikpe@csd.uu.se \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.