1
0
mirror of https://github.com/golang/go synced 2024-10-03 12:21:22 -06:00
Commit Graph

14 Commits

Author SHA1 Message Date
Shenghou Ma
2637777527 runtime: duplicate code for runtime.nanotime to avoid stack overflow in vDSO clock_gettime
Fixes #4402.

R=remyoudompheng, shivakumar.gn, random0x00, rsc
CC=golang-dev
https://golang.org/cl/6842063
2012-11-27 01:42:01 +08:00
Shenghou Ma
4022fc4e21 runtime: use vDSO clock_gettime for time.now & runtime.nanotime on Linux/amd64
Performance improvement aside, time.Now() now gets real nanosecond resolution
on supported systems.

Benchmark done on Core i7-2600 @ 3.40GHz with kernel 3.5.2-gentoo.
original vDSO gettimeofday:
BenchmarkNow    100000000               27.4 ns/op
new vDSO gettimeofday fallback:
BenchmarkNow    100000000               27.6 ns/op
new vDSO clock_gettime:
BenchmarkNow    100000000               24.4 ns/op

R=golang-dev, bradfitz, iant, iant
CC=golang-dev
https://golang.org/cl/6814103
2012-11-09 14:19:07 +08:00
Anthony Martin
024a92c1da runtime: use vDSO for gettimeofday on linux/amd64
Intel Core 2 Duo (2.16 GHz) running 3.6.5-1-ARCH

benchmark       old ns/op    new ns/op    delta
BenchmarkNow         1856         1034  -44.29%

R=rsc
CC=golang-dev
https://golang.org/cl/6826072
2012-11-07 18:29:31 -08:00
Alan Donovan
532dee3842 runtime: discard SIGPROF delivered to non-Go threads.
Signal handlers are global resources but many language
environments (Go, C++ at Google, etc) assume they have sole
ownership of a particular handler.  Signal handlers in
mixed-language applications must therefore be robust against
unexpected delivery of certain signals, such as SIGPROF.

The default Go signal handler runtime·sigtramp assumes that it
will never be called on a non-Go thread, but this assumption
is violated by when linking in C++ code that spawns threads.
Specifically, the handler asserts the thread has an associated
"m" (Go scheduler).

This CL is a very simple workaround: discard SIGPROF delivered to non-Go threads.  runtime.badsignal(int32) now receives the signal number; if it returns without panicking (e.g. sig==SIGPROF) the signal is discarded.

I don't think there is any really satisfactory solution to the
problem of signal-based profiling in a mixed-language
application.  It's not only the issue of handler clobbering,
but also that a C++ SIGPROF handler called in a Go thread
can't unwind the Go stack (and vice versa).  The best we can
hope for is not crashing.

Note:
- I've ported this to all POSIX platforms, except ARM-linux which already ignores unexpected signals on m-less threads.
- I've avoided tail-calling runtime.badsignal because AFAICT the 6a/6l don't support it.
- I've avoided hoisting 'push sig' (common to both function calls) because it makes the code harder to read.
- Fixed an (apparently incorrect?) docstring.

R=iant, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6498057
2012-09-04 14:40:49 -04:00
Shenghou Ma
4f308edc86 runtime: use sched_getaffinity for runtime.NumCPU() on Linux
Fixes #3921.

R=iant
CC=golang-dev
https://golang.org/cl/6448132
2012-08-10 10:05:26 +08:00
Russ Cox
b23691148f runtime: print error on receipt of signal on non-Go thread
It's the best we can do before Go 1.

For issue 3250; not a fix but at least less mysterious.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5797068
2012-03-12 15:55:18 -04:00
Russ Cox
36aa7d4d14 runtime: inline calls to notok
When a very low-level system call that should never fail
does fail, we call notok, which crashes the program.
Often, we are then left with only the program counter as
information about the crash, and it is in notok.
Instead, inline calls to notok (it is just one instruction
on most systems) so that the program counter will
tell us which system call is unhappy.

R=golang-dev, gri, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/5792048
2012-03-08 14:03:56 -05:00
Russ Cox
102274a30e runtime: size arena to fit in virtual address space limit
For Brad.
Now FreeBSD/386 binaries run on nearlyfreespeech.net.

Fixes #2302.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5700060
2012-02-24 15:28:51 -05:00
Russ Cox
240b1d5b44 runtime: linux signal masking
Fixes #3101 (Linux).

R=golang-dev, bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/5696043
2012-02-23 14:43:58 -05:00
Russ Cox
35586f718c os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only.  Also, signals
go to everyone who asks, not just one client.

This could plausibly move into package os now
that there are no magic side effects as a result
of the import.

Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)

Tested on darwin,linux 386,amd64.

Fixes #1266.

R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 13:52:37 -05:00
Russ Cox
55889409f8 runtime: separate out auto-generated files, take 2
This is like the ill-fated CL 5493063 except that
I have written a shell script (autogen.sh) instead of
thinking I could possibly write a correct Makefile.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5496075
2011-12-19 15:51:13 -05:00
Russ Cox
86dcc431e9 runtime: hg revert -r 6ec0a5c12d75
That was the last build that was close to working.
I will try that change again next week.
Make is being very subtle today.

At the reverted-to CL, the ARM traceback appears
to be broken.  I'll look into that next week too.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5492063
2011-12-16 18:50:40 -05:00
Russ Cox
bd9243da22 runtime: separate out auto-generated files
R=golang-dev, r, r
CC=golang-dev
https://golang.org/cl/5493063
2011-12-16 17:04:32 -05:00
Russ Cox
851f30136d runtime: make more build-friendly
Collapse the arch,os-specific directories into the main directory
by renaming xxx/foo.c to foo_xxx.c, and so on.

There are no substantial edits here, except to the Makefile.
The assumption is that the Go tool will #define GOOS_darwin
and GOARCH_amd64 and will make any file named something
like signals_darwin.h available as signals_GOOS.h during the
build.  This replaces what used to be done with -I$(GOOS).

There is still work to be done to make runtime build with
standard tools, but this is a big step.  After this we will have
to write a script to generate all the generated files so they
can be checked in (instead of generated during the build).

R=r, iant, r, lucio.dere
CC=golang-dev
https://golang.org/cl/5490053
2011-12-16 15:33:58 -05:00