Linux vmi284606.contaboserver.net 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64
Apache/2.4.57 (Ubuntu)
: 167.86.127.34 | : 216.73.217.31
Cant Read [ /etc/named.conf ]
7.2.24-0ubuntu0.18.04.17
root
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
README
+ Create Folder
+ Create File
/
usr /
local /
go /
src /
runtime /
[ HOME SHELL ]
Name
Size
Permission
Action
cgo
[ DIR ]
drwxr-xr-x
debug
[ DIR ]
drwxr-xr-x
internal
[ DIR ]
drwxr-xr-x
msan
[ DIR ]
drwxr-xr-x
pprof
[ DIR ]
drwxr-xr-x
race
[ DIR ]
drwxr-xr-x
testdata
[ DIR ]
drwxr-xr-x
trace
[ DIR ]
drwxr-xr-x
HACKING.md
13.07
KB
-rw-r--r--
Makefile
178
B
-rw-r--r--
alg.go
10.18
KB
-rw-r--r--
asm.s
1.16
KB
-rw-r--r--
asm_386.s
40.2
KB
-rw-r--r--
asm_amd64.s
45.78
KB
-rw-r--r--
asm_arm.s
30.89
KB
-rw-r--r--
asm_arm64.s
33.12
KB
-rw-r--r--
asm_mips64x.s
22.45
KB
-rw-r--r--
asm_mipsx.s
24.72
KB
-rw-r--r--
asm_ppc64x.h
1023
B
-rw-r--r--
asm_ppc64x.s
29.39
KB
-rw-r--r--
asm_riscv64.s
17.38
KB
-rw-r--r--
asm_s390x.s
26.35
KB
-rw-r--r--
asm_wasm.s
9.65
KB
-rw-r--r--
atomic_arm64.s
259
B
-rw-r--r--
atomic_mips64x.s
296
B
-rw-r--r--
atomic_mipsx.s
258
B
-rw-r--r--
atomic_pointer.go
2.62
KB
-rw-r--r--
atomic_ppc64x.s
433
B
-rw-r--r--
atomic_riscv64.s
307
B
-rw-r--r--
auxv_none.go
358
B
-rw-r--r--
callers_test.go
7.7
KB
-rw-r--r--
cgo.go
2.01
KB
-rw-r--r--
cgo_mmap.go
2.38
KB
-rw-r--r--
cgo_ppc64x.go
411
B
-rw-r--r--
cgo_sigaction.go
3.09
KB
-rw-r--r--
cgocall.go
21.38
KB
-rw-r--r--
cgocallback.go
317
B
-rw-r--r--
cgocheck.go
6.8
KB
-rw-r--r--
chan.go
19.71
KB
-rw-r--r--
chan_test.go
21.27
KB
-rw-r--r--
chanbarrier_test.go
1.4
KB
-rw-r--r--
checkptr.go
2.5
KB
-rw-r--r--
checkptr_test.go
1.27
KB
-rw-r--r--
closure_test.go
936
B
-rw-r--r--
compiler.go
413
B
-rw-r--r--
complex.go
1.59
KB
-rw-r--r--
complex_test.go
1.05
KB
-rw-r--r--
cpuflags.go
740
B
-rw-r--r--
cpuflags_amd64.go
533
B
-rw-r--r--
cpuprof.go
6.65
KB
-rw-r--r--
cputicks.go
478
B
-rw-r--r--
crash_cgo_test.go
13.71
KB
-rw-r--r--
crash_nonunix_test.go
385
B
-rw-r--r--
crash_test.go
20.24
KB
-rw-r--r--
crash_unix_test.go
8.89
KB
-rw-r--r--
debug.go
1.63
KB
-rw-r--r--
debug_test.go
6.16
KB
-rw-r--r--
debugcall.go
2.83
KB
-rw-r--r--
debuglog.go
17.08
KB
-rw-r--r--
debuglog_off.go
356
B
-rw-r--r--
debuglog_on.go
1.09
KB
-rw-r--r--
debuglog_test.go
4.56
KB
-rw-r--r--
defer_test.go
9.98
KB
-rw-r--r--
defs1_linux.go
844
B
-rw-r--r--
defs1_netbsd_386.go
2.84
KB
-rw-r--r--
defs1_netbsd_amd64.go
3.07
KB
-rw-r--r--
defs1_netbsd_arm.go
2.96
KB
-rw-r--r--
defs1_netbsd_arm64.go
3.18
KB
-rw-r--r--
defs1_solaris_amd64.go
4.02
KB
-rw-r--r--
defs2_linux.go
3.51
KB
-rw-r--r--
defs3_linux.go
1.09
KB
-rw-r--r--
defs_aix.go
4.16
KB
-rw-r--r--
defs_aix_ppc64.go
3.61
KB
-rw-r--r--
defs_arm_linux.go
2.67
KB
-rw-r--r--
defs_darwin.go
3.84
KB
-rw-r--r--
defs_darwin_386.go
5.98
KB
-rw-r--r--
defs_darwin_amd64.go
6.07
KB
-rw-r--r--
defs_darwin_arm.go
3.78
KB
-rw-r--r--
defs_darwin_arm64.go
3.84
KB
-rw-r--r--
defs_dragonfly.go
2.54
KB
-rw-r--r--
defs_dragonfly_amd64.go
3.25
KB
-rw-r--r--
defs_freebsd.go
3.84
KB
-rw-r--r--
defs_freebsd_386.go
4.35
KB
-rw-r--r--
defs_freebsd_amd64.go
4.62
KB
-rw-r--r--
defs_freebsd_arm.go
3.68
KB
-rw-r--r--
defs_freebsd_arm64.go
4
KB
-rw-r--r--
defs_illumos_amd64.go
285
B
-rw-r--r--
defs_linux.go
3.04
KB
-rw-r--r--
defs_linux_386.go
4.05
KB
-rw-r--r--
defs_linux_amd64.go
4.56
KB
-rw-r--r--
defs_linux_arm.go
3.31
KB
-rw-r--r--
defs_linux_arm64.go
3.23
KB
-rw-r--r--
defs_linux_mips64x.go
3.04
KB
-rw-r--r--
defs_linux_mipsx.go
3.18
KB
-rw-r--r--
defs_linux_ppc64.go
3.28
KB
-rw-r--r--
defs_linux_ppc64le.go
3.28
KB
-rw-r--r--
defs_linux_riscv64.go
3.27
KB
-rw-r--r--
defs_linux_s390x.go
2.76
KB
-rw-r--r--
defs_netbsd.go
2.74
KB
-rw-r--r--
defs_netbsd_386.go
854
B
-rw-r--r--
defs_netbsd_amd64.go
1.01
KB
-rw-r--r--
defs_netbsd_arm.go
763
B
-rw-r--r--
defs_openbsd.go
2.6
KB
-rw-r--r--
defs_openbsd_386.go
2.63
KB
-rw-r--r--
defs_openbsd_amd64.go
2.83
KB
-rw-r--r--
defs_openbsd_arm.go
2.74
KB
-rw-r--r--
defs_openbsd_arm64.go
2.34
KB
-rw-r--r--
defs_plan9_386.go
1.47
KB
-rw-r--r--
defs_plan9_amd64.go
1.66
KB
-rw-r--r--
defs_plan9_arm.go
1.73
KB
-rw-r--r--
defs_solaris.go
3.33
KB
-rw-r--r--
defs_solaris_amd64.go
1003
B
-rw-r--r--
defs_windows.go
2.07
KB
-rw-r--r--
defs_windows_386.go
3.75
KB
-rw-r--r--
defs_windows_amd64.go
4.51
KB
-rw-r--r--
defs_windows_arm.go
3.59
KB
-rw-r--r--
duff_386.s
8.24
KB
-rw-r--r--
duff_amd64.s
5.53
KB
-rw-r--r--
duff_arm.s
7.11
KB
-rw-r--r--
duff_arm64.s
5.25
KB
-rw-r--r--
duff_mips64x.s
11.28
KB
-rw-r--r--
duff_ppc64x.s
2.45
KB
-rw-r--r--
duff_s390x.s
507
B
-rw-r--r--
env_plan9.go
855
B
-rw-r--r--
env_posix.go
1.82
KB
-rw-r--r--
env_test.go
1.28
KB
-rw-r--r--
error.go
7.26
KB
-rw-r--r--
example_test.go
1.34
KB
-rw-r--r--
export_aix_test.go
204
B
-rw-r--r--
export_arm_test.go
226
B
-rw-r--r--
export_darwin_test.go
351
B
-rw-r--r--
export_debug_test.go
5.28
KB
-rw-r--r--
export_debuglog_test.go
1.27
KB
-rw-r--r--
export_futex_test.go
529
B
-rw-r--r--
export_linux_test.go
429
B
-rw-r--r--
export_mmap_test.go
481
B
-rw-r--r--
export_solaris_test.go
282
B
-rw-r--r--
export_test.go
23.58
KB
-rw-r--r--
export_unix_test.go
2.28
KB
-rw-r--r--
export_windows_test.go
652
B
-rw-r--r--
extern.go
11.6
KB
-rw-r--r--
fastlog2.go
1.22
KB
-rw-r--r--
fastlog2_test.go
784
B
-rw-r--r--
fastlog2table.go
904
B
-rw-r--r--
float.go
1.35
KB
-rw-r--r--
funcdata.h
2.44
KB
-rw-r--r--
futex_test.go
2.1
KB
-rw-r--r--
gc_test.go
13.22
KB
-rw-r--r--
gcinfo_test.go
6.18
KB
-rw-r--r--
go_tls.h
366
B
-rw-r--r--
hash32.go
2.51
KB
-rw-r--r--
hash64.go
2.6
KB
-rw-r--r--
hash_test.go
17.54
KB
-rw-r--r--
heapdump.go
17.1
KB
-rw-r--r--
iface.go
15.78
KB
-rw-r--r--
iface_test.go
6.81
KB
-rw-r--r--
lfstack.go
1.77
KB
-rw-r--r--
lfstack_32bit.go
522
B
-rw-r--r--
lfstack_64bit.go
2.15
KB
-rw-r--r--
lfstack_test.go
2.78
KB
-rw-r--r--
libfuzzer.go
2.58
KB
-rw-r--r--
libfuzzer_amd64.s
940
B
-rw-r--r--
libfuzzer_arm64.s
751
B
-rw-r--r--
lock_futex.go
5.06
KB
-rw-r--r--
lock_js.go
5.45
KB
-rw-r--r--
lock_sema.go
6.6
KB
-rw-r--r--
malloc.go
48.32
KB
-rw-r--r--
malloc_test.go
9.37
KB
-rw-r--r--
map.go
42.13
KB
-rw-r--r--
map_benchmark_test.go
10.16
KB
-rw-r--r--
map_fast32.go
12.18
KB
-rw-r--r--
map_fast64.go
12.37
KB
-rw-r--r--
map_faststr.go
13.82
KB
-rw-r--r--
map_test.go
27.11
KB
-rw-r--r--
mbarrier.go
12.14
KB
-rw-r--r--
mbitmap.go
67.53
KB
-rw-r--r--
mcache.go
5.61
KB
-rw-r--r--
mcentral.go
7.14
KB
-rw-r--r--
mem_aix.go
1.93
KB
-rw-r--r--
mem_bsd.go
2.05
KB
-rw-r--r--
mem_darwin.go
1.88
KB
-rw-r--r--
mem_js.go
2.32
KB
-rw-r--r--
mem_linux.go
5.58
KB
-rw-r--r--
mem_plan9.go
4.53
KB
-rw-r--r--
mem_windows.go
3.86
KB
-rw-r--r--
memclr_386.s
2.4
KB
-rw-r--r--
memclr_amd64.s
3.65
KB
-rw-r--r--
memclr_arm.s
2.44
KB
-rw-r--r--
memclr_arm64.s
3.48
KB
-rw-r--r--
memclr_mips64x.s
785
B
-rw-r--r--
memclr_mipsx.s
1.24
KB
-rw-r--r--
memclr_plan9_386.s
905
B
-rw-r--r--
memclr_plan9_amd64.s
433
B
-rw-r--r--
memclr_ppc64x.s
4.2
KB
-rw-r--r--
memclr_riscv64.s
848
B
-rwxr-xr-x
memclr_s390x.s
1.89
KB
-rw-r--r--
memclr_wasm.s
544
B
-rw-r--r--
memmove_386.s
4.45
KB
-rw-r--r--
memmove_amd64.s
12.33
KB
-rw-r--r--
memmove_arm.s
5.9
KB
-rw-r--r--
memmove_arm64.s
3.56
KB
-rw-r--r--
memmove_linux_amd64_test.go
1.61
KB
-rw-r--r--
memmove_mips64x.s
1.82
KB
-rw-r--r--
memmove_mipsx.s
4.39
KB
-rw-r--r--
memmove_plan9_386.s
3.06
KB
-rw-r--r--
memmove_plan9_amd64.s
3.04
KB
-rw-r--r--
memmove_ppc64x.s
3.33
KB
-rw-r--r--
memmove_riscv64.s
1.81
KB
-rwxr-xr-x
memmove_s390x.s
2.92
KB
-rw-r--r--
memmove_test.go
10.97
KB
-rw-r--r--
memmove_wasm.s
1.74
KB
-rw-r--r--
mfinal.go
14.8
KB
-rw-r--r--
mfinal_test.go
5.85
KB
-rw-r--r--
mfixalloc.go
2.72
KB
-rw-r--r--
mgc.go
74.87
KB
-rw-r--r--
mgcmark.go
46.5
KB
-rw-r--r--
mgcscavenge.go
30.95
KB
-rw-r--r--
mgcscavenge_test.go
12.34
KB
-rw-r--r--
mgcstack.go
10.55
KB
-rw-r--r--
mgcsweep.go
14.79
KB
-rw-r--r--
mgcsweepbuf.go
5.98
KB
-rw-r--r--
mgcwork.go
14.24
KB
-rw-r--r--
mheap.go
61.5
KB
-rw-r--r--
mkduff.go
6.23
KB
-rw-r--r--
mkfastlog2table.go
1.32
KB
-rw-r--r--
mkpreempt.go
13.33
KB
-rw-r--r--
mksizeclasses.go
8.62
KB
-rw-r--r--
mmap.go
847
B
-rw-r--r--
mpagealloc.go
35.25
KB
-rw-r--r--
mpagealloc_32bit.go
3.75
KB
-rw-r--r--
mpagealloc_64bit.go
6.51
KB
-rw-r--r--
mpagealloc_test.go
28.88
KB
-rw-r--r--
mpagecache.go
5.03
KB
-rw-r--r--
mpagecache_test.go
9.93
KB
-rw-r--r--
mpallocbits.go
10.69
KB
-rw-r--r--
mpallocbits_test.go
12.93
KB
-rw-r--r--
mprof.go
24.06
KB
-rw-r--r--
mranges.go
5.41
KB
-rw-r--r--
msan.go
1.39
KB
-rw-r--r--
msan0.go
647
B
-rw-r--r--
msan_amd64.s
2.03
KB
-rw-r--r--
msan_arm64.s
1.69
KB
-rw-r--r--
msize.go
785
B
-rw-r--r--
mstats.go
22.62
KB
-rw-r--r--
mwbbuf.go
10.07
KB
-rw-r--r--
nbpipe_fcntl_libc_test.go
463
B
-rw-r--r--
nbpipe_fcntl_unix_test.go
445
B
-rw-r--r--
nbpipe_pipe.go
411
B
-rw-r--r--
nbpipe_pipe2.go
509
B
-rw-r--r--
nbpipe_test.go
2.17
KB
-rw-r--r--
net_plan9.go
645
B
-rw-r--r--
netpoll.go
14.46
KB
-rw-r--r--
netpoll_aix.go
4.64
KB
-rw-r--r--
netpoll_epoll.go
4
KB
-rw-r--r--
netpoll_fake.go
648
B
-rw-r--r--
netpoll_kqueue.go
4.39
KB
-rw-r--r--
netpoll_solaris.go
10.56
KB
-rw-r--r--
netpoll_stub.go
1.3
KB
-rw-r--r--
netpoll_windows.go
4.51
KB
-rw-r--r--
norace_linux_test.go
888
B
-rw-r--r--
norace_test.go
979
B
-rw-r--r--
numcpu_freebsd_test.go
381
B
-rw-r--r--
os2_aix.go
20.67
KB
-rw-r--r--
os2_freebsd.go
302
B
-rw-r--r--
os2_openbsd.go
296
B
-rw-r--r--
os2_plan9.go
1.48
KB
-rw-r--r--
os2_solaris.go
320
B
-rw-r--r--
os3_plan9.go
3.99
KB
-rw-r--r--
os3_solaris.go
16.92
KB
-rw-r--r--
os_aix.go
8.29
KB
-rw-r--r--
os_android.go
463
B
-rw-r--r--
os_darwin.go
10.59
KB
-rw-r--r--
os_darwin_arm.go
749
B
-rw-r--r--
os_darwin_arm64.go
416
B
-rw-r--r--
os_dragonfly.go
6.2
KB
-rw-r--r--
os_freebsd.go
10.97
KB
-rw-r--r--
os_freebsd2.go
478
B
-rw-r--r--
os_freebsd_amd64.go
529
B
-rw-r--r--
os_freebsd_arm.go
1.32
KB
-rw-r--r--
os_freebsd_arm64.go
2.97
KB
-rw-r--r--
os_freebsd_noauxv.go
254
B
-rw-r--r--
os_illumos.go
3.93
KB
-rw-r--r--
os_js.go
2.93
KB
-rw-r--r--
os_linux.go
13.16
KB
-rw-r--r--
os_linux_arm.go
1.35
KB
-rw-r--r--
os_linux_arm64.go
1.02
KB
-rw-r--r--
os_linux_be64.go
816
B
-rw-r--r--
os_linux_generic.go
916
B
-rw-r--r--
os_linux_mips64x.go
999
B
-rw-r--r--
os_linux_mipsx.go
1.05
KB
-rw-r--r--
os_linux_noauxv.go
307
B
-rw-r--r--
os_linux_novdso.go
298
B
-rw-r--r--
os_linux_ppc64x.go
527
B
-rw-r--r--
os_linux_riscv64.go
198
B
-rw-r--r--
os_linux_s390x.go
455
B
-rw-r--r--
os_linux_x86.go
2.69
KB
-rw-r--r--
os_netbsd.go
8.49
KB
-rw-r--r--
os_netbsd_386.go
588
B
-rw-r--r--
os_netbsd_amd64.go
585
B
-rw-r--r--
os_netbsd_arm.go
1.13
KB
-rw-r--r--
os_netbsd_arm64.go
827
B
-rw-r--r--
os_nonopenbsd.go
436
B
-rw-r--r--
os_only_solaris.go
356
B
-rw-r--r--
os_openbsd.go
7.81
KB
-rw-r--r--
os_openbsd_arm.go
749
B
-rw-r--r--
os_openbsd_arm64.go
714
B
-rw-r--r--
os_plan9.go
9.3
KB
-rw-r--r--
os_plan9_arm.go
462
B
-rw-r--r--
os_solaris.go
6.49
KB
-rw-r--r--
os_windows.go
37.01
KB
-rw-r--r--
os_windows_arm.go
511
B
-rw-r--r--
panic.go
42.23
KB
-rw-r--r--
panic32.go
4.79
KB
-rw-r--r--
plugin.go
4.16
KB
-rw-r--r--
preempt.go
14.72
KB
-rw-r--r--
preempt_386.s
983
B
-rw-r--r--
preempt_amd64.s
1.62
KB
-rw-r--r--
preempt_arm.s
1.48
KB
-rw-r--r--
preempt_arm64.s
2.8
KB
-rw-r--r--
preempt_mips64x.s
2.71
KB
-rw-r--r--
preempt_mipsx.s
2.68
KB
-rw-r--r--
preempt_nonwindows.go
289
B
-rw-r--r--
preempt_ppc64x.s
2.71
KB
-rw-r--r--
preempt_riscv64.s
197
B
-rw-r--r--
preempt_s390x.s
1.01
KB
-rw-r--r--
preempt_wasm.s
176
B
-rw-r--r--
print.go
5.98
KB
-rw-r--r--
proc.go
149.75
KB
-rw-r--r--
proc_runtime_test.go
820
B
-rw-r--r--
proc_test.go
22.89
KB
-rw-r--r--
profbuf.go
18.26
KB
-rw-r--r--
profbuf_test.go
8.65
KB
-rw-r--r--
proflabel.go
1.52
KB
-rw-r--r--
race.go
18.11
KB
-rw-r--r--
race0.go
2.61
KB
-rw-r--r--
race_amd64.s
13.59
KB
-rw-r--r--
race_arm64.s
13.53
KB
-rw-r--r--
race_ppc64le.s
17.93
KB
-rw-r--r--
rand_test.go
783
B
-rw-r--r--
rdebug.go
553
B
-rw-r--r--
relax_stub.go
597
B
-rw-r--r--
rt0_aix_ppc64.s
4.33
KB
-rw-r--r--
rt0_android_386.s
822
B
-rw-r--r--
rt0_android_amd64.s
754
B
-rw-r--r--
rt0_android_arm.s
843
B
-rw-r--r--
rt0_android_arm64.s
941
B
-rw-r--r--
rt0_darwin_386.s
452
B
-rw-r--r--
rt0_darwin_amd64.s
399
B
-rw-r--r--
rt0_darwin_arm.s
290
B
-rw-r--r--
rt0_darwin_arm64.s
2.32
KB
-rw-r--r--
rt0_dragonfly_amd64.s
448
B
-rw-r--r--
rt0_freebsd_386.s
454
B
-rw-r--r--
rt0_freebsd_amd64.s
442
B
-rw-r--r--
rt0_freebsd_arm.s
298
B
-rw-r--r--
rt0_freebsd_arm64.s
2.46
KB
-rw-r--r--
rt0_illumos_amd64.s
311
B
-rw-r--r--
rt0_js_wasm.s
2.3
KB
-rw-r--r--
rt0_linux_386.s
450
B
-rw-r--r--
rt0_linux_amd64.s
307
B
-rw-r--r--
rt0_linux_arm.s
1007
B
-rw-r--r--
rt0_linux_arm64.s
2.39
KB
-rw-r--r--
rt0_linux_mips64x.s
1015
B
-rw-r--r--
rt0_linux_mipsx.s
798
B
-rw-r--r--
rt0_linux_ppc64.s
705
B
-rw-r--r--
rt0_linux_ppc64le.s
3.72
KB
-rw-r--r--
rt0_linux_riscv64.s
370
B
-rw-r--r--
rt0_linux_s390x.s
676
B
-rw-r--r--
rt0_netbsd_386.s
452
B
-rw-r--r--
rt0_netbsd_amd64.s
309
B
-rw-r--r--
rt0_netbsd_arm.s
296
B
-rw-r--r--
rt0_netbsd_arm64.s
2.39
KB
-rw-r--r--
rt0_openbsd_386.s
454
B
-rw-r--r--
rt0_openbsd_amd64.s
311
B
-rw-r--r--
rt0_openbsd_arm.s
298
B
-rw-r--r--
rt0_openbsd_arm64.s
2.42
KB
-rw-r--r--
rt0_plan9_386.s
523
B
-rw-r--r--
rt0_plan9_amd64.s
481
B
-rw-r--r--
rt0_plan9_arm.s
397
B
-rw-r--r--
rt0_solaris_amd64.s
311
B
-rw-r--r--
rt0_windows_386.s
1.28
KB
-rw-r--r--
rt0_windows_amd64.s
1.15
KB
-rw-r--r--
rt0_windows_arm.s
386
B
-rw-r--r--
runtime-gdb.py
14.83
KB
-rw-r--r--
runtime-gdb_test.go
16.85
KB
-rw-r--r--
runtime-lldb_test.go
5.09
KB
-rw-r--r--
runtime.go
1.42
KB
-rw-r--r--
runtime1.go
11.97
KB
-rw-r--r--
runtime2.go
37.85
KB
-rw-r--r--
runtime_linux_test.go
1.46
KB
-rw-r--r--
runtime_mmap_test.go
1.82
KB
-rw-r--r--
runtime_test.go
7.81
KB
-rw-r--r--
runtime_unix_test.go
1.2
KB
-rw-r--r--
rwmutex.go
3.4
KB
-rw-r--r--
rwmutex_test.go
4.03
KB
-rw-r--r--
select.go
13.24
KB
-rw-r--r--
sema.go
15.95
KB
-rw-r--r--
sema_test.go
2.41
KB
-rw-r--r--
semasleep_test.go
1.62
KB
-rw-r--r--
sigaction.go
460
B
-rw-r--r--
signal_386.go
2.14
KB
-rw-r--r--
signal_aix_ppc64.go
3.55
KB
-rw-r--r--
signal_amd64.go
2.56
KB
-rw-r--r--
signal_arm.go
2.63
KB
-rw-r--r--
signal_arm64.go
3.12
KB
-rw-r--r--
signal_darwin.go
2.13
KB
-rw-r--r--
signal_darwin_386.go
2.33
KB
-rw-r--r--
signal_darwin_amd64.go
3.85
KB
-rw-r--r--
signal_darwin_arm.go
2.71
KB
-rw-r--r--
signal_darwin_arm64.go
3.6
KB
-rw-r--r--
signal_dragonfly.go
2.17
KB
-rw-r--r--
signal_dragonfly_amd64.go
2.01
KB
-rw-r--r--
signal_freebsd.go
2.2
KB
-rw-r--r--
signal_freebsd_386.go
1.55
KB
-rw-r--r--
signal_freebsd_amd64.go
2.03
KB
-rw-r--r--
signal_freebsd_arm.go
2.18
KB
-rw-r--r--
signal_freebsd_arm64.go
3.23
KB
-rw-r--r--
signal_linux_386.go
1.59
KB
-rw-r--r--
signal_linux_amd64.go
2.05
KB
-rw-r--r--
signal_linux_arm.go
2.13
KB
-rw-r--r--
signal_linux_arm64.go
2.95
KB
-rw-r--r--
signal_linux_mips64x.go
3.35
KB
-rw-r--r--
signal_linux_mipsx.go
3.67
KB
-rw-r--r--
signal_linux_ppc64x.go
3.42
KB
-rw-r--r--
signal_linux_riscv64.go
2.92
KB
-rw-r--r--
signal_linux_s390x.go
4.45
KB
-rw-r--r--
signal_mips64x.go
3.16
KB
-rw-r--r--
signal_mipsx.go
3.05
KB
-rw-r--r--
signal_netbsd.go
2.18
KB
-rw-r--r--
signal_netbsd_386.go
1.76
KB
-rw-r--r--
signal_netbsd_amd64.go
2.33
KB
-rw-r--r--
signal_netbsd_arm.go
2.3
KB
-rw-r--r--
signal_netbsd_arm64.go
3.4
KB
-rw-r--r--
signal_openbsd.go
2.15
KB
-rw-r--r--
signal_openbsd_386.go
1.58
KB
-rw-r--r--
signal_openbsd_amd64.go
2.04
KB
-rw-r--r--
signal_openbsd_arm.go
2.12
KB
-rw-r--r--
signal_openbsd_arm64.go
3.38
KB
-rw-r--r--
signal_plan9.go
1.93
KB
-rw-r--r--
signal_ppc64x.go
3.61
KB
-rw-r--r--
signal_riscv64.go
2.45
KB
-rw-r--r--
signal_solaris.go
4.5
KB
-rw-r--r--
signal_solaris_amd64.go
2.47
KB
-rw-r--r--
signal_unix.go
35.95
KB
-rw-r--r--
signal_windows.go
8.54
KB
-rw-r--r--
signal_windows_test.go
1.6
KB
-rw-r--r--
sigqueue.go
7.69
KB
-rw-r--r--
sigqueue_note.go
654
B
-rw-r--r--
sigqueue_plan9.go
3.31
KB
-rw-r--r--
sigtab_aix.go
11.3
KB
-rw-r--r--
sigtab_linux_generic.go
3.49
KB
-rw-r--r--
sigtab_linux_mipsx.go
5.89
KB
-rw-r--r--
sizeclasses.go
7.9
KB
-rw-r--r--
sizeof_test.go
839
B
-rw-r--r--
slice.go
6.88
KB
-rw-r--r--
slice_test.go
8.78
KB
-rw-r--r--
softfloat64.go
10.7
KB
-rw-r--r--
softfloat64_test.go
4.05
KB
-rw-r--r--
stack.go
39.14
KB
-rw-r--r--
stack_test.go
19.9
KB
-rw-r--r--
string.go
11.52
KB
-rw-r--r--
string_test.go
10.35
KB
-rw-r--r--
stubs.go
13.08
KB
-rw-r--r--
stubs2.go
1.04
KB
-rw-r--r--
stubs3.go
289
B
-rw-r--r--
stubs32.go
393
B
-rw-r--r--
stubs_386.go
490
B
-rw-r--r--
stubs_amd64.go
348
B
-rw-r--r--
stubs_arm.go
454
B
-rw-r--r--
stubs_arm64.go
256
B
-rw-r--r--
stubs_linux.go
646
B
-rw-r--r--
stubs_mips64x.go
283
B
-rw-r--r--
stubs_mipsx.go
279
B
-rw-r--r--
stubs_nonlinux.go
297
B
-rw-r--r--
stubs_ppc64x.go
296
B
-rw-r--r--
stubs_s390x.go
256
B
-rw-r--r--
symtab.go
28.32
KB
-rw-r--r--
symtab_test.go
4.1
KB
-rw-r--r--
sys_aix_ppc64.s
7.17
KB
-rw-r--r--
sys_arm.go
521
B
-rw-r--r--
sys_arm64.go
469
B
-rw-r--r--
sys_darwin.go
15.96
KB
-rw-r--r--
sys_darwin_32.go
533
B
-rw-r--r--
sys_darwin_386.s
18.55
KB
-rw-r--r--
sys_darwin_64.go
513
B
-rw-r--r--
sys_darwin_amd64.s
18.07
KB
-rw-r--r--
sys_darwin_arm.s
13.7
KB
-rw-r--r--
sys_darwin_arm64.s
15.84
KB
-rw-r--r--
sys_dragonfly_amd64.s
8.32
KB
-rw-r--r--
sys_freebsd_386.s
8.92
KB
-rw-r--r--
sys_freebsd_amd64.s
10.72
KB
-rw-r--r--
sys_freebsd_arm.s
10.64
KB
-rw-r--r--
sys_freebsd_arm64.s
10.75
KB
-rw-r--r--
sys_linux_386.s
17.57
KB
-rw-r--r--
sys_linux_amd64.s
17.07
KB
-rw-r--r--
sys_linux_arm.s
14.9
KB
-rw-r--r--
sys_linux_arm64.s
14.32
KB
-rw-r--r--
sys_linux_mips64x.s
12
KB
-rw-r--r--
sys_linux_mipsx.s
11.13
KB
-rw-r--r--
sys_linux_ppc64x.s
14.71
KB
-rw-r--r--
sys_linux_riscv64.s
10.38
KB
-rw-r--r--
sys_linux_s390x.s
10.52
KB
-rw-r--r--
sys_mips64x.go
496
B
-rw-r--r--
sys_mipsx.go
492
B
-rw-r--r--
sys_netbsd_386.s
10.04
KB
-rw-r--r--
sys_netbsd_amd64.s
10.03
KB
-rw-r--r--
sys_netbsd_arm.s
10.85
KB
-rw-r--r--
sys_netbsd_arm64.s
10.13
KB
-rw-r--r--
sys_nonppc64x.go
241
B
-rw-r--r--
sys_openbsd_386.s
9.1
KB
-rw-r--r--
sys_openbsd_amd64.s
8.83
KB
-rw-r--r--
sys_openbsd_arm.s
9.63
KB
-rw-r--r--
sys_openbsd_arm64.s
9.55
KB
-rw-r--r--
sys_plan9_386.s
4.41
KB
-rw-r--r--
sys_plan9_amd64.s
4.47
KB
-rw-r--r--
sys_plan9_arm.s
7.03
KB
-rw-r--r--
sys_ppc64x.go
528
B
-rw-r--r--
sys_riscv64.go
469
B
-rw-r--r--
sys_s390x.go
469
B
-rw-r--r--
sys_solaris_amd64.s
6.69
KB
-rw-r--r--
sys_wasm.go
806
B
-rw-r--r--
sys_wasm.s
2.48
KB
-rw-r--r--
sys_windows_386.s
11.55
KB
-rw-r--r--
sys_windows_amd64.s
12.14
KB
-rw-r--r--
sys_windows_arm.s
18.38
KB
-rw-r--r--
sys_x86.go
624
B
-rw-r--r--
syscall2_solaris.go
1.73
KB
-rw-r--r--
syscall_aix.go
5.99
KB
-rw-r--r--
syscall_solaris.go
8.26
KB
-rw-r--r--
syscall_windows.go
6.83
KB
-rw-r--r--
syscall_windows_test.go
27.09
KB
-rw-r--r--
textflag.h
1.46
KB
-rw-r--r--
time.go
29.12
KB
-rw-r--r--
time_fake.go
2.67
KB
-rw-r--r--
time_nofake.go
631
B
-rw-r--r--
time_test.go
1.9
KB
-rw-r--r--
timeasm.go
382
B
-rw-r--r--
timestub.go
497
B
-rw-r--r--
timestub2.go
309
B
-rw-r--r--
tls_arm.s
3.37
KB
-rw-r--r--
tls_arm64.h
985
B
-rw-r--r--
tls_arm64.s
1.07
KB
-rw-r--r--
tls_mips64x.s
729
B
-rw-r--r--
tls_mipsx.s
705
B
-rw-r--r--
tls_ppc64x.s
1.51
KB
-rw-r--r--
tls_riscv64.s
454
B
-rw-r--r--
tls_s390x.s
1.55
KB
-rw-r--r--
trace.go
37.73
KB
-rw-r--r--
traceback.go
44.11
KB
-rw-r--r--
type.go
18.27
KB
-rw-r--r--
typekind.go
742
B
-rw-r--r--
utf8.go
3.39
KB
-rw-r--r--
vdso_elf32.go
2.76
KB
-rw-r--r--
vdso_elf64.go
2.79
KB
-rw-r--r--
vdso_freebsd.go
2.44
KB
-rw-r--r--
vdso_freebsd_arm.go
454
B
-rw-r--r--
vdso_freebsd_arm64.go
443
B
-rw-r--r--
vdso_freebsd_x86.go
1.85
KB
-rw-r--r--
vdso_in_none.go
379
B
-rw-r--r--
vdso_linux.go
7.68
KB
-rw-r--r--
vdso_linux_386.go
669
B
-rw-r--r--
vdso_linux_amd64.go
748
B
-rw-r--r--
vdso_linux_arm.go
669
B
-rw-r--r--
vdso_linux_arm64.go
670
B
-rw-r--r--
vdso_linux_mips64x.go
851
B
-rw-r--r--
vdso_linux_ppc64x.go
673
B
-rw-r--r--
vlop_386.s
2.02
KB
-rw-r--r--
vlop_arm.s
7.06
KB
-rw-r--r--
vlop_arm_test.go
3.75
KB
-rw-r--r--
vlrt.go
6.09
KB
-rw-r--r--
wincallback.go
2.53
KB
-rw-r--r--
write_err.go
290
B
-rw-r--r--
write_err_android.go
4.65
KB
-rw-r--r--
zcallback_windows.go
155
B
-rw-r--r--
zcallback_windows.s
63.02
KB
-rw-r--r--
zcallback_windows_arm.s
89.32
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : mgcmark.go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Garbage collector: marking and scanning package runtime import ( "runtime/internal/atomic" "runtime/internal/sys" "unsafe" ) const ( fixedRootFinalizers = iota fixedRootFreeGStacks fixedRootCount // rootBlockBytes is the number of bytes to scan per data or // BSS root. rootBlockBytes = 256 << 10 // rootBlockSpans is the number of spans to scan per span // root. rootBlockSpans = 8 * 1024 // 64MB worth of spans // maxObletBytes is the maximum bytes of an object to scan at // once. Larger objects will be split up into "oblets" of at // most this size. Since we can scan 1–2 MB/ms, 128 KB bounds // scan preemption at ~100 µs. // // This must be > _MaxSmallSize so that the object base is the // span base. maxObletBytes = 128 << 10 // drainCheckThreshold specifies how many units of work to do // between self-preemption checks in gcDrain. Assuming a scan // rate of 1 MB/ms, this is ~100 µs. Lower values have higher // overhead in the scan loop (the scheduler check may perform // a syscall, so its overhead is nontrivial). Higher values // make the system less responsive to incoming work. drainCheckThreshold = 100000 ) // gcMarkRootPrepare queues root scanning jobs (stacks, globals, and // some miscellany) and initializes scanning-related state. // // The world must be stopped. // //go:nowritebarrier func gcMarkRootPrepare() { work.nFlushCacheRoots = 0 // Compute how many data and BSS root blocks there are. nBlocks := func(bytes uintptr) int { return int((bytes + rootBlockBytes - 1) / rootBlockBytes) } work.nDataRoots = 0 work.nBSSRoots = 0 // Scan globals. for _, datap := range activeModules() { nDataRoots := nBlocks(datap.edata - datap.data) if nDataRoots > work.nDataRoots { work.nDataRoots = nDataRoots } } for _, datap := range activeModules() { nBSSRoots := nBlocks(datap.ebss - datap.bss) if nBSSRoots > work.nBSSRoots { work.nBSSRoots = nBSSRoots } } // Scan span roots for finalizer specials. // // We depend on addfinalizer to mark objects that get // finalizers after root marking. // // We're only interested in scanning the in-use spans, // which will all be swept at this point. More spans // may be added to this list during concurrent GC, but // we only care about spans that were allocated before // this mark phase. work.nSpanRoots = mheap_.sweepSpans[mheap_.sweepgen/2%2].numBlocks() // Scan stacks. // // Gs may be created after this point, but it's okay that we // ignore them because they begin life without any roots, so // there's nothing to scan, and any roots they create during // the concurrent phase will be scanned during mark // termination. work.nStackRoots = int(atomic.Loaduintptr(&allglen)) work.markrootNext = 0 work.markrootJobs = uint32(fixedRootCount + work.nFlushCacheRoots + work.nDataRoots + work.nBSSRoots + work.nSpanRoots + work.nStackRoots) } // gcMarkRootCheck checks that all roots have been scanned. It is // purely for debugging. func gcMarkRootCheck() { if work.markrootNext < work.markrootJobs { print(work.markrootNext, " of ", work.markrootJobs, " markroot jobs done\n") throw("left over markroot jobs") } lock(&allglock) // Check that stacks have been scanned. var gp *g for i := 0; i < work.nStackRoots; i++ { gp = allgs[i] if !gp.gcscandone { goto fail } } unlock(&allglock) return fail: println("gp", gp, "goid", gp.goid, "status", readgstatus(gp), "gcscandone", gp.gcscandone) unlock(&allglock) // Avoid self-deadlock with traceback. throw("scan missed a g") } // ptrmask for an allocation containing a single pointer. var oneptrmask = [...]uint8{1} // markroot scans the i'th root. // // Preemption must be disabled (because this uses a gcWork). // // nowritebarrier is only advisory here. // //go:nowritebarrier func markroot(gcw *gcWork, i uint32) { // TODO(austin): This is a bit ridiculous. Compute and store // the bases in gcMarkRootPrepare instead of the counts. baseFlushCache := uint32(fixedRootCount) baseData := baseFlushCache + uint32(work.nFlushCacheRoots) baseBSS := baseData + uint32(work.nDataRoots) baseSpans := baseBSS + uint32(work.nBSSRoots) baseStacks := baseSpans + uint32(work.nSpanRoots) end := baseStacks + uint32(work.nStackRoots) // Note: if you add a case here, please also update heapdump.go:dumproots. switch { case baseFlushCache <= i && i < baseData: flushmcache(int(i - baseFlushCache)) case baseData <= i && i < baseBSS: for _, datap := range activeModules() { markrootBlock(datap.data, datap.edata-datap.data, datap.gcdatamask.bytedata, gcw, int(i-baseData)) } case baseBSS <= i && i < baseSpans: for _, datap := range activeModules() { markrootBlock(datap.bss, datap.ebss-datap.bss, datap.gcbssmask.bytedata, gcw, int(i-baseBSS)) } case i == fixedRootFinalizers: for fb := allfin; fb != nil; fb = fb.alllink { cnt := uintptr(atomic.Load(&fb.cnt)) scanblock(uintptr(unsafe.Pointer(&fb.fin[0])), cnt*unsafe.Sizeof(fb.fin[0]), &finptrmask[0], gcw, nil) } case i == fixedRootFreeGStacks: // Switch to the system stack so we can call // stackfree. systemstack(markrootFreeGStacks) case baseSpans <= i && i < baseStacks: // mark mspan.specials markrootSpans(gcw, int(i-baseSpans)) default: // the rest is scanning goroutine stacks var gp *g if baseStacks <= i && i < end { gp = allgs[i-baseStacks] } else { throw("markroot: bad index") } // remember when we've first observed the G blocked // needed only to output in traceback status := readgstatus(gp) // We are not in a scan state if (status == _Gwaiting || status == _Gsyscall) && gp.waitsince == 0 { gp.waitsince = work.tstart } // scanstack must be done on the system stack in case // we're trying to scan our own stack. systemstack(func() { // If this is a self-scan, put the user G in // _Gwaiting to prevent self-deadlock. It may // already be in _Gwaiting if this is a mark // worker or we're in mark termination. userG := getg().m.curg selfScan := gp == userG && readgstatus(userG) == _Grunning if selfScan { casgstatus(userG, _Grunning, _Gwaiting) userG.waitreason = waitReasonGarbageCollectionScan } // TODO: suspendG blocks (and spins) until gp // stops, which may take a while for // running goroutines. Consider doing this in // two phases where the first is non-blocking: // we scan the stacks we can and ask running // goroutines to scan themselves; and the // second blocks. stopped := suspendG(gp) if stopped.dead { gp.gcscandone = true return } if gp.gcscandone { throw("g already scanned") } scanstack(gp, gcw) gp.gcscandone = true resumeG(stopped) if selfScan { casgstatus(userG, _Gwaiting, _Grunning) } }) } } // markrootBlock scans the shard'th shard of the block of memory [b0, // b0+n0), with the given pointer mask. // //go:nowritebarrier func markrootBlock(b0, n0 uintptr, ptrmask0 *uint8, gcw *gcWork, shard int) { if rootBlockBytes%(8*sys.PtrSize) != 0 { // This is necessary to pick byte offsets in ptrmask0. throw("rootBlockBytes must be a multiple of 8*ptrSize") } // Note that if b0 is toward the end of the address space, // then b0 + rootBlockBytes might wrap around. // These tests are written to avoid any possible overflow. off := uintptr(shard) * rootBlockBytes if off >= n0 { return } b := b0 + off ptrmask := (*uint8)(add(unsafe.Pointer(ptrmask0), uintptr(shard)*(rootBlockBytes/(8*sys.PtrSize)))) n := uintptr(rootBlockBytes) if off+n > n0 { n = n0 - off } // Scan this shard. scanblock(b, n, ptrmask, gcw, nil) } // markrootFreeGStacks frees stacks of dead Gs. // // This does not free stacks of dead Gs cached on Ps, but having a few // cached stacks around isn't a problem. func markrootFreeGStacks() { // Take list of dead Gs with stacks. lock(&sched.gFree.lock) list := sched.gFree.stack sched.gFree.stack = gList{} unlock(&sched.gFree.lock) if list.empty() { return } // Free stacks. q := gQueue{list.head, list.head} for gp := list.head.ptr(); gp != nil; gp = gp.schedlink.ptr() { stackfree(gp.stack) gp.stack.lo = 0 gp.stack.hi = 0 // Manipulate the queue directly since the Gs are // already all linked the right way. q.tail.set(gp) } // Put Gs back on the free list. lock(&sched.gFree.lock) sched.gFree.noStack.pushAll(q) unlock(&sched.gFree.lock) } // markrootSpans marks roots for one shard of work.spans. // //go:nowritebarrier func markrootSpans(gcw *gcWork, shard int) { // Objects with finalizers have two GC-related invariants: // // 1) Everything reachable from the object must be marked. // This ensures that when we pass the object to its finalizer, // everything the finalizer can reach will be retained. // // 2) Finalizer specials (which are not in the garbage // collected heap) are roots. In practice, this means the fn // field must be scanned. // // TODO(austin): There are several ideas for making this more // efficient in issue #11485. sg := mheap_.sweepgen spans := mheap_.sweepSpans[mheap_.sweepgen/2%2].block(shard) // Note that work.spans may not include spans that were // allocated between entering the scan phase and now. We may // also race with spans being added into sweepSpans when they're // just created, and as a result we may see nil pointers in the // spans slice. This is okay because any objects with finalizers // in those spans must have been allocated and given finalizers // after we entered the scan phase, so addfinalizer will have // ensured the above invariants for them. for i := 0; i < len(spans); i++ { // sweepBuf.block requires that we read pointers from the block atomically. // It also requires that we ignore nil pointers. s := (*mspan)(atomic.Loadp(unsafe.Pointer(&spans[i]))) // This is racing with spans being initialized, so // check the state carefully. if s == nil || s.state.get() != mSpanInUse { continue } // Check that this span was swept (it may be cached or uncached). if !useCheckmark && !(s.sweepgen == sg || s.sweepgen == sg+3) { // sweepgen was updated (+2) during non-checkmark GC pass print("sweep ", s.sweepgen, " ", sg, "\n") throw("gc: unswept span") } // Speculatively check if there are any specials // without acquiring the span lock. This may race with // adding the first special to a span, but in that // case addfinalizer will observe that the GC is // active (which is globally synchronized) and ensure // the above invariants. We may also ensure the // invariants, but it's okay to scan an object twice. if s.specials == nil { continue } // Lock the specials to prevent a special from being // removed from the list while we're traversing it. lock(&s.speciallock) for sp := s.specials; sp != nil; sp = sp.next { if sp.kind != _KindSpecialFinalizer { continue } // don't mark finalized object, but scan it so we // retain everything it points to. spf := (*specialfinalizer)(unsafe.Pointer(sp)) // A finalizer can be set for an inner byte of an object, find object beginning. p := s.base() + uintptr(spf.special.offset)/s.elemsize*s.elemsize // Mark everything that can be reached from // the object (but *not* the object itself or // we'll never collect it). scanobject(p, gcw) // The special itself is a root. scanblock(uintptr(unsafe.Pointer(&spf.fn)), sys.PtrSize, &oneptrmask[0], gcw, nil) } unlock(&s.speciallock) } } // gcAssistAlloc performs GC work to make gp's assist debt positive. // gp must be the calling user gorountine. // // This must be called with preemption enabled. func gcAssistAlloc(gp *g) { // Don't assist in non-preemptible contexts. These are // generally fragile and won't allow the assist to block. if getg() == gp.m.g0 { return } if mp := getg().m; mp.locks > 0 || mp.preemptoff != "" { return } traced := false retry: // Compute the amount of scan work we need to do to make the // balance positive. When the required amount of work is low, // we over-assist to build up credit for future allocations // and amortize the cost of assisting. debtBytes := -gp.gcAssistBytes scanWork := int64(gcController.assistWorkPerByte * float64(debtBytes)) if scanWork < gcOverAssistWork { scanWork = gcOverAssistWork debtBytes = int64(gcController.assistBytesPerWork * float64(scanWork)) } // Steal as much credit as we can from the background GC's // scan credit. This is racy and may drop the background // credit below 0 if two mutators steal at the same time. This // will just cause steals to fail until credit is accumulated // again, so in the long run it doesn't really matter, but we // do have to handle the negative credit case. bgScanCredit := atomic.Loadint64(&gcController.bgScanCredit) stolen := int64(0) if bgScanCredit > 0 { if bgScanCredit < scanWork { stolen = bgScanCredit gp.gcAssistBytes += 1 + int64(gcController.assistBytesPerWork*float64(stolen)) } else { stolen = scanWork gp.gcAssistBytes += debtBytes } atomic.Xaddint64(&gcController.bgScanCredit, -stolen) scanWork -= stolen if scanWork == 0 { // We were able to steal all of the credit we // needed. if traced { traceGCMarkAssistDone() } return } } if trace.enabled && !traced { traced = true traceGCMarkAssistStart() } // Perform assist work systemstack(func() { gcAssistAlloc1(gp, scanWork) // The user stack may have moved, so this can't touch // anything on it until it returns from systemstack. }) completed := gp.param != nil gp.param = nil if completed { gcMarkDone() } if gp.gcAssistBytes < 0 { // We were unable steal enough credit or perform // enough work to pay off the assist debt. We need to // do one of these before letting the mutator allocate // more to prevent over-allocation. // // If this is because we were preempted, reschedule // and try some more. if gp.preempt { Gosched() goto retry } // Add this G to an assist queue and park. When the GC // has more background credit, it will satisfy queued // assists before flushing to the global credit pool. // // Note that this does *not* get woken up when more // work is added to the work list. The theory is that // there wasn't enough work to do anyway, so we might // as well let background marking take care of the // work that is available. if !gcParkAssist() { goto retry } // At this point either background GC has satisfied // this G's assist debt, or the GC cycle is over. } if traced { traceGCMarkAssistDone() } } // gcAssistAlloc1 is the part of gcAssistAlloc that runs on the system // stack. This is a separate function to make it easier to see that // we're not capturing anything from the user stack, since the user // stack may move while we're in this function. // // gcAssistAlloc1 indicates whether this assist completed the mark // phase by setting gp.param to non-nil. This can't be communicated on // the stack since it may move. // //go:systemstack func gcAssistAlloc1(gp *g, scanWork int64) { // Clear the flag indicating that this assist completed the // mark phase. gp.param = nil if atomic.Load(&gcBlackenEnabled) == 0 { // The gcBlackenEnabled check in malloc races with the // store that clears it but an atomic check in every malloc // would be a performance hit. // Instead we recheck it here on the non-preemptable system // stack to determine if we should perform an assist. // GC is done, so ignore any remaining debt. gp.gcAssistBytes = 0 return } // Track time spent in this assist. Since we're on the // system stack, this is non-preemptible, so we can // just measure start and end time. startTime := nanotime() decnwait := atomic.Xadd(&work.nwait, -1) if decnwait == work.nproc { println("runtime: work.nwait =", decnwait, "work.nproc=", work.nproc) throw("nwait > work.nprocs") } // gcDrainN requires the caller to be preemptible. casgstatus(gp, _Grunning, _Gwaiting) gp.waitreason = waitReasonGCAssistMarking // drain own cached work first in the hopes that it // will be more cache friendly. gcw := &getg().m.p.ptr().gcw workDone := gcDrainN(gcw, scanWork) casgstatus(gp, _Gwaiting, _Grunning) // Record that we did this much scan work. // // Back out the number of bytes of assist credit that // this scan work counts for. The "1+" is a poor man's // round-up, to ensure this adds credit even if // assistBytesPerWork is very low. gp.gcAssistBytes += 1 + int64(gcController.assistBytesPerWork*float64(workDone)) // If this is the last worker and we ran out of work, // signal a completion point. incnwait := atomic.Xadd(&work.nwait, +1) if incnwait > work.nproc { println("runtime: work.nwait=", incnwait, "work.nproc=", work.nproc) throw("work.nwait > work.nproc") } if incnwait == work.nproc && !gcMarkWorkAvailable(nil) { // This has reached a background completion point. Set // gp.param to a non-nil value to indicate this. It // doesn't matter what we set it to (it just has to be // a valid pointer). gp.param = unsafe.Pointer(gp) } duration := nanotime() - startTime _p_ := gp.m.p.ptr() _p_.gcAssistTime += duration if _p_.gcAssistTime > gcAssistTimeSlack { atomic.Xaddint64(&gcController.assistTime, _p_.gcAssistTime) _p_.gcAssistTime = 0 } } // gcWakeAllAssists wakes all currently blocked assists. This is used // at the end of a GC cycle. gcBlackenEnabled must be false to prevent // new assists from going to sleep after this point. func gcWakeAllAssists() { lock(&work.assistQueue.lock) list := work.assistQueue.q.popList() injectglist(&list) unlock(&work.assistQueue.lock) } // gcParkAssist puts the current goroutine on the assist queue and parks. // // gcParkAssist reports whether the assist is now satisfied. If it // returns false, the caller must retry the assist. // //go:nowritebarrier func gcParkAssist() bool { lock(&work.assistQueue.lock) // If the GC cycle finished while we were getting the lock, // exit the assist. The cycle can't finish while we hold the // lock. if atomic.Load(&gcBlackenEnabled) == 0 { unlock(&work.assistQueue.lock) return true } gp := getg() oldList := work.assistQueue.q work.assistQueue.q.pushBack(gp) // Recheck for background credit now that this G is in // the queue, but can still back out. This avoids a // race in case background marking has flushed more // credit since we checked above. if atomic.Loadint64(&gcController.bgScanCredit) > 0 { work.assistQueue.q = oldList if oldList.tail != 0 { oldList.tail.ptr().schedlink.set(nil) } unlock(&work.assistQueue.lock) return false } // Park. goparkunlock(&work.assistQueue.lock, waitReasonGCAssistWait, traceEvGoBlockGC, 2) return true } // gcFlushBgCredit flushes scanWork units of background scan work // credit. This first satisfies blocked assists on the // work.assistQueue and then flushes any remaining credit to // gcController.bgScanCredit. // // Write barriers are disallowed because this is used by gcDrain after // it has ensured that all work is drained and this must preserve that // condition. // //go:nowritebarrierrec func gcFlushBgCredit(scanWork int64) { if work.assistQueue.q.empty() { // Fast path; there are no blocked assists. There's a // small window here where an assist may add itself to // the blocked queue and park. If that happens, we'll // just get it on the next flush. atomic.Xaddint64(&gcController.bgScanCredit, scanWork) return } scanBytes := int64(float64(scanWork) * gcController.assistBytesPerWork) lock(&work.assistQueue.lock) for !work.assistQueue.q.empty() && scanBytes > 0 { gp := work.assistQueue.q.pop() // Note that gp.gcAssistBytes is negative because gp // is in debt. Think carefully about the signs below. if scanBytes+gp.gcAssistBytes >= 0 { // Satisfy this entire assist debt. scanBytes += gp.gcAssistBytes gp.gcAssistBytes = 0 // It's important that we *not* put gp in // runnext. Otherwise, it's possible for user // code to exploit the GC worker's high // scheduler priority to get itself always run // before other goroutines and always in the // fresh quantum started by GC. ready(gp, 0, false) } else { // Partially satisfy this assist. gp.gcAssistBytes += scanBytes scanBytes = 0 // As a heuristic, we move this assist to the // back of the queue so that large assists // can't clog up the assist queue and // substantially delay small assists. work.assistQueue.q.pushBack(gp) break } } if scanBytes > 0 { // Convert from scan bytes back to work. scanWork = int64(float64(scanBytes) * gcController.assistWorkPerByte) atomic.Xaddint64(&gcController.bgScanCredit, scanWork) } unlock(&work.assistQueue.lock) } // scanstack scans gp's stack, greying all pointers found on the stack. // // scanstack will also shrink the stack if it is safe to do so. If it // is not, it schedules a stack shrink for the next synchronous safe // point. // // scanstack is marked go:systemstack because it must not be preempted // while using a workbuf. // //go:nowritebarrier //go:systemstack func scanstack(gp *g, gcw *gcWork) { if readgstatus(gp)&_Gscan == 0 { print("runtime:scanstack: gp=", gp, ", goid=", gp.goid, ", gp->atomicstatus=", hex(readgstatus(gp)), "\n") throw("scanstack - bad status") } switch readgstatus(gp) &^ _Gscan { default: print("runtime: gp=", gp, ", goid=", gp.goid, ", gp->atomicstatus=", readgstatus(gp), "\n") throw("mark - bad status") case _Gdead: return case _Grunning: print("runtime: gp=", gp, ", goid=", gp.goid, ", gp->atomicstatus=", readgstatus(gp), "\n") throw("scanstack: goroutine not stopped") case _Grunnable, _Gsyscall, _Gwaiting: // ok } if gp == getg() { throw("can't scan our own stack") } if isShrinkStackSafe(gp) { // Shrink the stack if not much of it is being used. shrinkstack(gp) } else { // Otherwise, shrink the stack at the next sync safe point. gp.preemptShrink = true } var state stackScanState state.stack = gp.stack if stackTraceDebug { println("stack trace goroutine", gp.goid) } if debugScanConservative && gp.asyncSafePoint { print("scanning async preempted goroutine ", gp.goid, " stack [", hex(gp.stack.lo), ",", hex(gp.stack.hi), ")\n") } // Scan the saved context register. This is effectively a live // register that gets moved back and forth between the // register and sched.ctxt without a write barrier. if gp.sched.ctxt != nil { scanblock(uintptr(unsafe.Pointer(&gp.sched.ctxt)), sys.PtrSize, &oneptrmask[0], gcw, &state) } // Scan the stack. Accumulate a list of stack objects. scanframe := func(frame *stkframe, unused unsafe.Pointer) bool { scanframeworker(frame, &state, gcw) return true } gentraceback(^uintptr(0), ^uintptr(0), 0, gp, 0, nil, 0x7fffffff, scanframe, nil, 0) // Find additional pointers that point into the stack from the heap. // Currently this includes defers and panics. See also function copystack. // Find and trace all defer arguments. tracebackdefers(gp, scanframe, nil) // Find and trace other pointers in defer records. for d := gp._defer; d != nil; d = d.link { if d.fn != nil { // tracebackdefers above does not scan the func value, which could // be a stack allocated closure. See issue 30453. scanblock(uintptr(unsafe.Pointer(&d.fn)), sys.PtrSize, &oneptrmask[0], gcw, &state) } if d.link != nil { // The link field of a stack-allocated defer record might point // to a heap-allocated defer record. Keep that heap record live. scanblock(uintptr(unsafe.Pointer(&d.link)), sys.PtrSize, &oneptrmask[0], gcw, &state) } // Retain defers records themselves. // Defer records might not be reachable from the G through regular heap // tracing because the defer linked list might weave between the stack and the heap. if d.heap { scanblock(uintptr(unsafe.Pointer(&d)), sys.PtrSize, &oneptrmask[0], gcw, &state) } } if gp._panic != nil { // Panics are always stack allocated. state.putPtr(uintptr(unsafe.Pointer(gp._panic)), false) } // Find and scan all reachable stack objects. // // The state's pointer queue prioritizes precise pointers over // conservative pointers so that we'll prefer scanning stack // objects precisely. state.buildIndex() for { p, conservative := state.getPtr() if p == 0 { break } obj := state.findObject(p) if obj == nil { continue } t := obj.typ if t == nil { // We've already scanned this object. continue } obj.setType(nil) // Don't scan it again. if stackTraceDebug { printlock() print(" live stkobj at", hex(state.stack.lo+uintptr(obj.off)), "of type", t.string()) if conservative { print(" (conservative)") } println() printunlock() } gcdata := t.gcdata var s *mspan if t.kind&kindGCProg != 0 { // This path is pretty unlikely, an object large enough // to have a GC program allocated on the stack. // We need some space to unpack the program into a straight // bitmask, which we allocate/free here. // TODO: it would be nice if there were a way to run a GC // program without having to store all its bits. We'd have // to change from a Lempel-Ziv style program to something else. // Or we can forbid putting objects on stacks if they require // a gc program (see issue 27447). s = materializeGCProg(t.ptrdata, gcdata) gcdata = (*byte)(unsafe.Pointer(s.startAddr)) } b := state.stack.lo + uintptr(obj.off) if conservative { scanConservative(b, t.ptrdata, gcdata, gcw, &state) } else { scanblock(b, t.ptrdata, gcdata, gcw, &state) } if s != nil { dematerializeGCProg(s) } } // Deallocate object buffers. // (Pointer buffers were all deallocated in the loop above.) for state.head != nil { x := state.head state.head = x.next if stackTraceDebug { for _, obj := range x.obj[:x.nobj] { if obj.typ == nil { // reachable continue } println(" dead stkobj at", hex(gp.stack.lo+uintptr(obj.off)), "of type", obj.typ.string()) // Note: not necessarily really dead - only reachable-from-ptr dead. } } x.nobj = 0 putempty((*workbuf)(unsafe.Pointer(x))) } if state.buf != nil || state.cbuf != nil || state.freeBuf != nil { throw("remaining pointer buffers") } } // Scan a stack frame: local variables and function arguments/results. //go:nowritebarrier func scanframeworker(frame *stkframe, state *stackScanState, gcw *gcWork) { if _DebugGC > 1 && frame.continpc != 0 { print("scanframe ", funcname(frame.fn), "\n") } isAsyncPreempt := frame.fn.valid() && frame.fn.funcID == funcID_asyncPreempt if state.conservative || isAsyncPreempt { if debugScanConservative { println("conservatively scanning function", funcname(frame.fn), "at PC", hex(frame.continpc)) } // Conservatively scan the frame. Unlike the precise // case, this includes the outgoing argument space // since we may have stopped while this function was // setting up a call. // // TODO: We could narrow this down if the compiler // produced a single map per function of stack slots // and registers that ever contain a pointer. if frame.varp != 0 { size := frame.varp - frame.sp if size > 0 { scanConservative(frame.sp, size, nil, gcw, state) } } // Scan arguments to this frame. if frame.arglen != 0 { // TODO: We could pass the entry argument map // to narrow this down further. scanConservative(frame.argp, frame.arglen, nil, gcw, state) } if isAsyncPreempt { // This function's frame contained the // registers for the asynchronously stopped // parent frame. Scan the parent // conservatively. state.conservative = true } else { // We only wanted to scan those two frames // conservatively. Clear the flag for future // frames. state.conservative = false } return } locals, args, objs := getStackMap(frame, &state.cache, false) // Scan local variables if stack frame has been allocated. if locals.n > 0 { size := uintptr(locals.n) * sys.PtrSize scanblock(frame.varp-size, size, locals.bytedata, gcw, state) } // Scan arguments. if args.n > 0 { scanblock(frame.argp, uintptr(args.n)*sys.PtrSize, args.bytedata, gcw, state) } // Add all stack objects to the stack object list. if frame.varp != 0 { // varp is 0 for defers, where there are no locals. // In that case, there can't be a pointer to its args, either. // (And all args would be scanned above anyway.) for _, obj := range objs { off := obj.off base := frame.varp // locals base pointer if off >= 0 { base = frame.argp // arguments and return values base pointer } ptr := base + uintptr(off) if ptr < frame.sp { // object hasn't been allocated in the frame yet. continue } if stackTraceDebug { println("stkobj at", hex(ptr), "of type", obj.typ.string()) } state.addObject(ptr, obj.typ) } } } type gcDrainFlags int const ( gcDrainUntilPreempt gcDrainFlags = 1 << iota gcDrainFlushBgCredit gcDrainIdle gcDrainFractional ) // gcDrain scans roots and objects in work buffers, blackening grey // objects until it is unable to get more work. It may return before // GC is done; it's the caller's responsibility to balance work from // other Ps. // // If flags&gcDrainUntilPreempt != 0, gcDrain returns when g.preempt // is set. // // If flags&gcDrainIdle != 0, gcDrain returns when there is other work // to do. // // If flags&gcDrainFractional != 0, gcDrain self-preempts when // pollFractionalWorkerExit() returns true. This implies // gcDrainNoBlock. // // If flags&gcDrainFlushBgCredit != 0, gcDrain flushes scan work // credit to gcController.bgScanCredit every gcCreditSlack units of // scan work. // //go:nowritebarrier func gcDrain(gcw *gcWork, flags gcDrainFlags) { if !writeBarrier.needed { throw("gcDrain phase incorrect") } gp := getg().m.curg preemptible := flags&gcDrainUntilPreempt != 0 flushBgCredit := flags&gcDrainFlushBgCredit != 0 idle := flags&gcDrainIdle != 0 initScanWork := gcw.scanWork // checkWork is the scan work before performing the next // self-preempt check. checkWork := int64(1<<63 - 1) var check func() bool if flags&(gcDrainIdle|gcDrainFractional) != 0 { checkWork = initScanWork + drainCheckThreshold if idle { check = pollWork } else if flags&gcDrainFractional != 0 { check = pollFractionalWorkerExit } } // Drain root marking jobs. if work.markrootNext < work.markrootJobs { for !(preemptible && gp.preempt) { job := atomic.Xadd(&work.markrootNext, +1) - 1 if job >= work.markrootJobs { break } markroot(gcw, job) if check != nil && check() { goto done } } } // Drain heap marking jobs. for !(preemptible && gp.preempt) { // Try to keep work available on the global queue. We used to // check if there were waiting workers, but it's better to // just keep work available than to make workers wait. In the // worst case, we'll do O(log(_WorkbufSize)) unnecessary // balances. if work.full == 0 { gcw.balance() } b := gcw.tryGetFast() if b == 0 { b = gcw.tryGet() if b == 0 { // Flush the write barrier // buffer; this may create // more work. wbBufFlush(nil, 0) b = gcw.tryGet() } } if b == 0 { // Unable to get work. break } scanobject(b, gcw) // Flush background scan work credit to the global // account if we've accumulated enough locally so // mutator assists can draw on it. if gcw.scanWork >= gcCreditSlack { atomic.Xaddint64(&gcController.scanWork, gcw.scanWork) if flushBgCredit { gcFlushBgCredit(gcw.scanWork - initScanWork) initScanWork = 0 } checkWork -= gcw.scanWork gcw.scanWork = 0 if checkWork <= 0 { checkWork += drainCheckThreshold if check != nil && check() { break } } } } done: // Flush remaining scan work credit. if gcw.scanWork > 0 { atomic.Xaddint64(&gcController.scanWork, gcw.scanWork) if flushBgCredit { gcFlushBgCredit(gcw.scanWork - initScanWork) } gcw.scanWork = 0 } } // gcDrainN blackens grey objects until it has performed roughly // scanWork units of scan work or the G is preempted. This is // best-effort, so it may perform less work if it fails to get a work // buffer. Otherwise, it will perform at least n units of work, but // may perform more because scanning is always done in whole object // increments. It returns the amount of scan work performed. // // The caller goroutine must be in a preemptible state (e.g., // _Gwaiting) to prevent deadlocks during stack scanning. As a // consequence, this must be called on the system stack. // //go:nowritebarrier //go:systemstack func gcDrainN(gcw *gcWork, scanWork int64) int64 { if !writeBarrier.needed { throw("gcDrainN phase incorrect") } // There may already be scan work on the gcw, which we don't // want to claim was done by this call. workFlushed := -gcw.scanWork gp := getg().m.curg for !gp.preempt && workFlushed+gcw.scanWork < scanWork { // See gcDrain comment. if work.full == 0 { gcw.balance() } // This might be a good place to add prefetch code... // if(wbuf.nobj > 4) { // PREFETCH(wbuf->obj[wbuf.nobj - 3]; // } // b := gcw.tryGetFast() if b == 0 { b = gcw.tryGet() if b == 0 { // Flush the write barrier buffer; // this may create more work. wbBufFlush(nil, 0) b = gcw.tryGet() } } if b == 0 { // Try to do a root job. // // TODO: Assists should get credit for this // work. if work.markrootNext < work.markrootJobs { job := atomic.Xadd(&work.markrootNext, +1) - 1 if job < work.markrootJobs { markroot(gcw, job) continue } } // No heap or root jobs. break } scanobject(b, gcw) // Flush background scan work credit. if gcw.scanWork >= gcCreditSlack { atomic.Xaddint64(&gcController.scanWork, gcw.scanWork) workFlushed += gcw.scanWork gcw.scanWork = 0 } } // Unlike gcDrain, there's no need to flush remaining work // here because this never flushes to bgScanCredit and // gcw.dispose will flush any remaining work to scanWork. return workFlushed + gcw.scanWork } // scanblock scans b as scanobject would, but using an explicit // pointer bitmap instead of the heap bitmap. // // This is used to scan non-heap roots, so it does not update // gcw.bytesMarked or gcw.scanWork. // // If stk != nil, possible stack pointers are also reported to stk.putPtr. //go:nowritebarrier func scanblock(b0, n0 uintptr, ptrmask *uint8, gcw *gcWork, stk *stackScanState) { // Use local copies of original parameters, so that a stack trace // due to one of the throws below shows the original block // base and extent. b := b0 n := n0 for i := uintptr(0); i < n; { // Find bits for the next word. bits := uint32(*addb(ptrmask, i/(sys.PtrSize*8))) if bits == 0 { i += sys.PtrSize * 8 continue } for j := 0; j < 8 && i < n; j++ { if bits&1 != 0 { // Same work as in scanobject; see comments there. p := *(*uintptr)(unsafe.Pointer(b + i)) if p != 0 { if obj, span, objIndex := findObject(p, b, i); obj != 0 { greyobject(obj, b, i, span, gcw, objIndex) } else if stk != nil && p >= stk.stack.lo && p < stk.stack.hi { stk.putPtr(p, false) } } } bits >>= 1 i += sys.PtrSize } } } // scanobject scans the object starting at b, adding pointers to gcw. // b must point to the beginning of a heap object or an oblet. // scanobject consults the GC bitmap for the pointer mask and the // spans for the size of the object. // //go:nowritebarrier func scanobject(b uintptr, gcw *gcWork) { // Find the bits for b and the size of the object at b. // // b is either the beginning of an object, in which case this // is the size of the object to scan, or it points to an // oblet, in which case we compute the size to scan below. hbits := heapBitsForAddr(b) s := spanOfUnchecked(b) n := s.elemsize if n == 0 { throw("scanobject n == 0") } if n > maxObletBytes { // Large object. Break into oblets for better // parallelism and lower latency. if b == s.base() { // It's possible this is a noscan object (not // from greyobject, but from other code // paths), in which case we must *not* enqueue // oblets since their bitmaps will be // uninitialized. if s.spanclass.noscan() { // Bypass the whole scan. gcw.bytesMarked += uint64(n) return } // Enqueue the other oblets to scan later. // Some oblets may be in b's scalar tail, but // these will be marked as "no more pointers", // so we'll drop out immediately when we go to // scan those. for oblet := b + maxObletBytes; oblet < s.base()+s.elemsize; oblet += maxObletBytes { if !gcw.putFast(oblet) { gcw.put(oblet) } } } // Compute the size of the oblet. Since this object // must be a large object, s.base() is the beginning // of the object. n = s.base() + s.elemsize - b if n > maxObletBytes { n = maxObletBytes } } var i uintptr for i = 0; i < n; i += sys.PtrSize { // Find bits for this word. if i != 0 { // Avoid needless hbits.next() on last iteration. hbits = hbits.next() } // Load bits once. See CL 22712 and issue 16973 for discussion. bits := hbits.bits() // During checkmarking, 1-word objects store the checkmark // in the type bit for the one word. The only one-word objects // are pointers, or else they'd be merged with other non-pointer // data into larger allocations. if i != 1*sys.PtrSize && bits&bitScan == 0 { break // no more pointers in this object } if bits&bitPointer == 0 { continue // not a pointer } // Work here is duplicated in scanblock and above. // If you make changes here, make changes there too. obj := *(*uintptr)(unsafe.Pointer(b + i)) // At this point we have extracted the next potential pointer. // Quickly filter out nil and pointers back to the current object. if obj != 0 && obj-b >= n { // Test if obj points into the Go heap and, if so, // mark the object. // // Note that it's possible for findObject to // fail if obj points to a just-allocated heap // object because of a race with growing the // heap. In this case, we know the object was // just allocated and hence will be marked by // allocation itself. if obj, span, objIndex := findObject(obj, b, i); obj != 0 { greyobject(obj, b, i, span, gcw, objIndex) } } } gcw.bytesMarked += uint64(n) gcw.scanWork += int64(i) } // scanConservative scans block [b, b+n) conservatively, treating any // pointer-like value in the block as a pointer. // // If ptrmask != nil, only words that are marked in ptrmask are // considered as potential pointers. // // If state != nil, it's assumed that [b, b+n) is a block in the stack // and may contain pointers to stack objects. func scanConservative(b, n uintptr, ptrmask *uint8, gcw *gcWork, state *stackScanState) { if debugScanConservative { printlock() print("conservatively scanning [", hex(b), ",", hex(b+n), ")\n") hexdumpWords(b, b+n, func(p uintptr) byte { if ptrmask != nil { word := (p - b) / sys.PtrSize bits := *addb(ptrmask, word/8) if (bits>>(word%8))&1 == 0 { return '$' } } val := *(*uintptr)(unsafe.Pointer(p)) if state != nil && state.stack.lo <= val && val < state.stack.hi { return '@' } span := spanOfHeap(val) if span == nil { return ' ' } idx := span.objIndex(val) if span.isFree(idx) { return ' ' } return '*' }) printunlock() } for i := uintptr(0); i < n; i += sys.PtrSize { if ptrmask != nil { word := i / sys.PtrSize bits := *addb(ptrmask, word/8) if bits == 0 { // Skip 8 words (the loop increment will do the 8th) // // This must be the first time we've // seen this word of ptrmask, so i // must be 8-word-aligned, but check // our reasoning just in case. if i%(sys.PtrSize*8) != 0 { throw("misaligned mask") } i += sys.PtrSize*8 - sys.PtrSize continue } if (bits>>(word%8))&1 == 0 { continue } } val := *(*uintptr)(unsafe.Pointer(b + i)) // Check if val points into the stack. if state != nil && state.stack.lo <= val && val < state.stack.hi { // val may point to a stack object. This // object may be dead from last cycle and // hence may contain pointers to unallocated // objects, but unlike heap objects we can't // tell if it's already dead. Hence, if all // pointers to this object are from // conservative scanning, we have to scan it // defensively, too. state.putPtr(val, true) continue } // Check if val points to a heap span. span := spanOfHeap(val) if span == nil { continue } // Check if val points to an allocated object. idx := span.objIndex(val) if span.isFree(idx) { continue } // val points to an allocated object. Mark it. obj := span.base() + idx*span.elemsize greyobject(obj, b, i, span, gcw, idx) } } // Shade the object if it isn't already. // The object is not nil and known to be in the heap. // Preemption must be disabled. //go:nowritebarrier func shade(b uintptr) { if obj, span, objIndex := findObject(b, 0, 0); obj != 0 { gcw := &getg().m.p.ptr().gcw greyobject(obj, 0, 0, span, gcw, objIndex) } } // obj is the start of an object with mark mbits. // If it isn't already marked, mark it and enqueue into gcw. // base and off are for debugging only and could be removed. // // See also wbBufFlush1, which partially duplicates this logic. // //go:nowritebarrierrec func greyobject(obj, base, off uintptr, span *mspan, gcw *gcWork, objIndex uintptr) { // obj should be start of allocation, and so must be at least pointer-aligned. if obj&(sys.PtrSize-1) != 0 { throw("greyobject: obj not pointer-aligned") } mbits := span.markBitsForIndex(objIndex) if useCheckmark { if !mbits.isMarked() { printlock() print("runtime:greyobject: checkmarks finds unexpected unmarked object obj=", hex(obj), "\n") print("runtime: found obj at *(", hex(base), "+", hex(off), ")\n") // Dump the source (base) object gcDumpObject("base", base, off) // Dump the object gcDumpObject("obj", obj, ^uintptr(0)) getg().m.traceback = 2 throw("checkmark found unmarked object") } hbits := heapBitsForAddr(obj) if hbits.isCheckmarked(span.elemsize) { return } hbits.setCheckmarked(span.elemsize) if !hbits.isCheckmarked(span.elemsize) { throw("setCheckmarked and isCheckmarked disagree") } } else { if debug.gccheckmark > 0 && span.isFree(objIndex) { print("runtime: marking free object ", hex(obj), " found at *(", hex(base), "+", hex(off), ")\n") gcDumpObject("base", base, off) gcDumpObject("obj", obj, ^uintptr(0)) getg().m.traceback = 2 throw("marking free object") } // If marked we have nothing to do. if mbits.isMarked() { return } mbits.setMarked() // Mark span. arena, pageIdx, pageMask := pageIndexOf(span.base()) if arena.pageMarks[pageIdx]&pageMask == 0 { atomic.Or8(&arena.pageMarks[pageIdx], pageMask) } // If this is a noscan object, fast-track it to black // instead of greying it. if span.spanclass.noscan() { gcw.bytesMarked += uint64(span.elemsize) return } } // Queue the obj for scanning. The PREFETCH(obj) logic has been removed but // seems like a nice optimization that can be added back in. // There needs to be time between the PREFETCH and the use. // Previously we put the obj in an 8 element buffer that is drained at a rate // to give the PREFETCH time to do its work. // Use of PREFETCHNTA might be more appropriate than PREFETCH if !gcw.putFast(obj) { gcw.put(obj) } } // gcDumpObject dumps the contents of obj for debugging and marks the // field at byte offset off in obj. func gcDumpObject(label string, obj, off uintptr) { s := spanOf(obj) print(label, "=", hex(obj)) if s == nil { print(" s=nil\n") return } print(" s.base()=", hex(s.base()), " s.limit=", hex(s.limit), " s.spanclass=", s.spanclass, " s.elemsize=", s.elemsize, " s.state=") if state := s.state.get(); 0 <= state && int(state) < len(mSpanStateNames) { print(mSpanStateNames[state], "\n") } else { print("unknown(", state, ")\n") } skipped := false size := s.elemsize if s.state.get() == mSpanManual && size == 0 { // We're printing something from a stack frame. We // don't know how big it is, so just show up to an // including off. size = off + sys.PtrSize } for i := uintptr(0); i < size; i += sys.PtrSize { // For big objects, just print the beginning (because // that usually hints at the object's type) and the // fields around off. if !(i < 128*sys.PtrSize || off-16*sys.PtrSize < i && i < off+16*sys.PtrSize) { skipped = true continue } if skipped { print(" ...\n") skipped = false } print(" *(", label, "+", i, ") = ", hex(*(*uintptr)(unsafe.Pointer(obj + i)))) if i == off { print(" <==") } print("\n") } if skipped { print(" ...\n") } } // gcmarknewobject marks a newly allocated object black. obj must // not contain any non-nil pointers. // // This is nosplit so it can manipulate a gcWork without preemption. // //go:nowritebarrier //go:nosplit func gcmarknewobject(obj, size, scanSize uintptr) { if useCheckmark { // The world should be stopped so this should not happen. throw("gcmarknewobject called while doing checkmark") } markBitsForAddr(obj).setMarked() gcw := &getg().m.p.ptr().gcw gcw.bytesMarked += uint64(size) gcw.scanWork += int64(scanSize) } // gcMarkTinyAllocs greys all active tiny alloc blocks. // // The world must be stopped. func gcMarkTinyAllocs() { for _, p := range allp { c := p.mcache if c == nil || c.tiny == 0 { continue } _, span, objIndex := findObject(c.tiny, 0, 0) gcw := &p.gcw greyobject(c.tiny, 0, 0, span, gcw, objIndex) } } // Checkmarking // To help debug the concurrent GC we remark with the world // stopped ensuring that any object encountered has their normal // mark bit set. To do this we use an orthogonal bit // pattern to indicate the object is marked. The following pattern // uses the upper two bits in the object's boundary nibble. // 01: scalar not marked // 10: pointer not marked // 11: pointer marked // 00: scalar marked // Xoring with 01 will flip the pattern from marked to unmarked and vica versa. // The higher bit is 1 for pointers and 0 for scalars, whether the object // is marked or not. // The first nibble no longer holds the typeDead pattern indicating that the // there are no more pointers in the object. This information is held // in the second nibble. // If useCheckmark is true, marking of an object uses the // checkmark bits (encoding above) instead of the standard // mark bits. var useCheckmark = false //go:nowritebarrier func initCheckmarks() { useCheckmark = true for _, s := range mheap_.allspans { if s.state.get() == mSpanInUse { heapBitsForAddr(s.base()).initCheckmarkSpan(s.layout()) } } } func clearCheckmarks() { useCheckmark = false for _, s := range mheap_.allspans { if s.state.get() == mSpanInUse { heapBitsForAddr(s.base()).clearCheckmarkSpan(s.layout()) } } }
Close