From: "Kevin D. Kissell" <kevink@mips.com>
To: "Dominic Sweetman" <dom@algor.co.uk>
Cc: "Ralf Baechle" <ralf@oss.sgi.com>,
"Ulrich Drepper" <drepper@redhat.com>,
"Mike Uhler" <uhler@mips.com>,
"MIPS/Linux List \(SGI\)" <linux-mips@oss.sgi.com>,
"GNU libc hacker" <libc-hacker@sources.redhat.com>,
"H . J . Lu" <hjl@lucon.org>
Subject: Re: thread-ready ABIs
Date: Tue, 22 Jan 2002 13:18:03 +0100 [thread overview]
Message-ID: <002001c1a33e$d9936560$0deca8c0@Ulysses> (raw)
In-Reply-To: 15437.14361.918255.115877@gladsmuir.algor.co.uk
> Since nobody seems to be prepared to essay a brief definition of a
> thread register, I'll make one up from first principles and maybe the
> experts will beat it into shape.
Thank you, Dom, for trying to inject some civility into this debate.
> Multiple threads in a Linux process share the same address space: code
> and data. A thread has its own unique stack, but since (by
> definition) it shares all its data with every other thread it has no
> identity - there is no thread-unique static data. That means it has
> no handle to acquire and manage any thread-specific variables.
>
> [Some threads purists would probably maintain that's a Good Thing:
> threads to them are like electrons to quantum physicists,
> indistinguishable by definition].
>
> Linux is not noted for computer science purity; so an OS-maintained
> "thread identity" variable which is cheap to read in user space sounds
> a useful thing to have.
>
> A patient Linux expert (if any such are reading this list) might like
> to say what value is typically held (a pointer? an index?) and how
> it's used (my money's on "wrapped in an impenetrable macro").
>
> In a more baroque (synonym for "less backward"?) architecture there
> are usually registers hanging about which no compiler or OS author has
> previously figured out any use for, which can be bent to this purpose.
> Unfortunately, MIPS original architects committed the grave error of
> making all the registers useful.
>
> I quite like the idea of putting the thread value at a known offset in
> low virtual memory, but I expect the kernel keeps virtual page 0
> invalid to catch null pointers and that instructions start at the
> first boundary which doesn't create cache alias problems...
I think that the problem is complicated by the fact that
there may be a many->many mapping of kernel threads
(and CPUs) to user-land threads. In that case, no single
low-memory address can be correct for all kernel threads.
However, since every kernel thread should have its own
stack segment, it would appear to me that having a
variable "under" the stack would satisfy the need for
per-kernel-thread storage at a knowable location.
I suspect that there is a second-order problem in that
the base stack address may differ for instances of
the same binary launched under different circumstances.
But I don't think that renders the problem impossible.
One could have a global pointer, resolvable at link
time, which could be set to SP+delta by whatever
we call crt0 these days, and which should provide the
required semantics. Each user thread startup or
context switch could follow the global pointer to the
kernel-thread-specific memory location which
could be used as the pointer to the user-thread
specific data area.
Even with the double indirection, that strikes me
as far more efficient than performing a system call
on every thread startup to set up a magic value to be
returned in a k-register (as some have suggested)
and considerably less messy, technically and commercially,
than pulling a register out of the ABI and rendering it
useless for programs which happen not to be executing
the threads library (as others have proposed).
I await news as to why this is impossible and/or
unacceptable, and I shall endeavor to modify
or withdraw the suggestion accordingly.
Regards,
Kevin K.
WARNING: multiple messages have this Message-ID (diff)
From: "Kevin D. Kissell" <kevink@mips.com>
To: Dominic Sweetman <dom@algor.co.uk>
Cc: Ralf Baechle <ralf@oss.sgi.com>,
Ulrich Drepper <drepper@redhat.com>, Mike Uhler <uhler@mips.com>,
"MIPS/Linux List (SGI)" <linux-mips@oss.sgi.com>,
GNU libc hacker <libc-hacker@sources.redhat.com>,
"H . J . Lu" <hjl@lucon.org>
Subject: Re: thread-ready ABIs
Date: Tue, 22 Jan 2002 13:18:03 +0100 [thread overview]
Message-ID: <002001c1a33e$d9936560$0deca8c0@Ulysses> (raw)
Message-ID: <20020122121803.Oi3dIQAbvvrNP6QaIq9gM-ZFMXkK-lunHij1T2qBhYA@z> (raw)
In-Reply-To: 15437.14361.918255.115877@gladsmuir.algor.co.uk
> Since nobody seems to be prepared to essay a brief definition of a
> thread register, I'll make one up from first principles and maybe the
> experts will beat it into shape.
Thank you, Dom, for trying to inject some civility into this debate.
> Multiple threads in a Linux process share the same address space: code
> and data. A thread has its own unique stack, but since (by
> definition) it shares all its data with every other thread it has no
> identity - there is no thread-unique static data. That means it has
> no handle to acquire and manage any thread-specific variables.
>
> [Some threads purists would probably maintain that's a Good Thing:
> threads to them are like electrons to quantum physicists,
> indistinguishable by definition].
>
> Linux is not noted for computer science purity; so an OS-maintained
> "thread identity" variable which is cheap to read in user space sounds
> a useful thing to have.
>
> A patient Linux expert (if any such are reading this list) might like
> to say what value is typically held (a pointer? an index?) and how
> it's used (my money's on "wrapped in an impenetrable macro").
>
> In a more baroque (synonym for "less backward"?) architecture there
> are usually registers hanging about which no compiler or OS author has
> previously figured out any use for, which can be bent to this purpose.
> Unfortunately, MIPS original architects committed the grave error of
> making all the registers useful.
>
> I quite like the idea of putting the thread value at a known offset in
> low virtual memory, but I expect the kernel keeps virtual page 0
> invalid to catch null pointers and that instructions start at the
> first boundary which doesn't create cache alias problems...
I think that the problem is complicated by the fact that
there may be a many->many mapping of kernel threads
(and CPUs) to user-land threads. In that case, no single
low-memory address can be correct for all kernel threads.
However, since every kernel thread should have its own
stack segment, it would appear to me that having a
variable "under" the stack would satisfy the need for
per-kernel-thread storage at a knowable location.
I suspect that there is a second-order problem in that
the base stack address may differ for instances of
the same binary launched under different circumstances.
But I don't think that renders the problem impossible.
One could have a global pointer, resolvable at link
time, which could be set to SP+delta by whatever
we call crt0 these days, and which should provide the
required semantics. Each user thread startup or
context switch could follow the global pointer to the
kernel-thread-specific memory location which
could be used as the pointer to the user-thread
specific data area.
Even with the double indirection, that strikes me
as far more efficient than performing a system call
on every thread startup to set up a magic value to be
returned in a k-register (as some have suggested)
and considerably less messy, technically and commercially,
than pulling a register out of the ABI and rendering it
useless for programs which happen not to be executing
the threads library (as others have proposed).
I await news as to why this is impossible and/or
unacceptable, and I shall endeavor to modify
or withdraw the suggestion accordingly.
Regards,
Kevin K.
next prev parent reply other threads:[~2002-01-22 13:17 UTC|newest]
Thread overview: 94+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <m3elkoa5dw.fsf@myware.mynet>
2002-01-18 18:19 ` thread-ready ABIs H . J . Lu
2002-01-18 18:31 ` Ulrich Drepper
2002-01-18 19:08 ` H . J . Lu
2002-01-18 19:20 ` Ulrich Drepper
2002-01-19 12:14 ` Dominic Sweetman
2002-01-19 12:14 ` Dominic Sweetman
2002-01-20 0:14 ` Ralf Baechle
2002-01-18 20:03 ` Maciej W. Rozycki
2002-01-18 20:20 ` Ulrich Drepper
2002-01-18 20:50 ` Maciej W. Rozycki
2002-01-18 21:02 ` Ulrich Drepper
2002-01-18 21:35 ` Maciej W. Rozycki
2002-01-18 21:44 ` Ulrich Drepper
2002-01-18 22:17 ` Maciej W. Rozycki
2002-01-18 21:23 ` Daniel Jacobowitz
2002-01-19 0:35 ` Kevin D. Kissell
2002-01-19 0:35 ` Kevin D. Kissell
2002-01-19 4:11 ` H . J . Lu
2002-01-19 12:27 ` Dominic Sweetman
2002-01-19 19:42 ` H . J . Lu
2002-01-21 13:27 ` Maciej W. Rozycki
2002-01-19 22:21 ` Kevin D. Kissell
2002-01-19 22:21 ` Kevin D. Kissell
2002-01-20 10:38 ` Machida Hiroyuki
2002-01-20 11:58 ` Kevin D. Kissell
2002-01-20 11:58 ` Kevin D. Kissell
2002-01-20 13:16 ` Machida Hiroyuki
2002-01-22 6:27 ` patches for test-and-set without ll/sc (Re: thread-ready ABIs) Machida Hiroyuki
2002-01-22 6:37 ` Ulrich Drepper
2002-01-22 6:46 ` Machida Hiroyuki
2002-01-22 6:56 ` Ulrich Drepper
2002-01-24 9:56 ` Andreas Jaeger
2002-01-24 9:56 ` Andreas Jaeger
2002-01-20 19:19 ` thread-ready ABIs H . J . Lu
2002-01-21 9:39 ` Kevin D. Kissell
2002-01-21 9:39 ` Kevin D. Kissell
2002-01-21 13:56 ` Maciej W. Rozycki
2002-01-21 18:24 ` H . J . Lu
2002-01-21 18:36 ` Ulrich Drepper
2002-01-21 18:52 ` H . J . Lu
2002-01-21 18:58 ` H . J . Lu
2002-01-21 18:59 ` Daniel Jacobowitz
2002-01-21 19:05 ` H . J . Lu
2002-01-21 19:09 ` Daniel Jacobowitz
2002-01-21 19:18 ` H . J . Lu
2002-01-21 21:04 ` Kevin D. Kissell
2002-01-21 21:04 ` Kevin D. Kissell
2002-01-21 19:30 ` Geoff Keating
2002-01-21 21:07 ` Ulrich Drepper
2002-01-21 13:43 ` Maciej W. Rozycki
2002-01-20 0:24 ` Ralf Baechle
2002-01-21 23:22 ` Ulrich Drepper
2002-01-21 23:57 ` Kevin D. Kissell
2002-01-21 23:57 ` Kevin D. Kissell
2002-01-22 0:16 ` Ulrich Drepper
2002-01-22 0:16 ` Ulrich Drepper
2002-01-22 9:37 ` Dominic Sweetman
2002-01-22 9:37 ` Dominic Sweetman
2002-01-22 17:41 ` Ulrich Drepper
2002-01-22 17:41 ` Ulrich Drepper
2002-01-22 9:59 ` Dominic Sweetman
2002-01-22 9:59 ` Dominic Sweetman
2002-01-22 12:18 ` Kevin D. Kissell [this message]
2002-01-22 12:18 ` Kevin D. Kissell
2002-01-22 15:21 ` Daniel Jacobowitz
2002-01-22 15:44 ` Dominic Sweetman
2002-01-22 21:44 ` Tommy S. Christensen
2002-01-22 21:53 ` Kevin D. Kissell
2002-01-22 21:53 ` Kevin D. Kissell
2002-01-22 23:13 ` Kevin D. Kissell
2002-01-22 23:13 ` Kevin D. Kissell
2002-01-23 1:12 ` Jason Gunthorpe
2002-01-22 16:05 ` Kevin D. Kissell
2002-01-22 16:05 ` Kevin D. Kissell
2002-01-22 16:34 ` Daniel Jacobowitz
2002-01-22 17:08 ` Kevin D. Kissell
2002-01-22 17:08 ` Kevin D. Kissell
2002-01-22 17:13 ` Daniel Jacobowitz
2002-01-22 17:34 ` Kevin D. Kissell
2002-01-22 17:34 ` Kevin D. Kissell
2002-01-22 17:37 ` Daniel Jacobowitz
2002-01-22 17:47 ` Kevin D. Kissell
2002-01-22 17:47 ` Kevin D. Kissell
2002-01-22 17:57 ` Daniel Jacobowitz
2002-01-22 18:18 ` Kevin D. Kissell
2002-01-22 18:18 ` Kevin D. Kissell
2002-01-27 20:24 ` Alan Cox
2002-01-27 20:24 ` Alan Cox
2002-01-28 8:50 ` Kevin D. Kissell
2002-01-28 8:50 ` Kevin D. Kissell
2002-01-22 1:39 ` Richard Henderson
2002-01-18 21:24 Justin Carlson
2002-01-18 21:31 ` Ulrich Drepper
2002-01-18 21:42 ` Maciej W. Rozycki
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='002001c1a33e$d9936560$0deca8c0@Ulysses' \
--to=kevink@mips.com \
--cc=dom@algor.co.uk \
--cc=drepper@redhat.com \
--cc=hjl@lucon.org \
--cc=libc-hacker@sources.redhat.com \
--cc=linux-mips@oss.sgi.com \
--cc=ralf@oss.sgi.com \
--cc=uhler@mips.com \
/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