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 : mgcscavenge.go
// Copyright 2019 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. // Scavenging free pages. // // This file implements scavenging (the release of physical pages backing mapped // memory) of free and unused pages in the heap as a way to deal with page-level // fragmentation and reduce the RSS of Go applications. // // Scavenging in Go happens on two fronts: there's the background // (asynchronous) scavenger and the heap-growth (synchronous) scavenger. // // The former happens on a goroutine much like the background sweeper which is // soft-capped at using scavengePercent of the mutator's time, based on // order-of-magnitude estimates of the costs of scavenging. The background // scavenger's primary goal is to bring the estimated heap RSS of the // application down to a goal. // // That goal is defined as: // (retainExtraPercent+100) / 100 * (next_gc / last_next_gc) * last_heap_inuse // // Essentially, we wish to have the application's RSS track the heap goal, but // the heap goal is defined in terms of bytes of objects, rather than pages like // RSS. As a result, we need to take into account for fragmentation internal to // spans. next_gc / last_next_gc defines the ratio between the current heap goal // and the last heap goal, which tells us by how much the heap is growing and // shrinking. We estimate what the heap will grow to in terms of pages by taking // this ratio and multiplying it by heap_inuse at the end of the last GC, which // allows us to account for this additional fragmentation. Note that this // procedure makes the assumption that the degree of fragmentation won't change // dramatically over the next GC cycle. Overestimating the amount of // fragmentation simply results in higher memory use, which will be accounted // for by the next pacing up date. Underestimating the fragmentation however // could lead to performance degradation. Handling this case is not within the // scope of the scavenger. Situations where the amount of fragmentation balloons // over the course of a single GC cycle should be considered pathologies, // flagged as bugs, and fixed appropriately. // // An additional factor of retainExtraPercent is added as a buffer to help ensure // that there's more unscavenged memory to allocate out of, since each allocation // out of scavenged memory incurs a potentially expensive page fault. // // The goal is updated after each GC and the scavenger's pacing parameters // (which live in mheap_) are updated to match. The pacing parameters work much // like the background sweeping parameters. The parameters define a line whose // horizontal axis is time and vertical axis is estimated heap RSS, and the // scavenger attempts to stay below that line at all times. // // The synchronous heap-growth scavenging happens whenever the heap grows in // size, for some definition of heap-growth. The intuition behind this is that // the application had to grow the heap because existing fragments were // not sufficiently large to satisfy a page-level memory allocation, so we // scavenge those fragments eagerly to offset the growth in RSS that results. package runtime import ( "runtime/internal/atomic" "runtime/internal/sys" "unsafe" ) const ( // The background scavenger is paced according to these parameters. // // scavengePercent represents the portion of mutator time we're willing // to spend on scavenging in percent. scavengePercent = 1 // 1% // retainExtraPercent represents the amount of memory over the heap goal // that the scavenger should keep as a buffer space for the allocator. // // The purpose of maintaining this overhead is to have a greater pool of // unscavenged memory available for allocation (since using scavenged memory // incurs an additional cost), to account for heap fragmentation and // the ever-changing layout of the heap. retainExtraPercent = 10 // maxPagesPerPhysPage is the maximum number of supported runtime pages per // physical page, based on maxPhysPageSize. maxPagesPerPhysPage = maxPhysPageSize / pageSize // scavengeCostRatio is the approximate ratio between the costs of using previously // scavenged memory and scavenging memory. // // For most systems the cost of scavenging greatly outweighs the costs // associated with using scavenged memory, making this constant 0. On other systems // (especially ones where "sysUsed" is not just a no-op) this cost is non-trivial. // // This ratio is used as part of multiplicative factor to help the scavenger account // for the additional costs of using scavenged memory in its pacing. scavengeCostRatio = 0.7 * sys.GoosDarwin ) // heapRetained returns an estimate of the current heap RSS. func heapRetained() uint64 { return atomic.Load64(&memstats.heap_sys) - atomic.Load64(&memstats.heap_released) } // gcPaceScavenger updates the scavenger's pacing, particularly // its rate and RSS goal. // // The RSS goal is based on the current heap goal with a small overhead // to accommodate non-determinism in the allocator. // // The pacing is based on scavengePageRate, which applies to both regular and // huge pages. See that constant for more information. // // mheap_.lock must be held or the world must be stopped. func gcPaceScavenger() { // If we're called before the first GC completed, disable scavenging. // We never scavenge before the 2nd GC cycle anyway (we don't have enough // information about the heap yet) so this is fine, and avoids a fault // or garbage data later. if memstats.last_next_gc == 0 { mheap_.scavengeGoal = ^uint64(0) return } // Compute our scavenging goal. goalRatio := float64(memstats.next_gc) / float64(memstats.last_next_gc) retainedGoal := uint64(float64(memstats.last_heap_inuse) * goalRatio) // Add retainExtraPercent overhead to retainedGoal. This calculation // looks strange but the purpose is to arrive at an integer division // (e.g. if retainExtraPercent = 12.5, then we get a divisor of 8) // that also avoids the overflow from a multiplication. retainedGoal += retainedGoal / (1.0 / (retainExtraPercent / 100.0)) // Align it to a physical page boundary to make the following calculations // a bit more exact. retainedGoal = (retainedGoal + uint64(physPageSize) - 1) &^ (uint64(physPageSize) - 1) // Represents where we are now in the heap's contribution to RSS in bytes. // // Guaranteed to always be a multiple of physPageSize on systems where // physPageSize <= pageSize since we map heap_sys at a rate larger than // any physPageSize and released memory in multiples of the physPageSize. // // However, certain functions recategorize heap_sys as other stats (e.g. // stack_sys) and this happens in multiples of pageSize, so on systems // where physPageSize > pageSize the calculations below will not be exact. // Generally this is OK since we'll be off by at most one regular // physical page. retainedNow := heapRetained() // If we're already below our goal, or within one page of our goal, then disable // the background scavenger. We disable the background scavenger if there's // less than one physical page of work to do because it's not worth it. if retainedNow <= retainedGoal || retainedNow-retainedGoal < uint64(physPageSize) { mheap_.scavengeGoal = ^uint64(0) return } mheap_.scavengeGoal = retainedGoal mheap_.pages.resetScavengeAddr() } // Sleep/wait state of the background scavenger. var scavenge struct { lock mutex g *g parked bool timer *timer } // wakeScavenger unparks the scavenger if necessary. It must be called // after any pacing update. // // mheap_.lock and scavenge.lock must not be held. func wakeScavenger() { lock(&scavenge.lock) if scavenge.parked { // Try to stop the timer but we don't really care if we succeed. // It's possible that either a timer was never started, or that // we're racing with it. // In the case that we're racing with there's the low chance that // we experience a spurious wake-up of the scavenger, but that's // totally safe. stopTimer(scavenge.timer) // Unpark the goroutine and tell it that there may have been a pacing // change. Note that we skip the scheduler's runnext slot because we // want to avoid having the scavenger interfere with the fair // scheduling of user goroutines. In effect, this schedules the // scavenger at a "lower priority" but that's OK because it'll // catch up on the work it missed when it does get scheduled. scavenge.parked = false systemstack(func() { ready(scavenge.g, 0, false) }) } unlock(&scavenge.lock) } // scavengeSleep attempts to put the scavenger to sleep for ns. // // Note that this function should only be called by the scavenger. // // The scavenger may be woken up earlier by a pacing change, and it may not go // to sleep at all if there's a pending pacing change. // // Returns the amount of time actually slept. func scavengeSleep(ns int64) int64 { lock(&scavenge.lock) // Set the timer. // // This must happen here instead of inside gopark // because we can't close over any variables without // failing escape analysis. start := nanotime() resetTimer(scavenge.timer, start+ns) // Mark ourself as asleep and go to sleep. scavenge.parked = true goparkunlock(&scavenge.lock, waitReasonSleep, traceEvGoSleep, 2) // Return how long we actually slept for. return nanotime() - start } // Background scavenger. // // The background scavenger maintains the RSS of the application below // the line described by the proportional scavenging statistics in // the mheap struct. func bgscavenge(c chan int) { scavenge.g = getg() lock(&scavenge.lock) scavenge.parked = true scavenge.timer = new(timer) scavenge.timer.f = func(_ interface{}, _ uintptr) { wakeScavenger() } c <- 1 goparkunlock(&scavenge.lock, waitReasonGCScavengeWait, traceEvGoBlock, 1) // Exponentially-weighted moving average of the fraction of time this // goroutine spends scavenging (that is, percent of a single CPU). // It represents a measure of scheduling overheads which might extend // the sleep or the critical time beyond what's expected. Assume no // overhead to begin with. // // TODO(mknyszek): Consider making this based on total CPU time of the // application (i.e. scavengePercent * GOMAXPROCS). This isn't really // feasible now because the scavenger acquires the heap lock over the // scavenging operation, which means scavenging effectively blocks // allocators and isn't scalable. However, given a scalable allocator, // it makes sense to also make the scavenger scale with it; if you're // allocating more frequently, then presumably you're also generating // more work for the scavenger. const idealFraction = scavengePercent / 100.0 scavengeEWMA := float64(idealFraction) for { released := uintptr(0) // Time in scavenging critical section. crit := float64(0) // Run on the system stack since we grab the heap lock, // and a stack growth with the heap lock means a deadlock. systemstack(func() { lock(&mheap_.lock) // If background scavenging is disabled or if there's no work to do just park. retained, goal := heapRetained(), mheap_.scavengeGoal if retained <= goal { unlock(&mheap_.lock) return } unlock(&mheap_.lock) // Scavenge one page, and measure the amount of time spent scavenging. start := nanotime() released = mheap_.pages.scavengeOne(physPageSize, false) atomic.Xadduintptr(&mheap_.pages.scavReleased, released) crit = float64(nanotime() - start) }) if released == 0 { lock(&scavenge.lock) scavenge.parked = true goparkunlock(&scavenge.lock, waitReasonGCScavengeWait, traceEvGoBlock, 1) continue } if released < physPageSize { // If this happens, it means that we may have attempted to release part // of a physical page, but the likely effect of that is that it released // the whole physical page, some of which may have still been in-use. // This could lead to memory corruption. Throw. throw("released less than one physical page of memory") } // On some platforms we may see crit as zero if the time it takes to scavenge // memory is less than the minimum granularity of its clock (e.g. Windows). // In this case, just assume scavenging takes 10 µs per regular physical page // (determined empirically), and conservatively ignore the impact of huge pages // on timing. // // We shouldn't ever see a crit value less than zero unless there's a bug of // some kind, either on our side or in the platform we're running on, but be // defensive in that case as well. const approxCritNSPerPhysicalPage = 10e3 if crit <= 0 { crit = approxCritNSPerPhysicalPage * float64(released/physPageSize) } // Multiply the critical time by 1 + the ratio of the costs of using // scavenged memory vs. scavenging memory. This forces us to pay down // the cost of reusing this memory eagerly by sleeping for a longer period // of time and scavenging less frequently. More concretely, we avoid situations // where we end up scavenging so often that we hurt allocation performance // because of the additional overheads of using scavenged memory. crit *= 1 + scavengeCostRatio // If we spent more than 10 ms (for example, if the OS scheduled us away, or someone // put their machine to sleep) in the critical section, bound the time we use to // calculate at 10 ms to avoid letting the sleep time get arbitrarily high. const maxCrit = 10e6 if crit > maxCrit { crit = maxCrit } // Compute the amount of time to sleep, assuming we want to use at most // scavengePercent of CPU time. Take into account scheduling overheads // that may extend the length of our sleep by multiplying by how far // off we are from the ideal ratio. For example, if we're sleeping too // much, then scavengeEMWA < idealFraction, so we'll adjust the sleep time // down. adjust := scavengeEWMA / idealFraction sleepTime := int64(adjust * crit / (scavengePercent / 100.0)) // Go to sleep. slept := scavengeSleep(sleepTime) // Compute the new ratio. fraction := crit / (crit + float64(slept)) // Set a lower bound on the fraction. // Due to OS-related anomalies we may "sleep" for an inordinate amount // of time. Let's avoid letting the ratio get out of hand by bounding // the sleep time we use in our EWMA. const minFraction = 1 / 1000 if fraction < minFraction { fraction = minFraction } // Update scavengeEWMA by merging in the new crit/slept ratio. const alpha = 0.5 scavengeEWMA = alpha*fraction + (1-alpha)*scavengeEWMA } } // scavenge scavenges nbytes worth of free pages, starting with the // highest address first. Successive calls continue from where it left // off until the heap is exhausted. Call resetScavengeAddr to bring it // back to the top of the heap. // // Returns the amount of memory scavenged in bytes. // // If locked == false, s.mheapLock must not be locked. If locked == true, // s.mheapLock must be locked. // // Must run on the system stack because scavengeOne must run on the // system stack. // //go:systemstack func (s *pageAlloc) scavenge(nbytes uintptr, locked bool) uintptr { released := uintptr(0) for released < nbytes { r := s.scavengeOne(nbytes-released, locked) if r == 0 { // Nothing left to scavenge! Give up. break } released += r } return released } // printScavTrace prints a scavenge trace line to standard error. // // released should be the amount of memory released since the last time this // was called, and forced indicates whether the scavenge was forced by the // application. func printScavTrace(released uintptr, forced bool) { printlock() print("scav ", released>>10, " KiB work, ", atomic.Load64(&memstats.heap_released)>>10, " KiB total, ", (atomic.Load64(&memstats.heap_inuse)*100)/heapRetained(), "% util", ) if forced { print(" (forced)") } println() printunlock() } // resetScavengeAddr sets the scavenge start address to the top of the heap's // address space. This should be called each time the scavenger's pacing // changes. // // s.mheapLock must be held. func (s *pageAlloc) resetScavengeAddr() { released := atomic.Loaduintptr(&s.scavReleased) if debug.scavtrace > 0 { printScavTrace(released, false) } // Subtract from scavReleased instead of just setting it to zero because // the scavenger could have increased scavReleased concurrently with the // load above, and we may miss an update by just blindly zeroing the field. atomic.Xadduintptr(&s.scavReleased, -released) s.scavAddr = chunkBase(s.end) - 1 } // scavengeOne starts from s.scavAddr and walks down the heap until it finds // a contiguous run of pages to scavenge. It will try to scavenge at most // max bytes at once, but may scavenge more to avoid breaking huge pages. Once // it scavenges some memory it returns how much it scavenged and updates s.scavAddr // appropriately. s.scavAddr must be reset manually and externally. // // Should it exhaust the heap, it will return 0 and set s.scavAddr to minScavAddr. // // If locked == false, s.mheapLock must not be locked. // If locked == true, s.mheapLock must be locked. // // Must be run on the system stack because it either acquires the heap lock // or executes with the heap lock acquired. // //go:systemstack func (s *pageAlloc) scavengeOne(max uintptr, locked bool) uintptr { // Calculate the maximum number of pages to scavenge. // // This should be alignUp(max, pageSize) / pageSize but max can and will // be ^uintptr(0), so we need to be very careful not to overflow here. // Rather than use alignUp, calculate the number of pages rounded down // first, then add back one if necessary. maxPages := max / pageSize if max%pageSize != 0 { maxPages++ } // Calculate the minimum number of pages we can scavenge. // // Because we can only scavenge whole physical pages, we must // ensure that we scavenge at least minPages each time, aligned // to minPages*pageSize. minPages := physPageSize / pageSize if minPages < 1 { minPages = 1 } // Helpers for locking and unlocking only if locked == false. lockHeap := func() { if !locked { lock(s.mheapLock) } } unlockHeap := func() { if !locked { unlock(s.mheapLock) } } lockHeap() ci := chunkIndex(s.scavAddr) if ci < s.start { unlockHeap() return 0 } // Check the chunk containing the scav addr, starting at the addr // and see if there are any free and unscavenged pages. // // Only check this if s.scavAddr is covered by any address range // in s.inUse, so that we know our check of the summary is safe. if s.inUse.contains(s.scavAddr) && s.summary[len(s.summary)-1][ci].max() >= uint(minPages) { // We only bother looking for a candidate if there at least // minPages free pages at all. It's important that we only // continue if the summary says we can because that's how // we can tell if parts of the address space are unused. // See the comment on s.chunks in mpagealloc.go. base, npages := s.chunkOf(ci).findScavengeCandidate(chunkPageIndex(s.scavAddr), minPages, maxPages) // If we found something, scavenge it and return! if npages != 0 { s.scavengeRangeLocked(ci, base, npages) unlockHeap() return uintptr(npages) * pageSize } } // getInUseRange returns the highest range in the // intersection of [0, addr] and s.inUse. // // s.mheapLock must be held. getInUseRange := func(addr uintptr) addrRange { top := s.inUse.findSucc(addr) if top == 0 { return addrRange{} } r := s.inUse.ranges[top-1] // addr is inclusive, so treat it as such when // updating the limit, which is exclusive. if r.limit > addr+1 { r.limit = addr + 1 } return r } // Slow path: iterate optimistically over the in-use address space // looking for any free and unscavenged page. If we think we see something, // lock and verify it! // // We iterate over the address space by taking ranges from inUse. newRange: for { r := getInUseRange(s.scavAddr) if r.size() == 0 { break } unlockHeap() // Iterate over all of the chunks described by r. // Note that r.limit is the exclusive upper bound, but what // we want is the top chunk instead, inclusive, so subtract 1. bot, top := chunkIndex(r.base), chunkIndex(r.limit-1) for i := top; i >= bot; i-- { // If this chunk is totally in-use or has no unscavenged pages, don't bother // doing a more sophisticated check. // // Note we're accessing the summary and the chunks without a lock, but // that's fine. We're being optimistic anyway. // Check quickly if there are enough free pages at all. if s.summary[len(s.summary)-1][i].max() < uint(minPages) { continue } // Run over the chunk looking harder for a candidate. Again, we could // race with a lot of different pieces of code, but we're just being // optimistic. Make sure we load the l2 pointer atomically though, to // avoid races with heap growth. It may or may not be possible to also // see a nil pointer in this case if we do race with heap growth, but // just defensively ignore the nils. This operation is optimistic anyway. l2 := (*[1 << pallocChunksL2Bits]pallocData)(atomic.Loadp(unsafe.Pointer(&s.chunks[i.l1()]))) if l2 == nil || !l2[i.l2()].hasScavengeCandidate(minPages) { continue } // We found a candidate, so let's lock and verify it. lockHeap() // Find, verify, and scavenge if we can. chunk := s.chunkOf(i) base, npages := chunk.findScavengeCandidate(pallocChunkPages-1, minPages, maxPages) if npages > 0 { // We found memory to scavenge! Mark the bits and report that up. // scavengeRangeLocked will update scavAddr for us, also. s.scavengeRangeLocked(i, base, npages) unlockHeap() return uintptr(npages) * pageSize } // We were fooled, let's take this opportunity to move the scavAddr // all the way down to where we searched as scavenged for future calls // and keep iterating. Then, go get a new range. s.scavAddr = chunkBase(i-1) + pallocChunkPages*pageSize - 1 continue newRange } lockHeap() // Move the scavenger down the heap, past everything we just searched. // Since we don't check if scavAddr moved while twe let go of the heap lock, // it's possible that it moved down and we're moving it up here. This // raciness could result in us searching parts of the heap unnecessarily. // TODO(mknyszek): Remove this racy behavior through explicit address // space reservations, which are difficult to do with just scavAddr. s.scavAddr = r.base - 1 } // We reached the end of the in-use address space and couldn't find anything, // so signal that there's nothing left to scavenge. s.scavAddr = minScavAddr unlockHeap() return 0 } // scavengeRangeLocked scavenges the given region of memory. // // s.mheapLock must be held. func (s *pageAlloc) scavengeRangeLocked(ci chunkIdx, base, npages uint) { s.chunkOf(ci).scavenged.setRange(base, npages) // Compute the full address for the start of the range. addr := chunkBase(ci) + uintptr(base)*pageSize // Update the scav pointer. s.scavAddr = addr - 1 // Only perform the actual scavenging if we're not in a test. // It's dangerous to do so otherwise. if s.test { return } sysUnused(unsafe.Pointer(addr), uintptr(npages)*pageSize) // Update global accounting only when not in test, otherwise // the runtime's accounting will be wrong. mSysStatInc(&memstats.heap_released, uintptr(npages)*pageSize) } // fillAligned returns x but with all zeroes in m-aligned // groups of m bits set to 1 if any bit in the group is non-zero. // // For example, fillAligned(0x0100a3, 8) == 0xff00ff. // // Note that if m == 1, this is a no-op. // // m must be a power of 2 <= maxPagesPerPhysPage. func fillAligned(x uint64, m uint) uint64 { apply := func(x uint64, c uint64) uint64 { // The technique used it here is derived from // https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord // and extended for more than just bytes (like nibbles // and uint16s) by using an appropriate constant. // // To summarize the technique, quoting from that page: // "[It] works by first zeroing the high bits of the [8] // bytes in the word. Subsequently, it adds a number that // will result in an overflow to the high bit of a byte if // any of the low bits were initially set. Next the high // bits of the original word are ORed with these values; // thus, the high bit of a byte is set iff any bit in the // byte was set. Finally, we determine if any of these high // bits are zero by ORing with ones everywhere except the // high bits and inverting the result." return ^((((x & c) + c) | x) | c) } // Transform x to contain a 1 bit at the top of each m-aligned // group of m zero bits. switch m { case 1: return x case 2: x = apply(x, 0x5555555555555555) case 4: x = apply(x, 0x7777777777777777) case 8: x = apply(x, 0x7f7f7f7f7f7f7f7f) case 16: x = apply(x, 0x7fff7fff7fff7fff) case 32: x = apply(x, 0x7fffffff7fffffff) case 64: // == maxPagesPerPhysPage x = apply(x, 0x7fffffffffffffff) default: throw("bad m value") } // Now, the top bit of each m-aligned group in x is set // that group was all zero in the original x. // From each group of m bits subtract 1. // Because we know only the top bits of each // m-aligned group are set, we know this will // set each group to have all the bits set except // the top bit, so just OR with the original // result to set all the bits. return ^((x - (x >> (m - 1))) | x) } // hasScavengeCandidate returns true if there's any min-page-aligned groups of // min pages of free-and-unscavenged memory in the region represented by this // pallocData. // // min must be a non-zero power of 2 <= maxPagesPerPhysPage. func (m *pallocData) hasScavengeCandidate(min uintptr) bool { if min&(min-1) != 0 || min == 0 { print("runtime: min = ", min, "\n") throw("min must be a non-zero power of 2") } else if min > maxPagesPerPhysPage { print("runtime: min = ", min, "\n") throw("min too large") } // The goal of this search is to see if the chunk contains any free and unscavenged memory. for i := len(m.scavenged) - 1; i >= 0; i-- { // 1s are scavenged OR non-free => 0s are unscavenged AND free // // TODO(mknyszek): Consider splitting up fillAligned into two // functions, since here we technically could get by with just // the first half of its computation. It'll save a few instructions // but adds some additional code complexity. x := fillAligned(m.scavenged[i]|m.pallocBits[i], uint(min)) // Quickly skip over chunks of non-free or scavenged pages. if x != ^uint64(0) { return true } } return false } // findScavengeCandidate returns a start index and a size for this pallocData // segment which represents a contiguous region of free and unscavenged memory. // // searchIdx indicates the page index within this chunk to start the search, but // note that findScavengeCandidate searches backwards through the pallocData. As a // a result, it will return the highest scavenge candidate in address order. // // min indicates a hard minimum size and alignment for runs of pages. That is, // findScavengeCandidate will not return a region smaller than min pages in size, // or that is min pages or greater in size but not aligned to min. min must be // a non-zero power of 2 <= maxPagesPerPhysPage. // // max is a hint for how big of a region is desired. If max >= pallocChunkPages, then // findScavengeCandidate effectively returns entire free and unscavenged regions. // If max < pallocChunkPages, it may truncate the returned region such that size is // max. However, findScavengeCandidate may still return a larger region if, for // example, it chooses to preserve huge pages, or if max is not aligned to min (it // will round up). That is, even if max is small, the returned size is not guaranteed // to be equal to max. max is allowed to be less than min, in which case it is as if // max == min. func (m *pallocData) findScavengeCandidate(searchIdx uint, min, max uintptr) (uint, uint) { if min&(min-1) != 0 || min == 0 { print("runtime: min = ", min, "\n") throw("min must be a non-zero power of 2") } else if min > maxPagesPerPhysPage { print("runtime: min = ", min, "\n") throw("min too large") } // max may not be min-aligned, so we might accidentally truncate to // a max value which causes us to return a non-min-aligned value. // To prevent this, align max up to a multiple of min (which is always // a power of 2). This also prevents max from ever being less than // min, unless it's zero, so handle that explicitly. if max == 0 { max = min } else { max = alignUp(max, min) } i := int(searchIdx / 64) // Start by quickly skipping over blocks of non-free or scavenged pages. for ; i >= 0; i-- { // 1s are scavenged OR non-free => 0s are unscavenged AND free x := fillAligned(m.scavenged[i]|m.pallocBits[i], uint(min)) if x != ^uint64(0) { break } } if i < 0 { // Failed to find any free/unscavenged pages. return 0, 0 } // We have something in the 64-bit chunk at i, but it could // extend further. Loop until we find the extent of it. // 1s are scavenged OR non-free => 0s are unscavenged AND free x := fillAligned(m.scavenged[i]|m.pallocBits[i], uint(min)) z1 := uint(sys.LeadingZeros64(^x)) run, end := uint(0), uint(i)*64+(64-z1) if x<<z1 != 0 { // After shifting out z1 bits, we still have 1s, // so the run ends inside this word. run = uint(sys.LeadingZeros64(x << z1)) } else { // After shifting out z1 bits, we have no more 1s. // This means the run extends to the bottom of the // word so it may extend into further words. run = 64 - z1 for j := i - 1; j >= 0; j-- { x := fillAligned(m.scavenged[j]|m.pallocBits[j], uint(min)) run += uint(sys.LeadingZeros64(x)) if x != 0 { // The run stopped in this word. break } } } // Split the run we found if it's larger than max but hold on to // our original length, since we may need it later. size := run if size > uint(max) { size = uint(max) } start := end - size // Each huge page is guaranteed to fit in a single palloc chunk. // // TODO(mknyszek): Support larger huge page sizes. // TODO(mknyszek): Consider taking pages-per-huge-page as a parameter // so we can write tests for this. if physHugePageSize > pageSize && physHugePageSize > physPageSize { // We have huge pages, so let's ensure we don't break one by scavenging // over a huge page boundary. If the range [start, start+size) overlaps with // a free-and-unscavenged huge page, we want to grow the region we scavenge // to include that huge page. // Compute the huge page boundary above our candidate. pagesPerHugePage := uintptr(physHugePageSize / pageSize) hugePageAbove := uint(alignUp(uintptr(start), pagesPerHugePage)) // If that boundary is within our current candidate, then we may be breaking // a huge page. if hugePageAbove <= end { // Compute the huge page boundary below our candidate. hugePageBelow := uint(alignDown(uintptr(start), pagesPerHugePage)) if hugePageBelow >= end-run { // We're in danger of breaking apart a huge page since start+size crosses // a huge page boundary and rounding down start to the nearest huge // page boundary is included in the full run we found. Include the entire // huge page in the bound by rounding down to the huge page size. size = size + (start - hugePageBelow) start = hugePageBelow } } } return start, size }
Close