runtime: ignore failure from madvise

When we release memory to the OS, if the OS doesn't want us
to release it (for example, because the program executed
mlockall(MCL_FUTURE)), madvise will fail. Ignore the failure
instead of crashing.

Fixes #3435.

R=ken2
CC=golang-dev
https://golang.org/cl/6998052
This commit is contained in:
Russ Cox 2012-12-22 15:06:28 -05:00
parent 0de71619ce
commit 295a4d8e64
11 changed files with 11 additions and 26 deletions

View File

@ -47,8 +47,7 @@ TEXT runtime·mmap(SB),7,$0
TEXT runtime·madvise(SB),7,$0
MOVL $75, AX
INT $0x80
JAE 2(PC)
MOVL $0xf1, 0xf1 // crash
// ignore failure - maybe pages are locked
RET
TEXT runtime·munmap(SB),7,$0

View File

@ -61,8 +61,7 @@ TEXT runtime·madvise(SB), 7, $0
MOVL 24(SP), DX // arg 3 advice
MOVL $(0x2000000+75), AX // syscall entry madvise
SYSCALL
JCC 2(PC)
MOVL $0xf1, 0xf1 // crash
// ignore failure - maybe pages are locked
RET
// OS X comm page time offsets

View File

@ -105,8 +105,7 @@ TEXT runtime·munmap(SB),7,$-4
TEXT runtime·madvise(SB),7,$-4
MOVL $75, AX // madvise
INT $0x80
JAE 2(PC)
MOVL $0xf1, 0xf1 // crash
// ignore failure - maybe pages are locked
RET
TEXT runtime·setitimer(SB), 7, $-4

View File

@ -188,8 +188,7 @@ TEXT runtime·madvise(SB),7,$0
MOVQ 24(SP), DX
MOVQ $75, AX // madvise
SYSCALL
JCC 2(PC)
MOVL $0xf1, 0xf1 // crash
// ignore failure - maybe pages are locked
RET
TEXT runtime·sigaltstack(SB),7,$-8

View File

@ -189,8 +189,7 @@ TEXT runtime·madvise(SB),7,$0
MOVW 4(FP), R1 // arg 2 len
MOVW 8(FP), R2 // arg 3 flags
SWI $75
MOVW.CS $0, R9 // crash on syscall failure
MOVW.CS R9, (R9)
// ignore failure - maybe pages are locked
RET
TEXT runtime·sigaltstack(SB),7,$-8

View File

@ -241,9 +241,7 @@ TEXT runtime·madvise(SB),7,$0
MOVL 8(SP), CX
MOVL 12(SP), DX
CALL *runtime·_vdso(SB)
CMPL AX, $0xfffff001
JLS 2(PC)
INT $3
// ignore failure - maybe pages are locked
RET
// int32 futex(int32 *uaddr, int32 op, int32 val,

View File

@ -250,9 +250,7 @@ TEXT runtime·madvise(SB),7,$0
MOVQ 24(SP), DX
MOVQ $28, AX // madvise
SYSCALL
CMPQ AX, $0xfffffffffffff001
JLS 2(PC)
MOVL $0xf1, 0xf1 // crash
// ignore failure - maybe pages are locked
RET
// int64 futex(int32 *uaddr, int32 op, int32 val,

View File

@ -133,10 +133,7 @@ TEXT runtime·madvise(SB),7,$0
MOVW 8(FP), R2
MOVW $SYS_madvise, R7
SWI $0
MOVW $0xfffff001, R6
CMP R6, R0
MOVW.HI $0, R9 // crash on syscall failure
MOVW.HI R9, (R9)
// ignore failure - maybe pages are locked
RET
TEXT runtime·setitimer(SB),7,$0

View File

@ -86,8 +86,7 @@ TEXT runtime·munmap(SB),7,$-4
TEXT runtime·madvise(SB),7,$-4
MOVL $75, AX // sys_madvise
INT $0x80
JAE 2(PC)
MOVL $0xf1, 0xf1 // crash
// ignore failure - maybe pages are locked
RET
TEXT runtime·setitimer(SB),7,$-4

View File

@ -252,8 +252,7 @@ TEXT runtime·madvise(SB),7,$0
MOVQ behav+16(FP), DX // arg 3 - behav
MOVQ $75, AX // sys_madvise
SYSCALL
JCC 2(PC)
MOVL $0xf1, 0xf1 // crash
// ignore failure - maybe pages are locked
RET
TEXT runtime·sigaltstack(SB),7,$-8

View File

@ -240,8 +240,7 @@ TEXT runtime·madvise(SB),7,$0
MOVQ behav+16(FP), DX // arg 3 - behav
MOVQ $75, AX // sys_madvise
SYSCALL
JCC 2(PC)
MOVL $0xf1, 0xf1 // crash
// ignore failure - maybe pages are locked
RET
TEXT runtime·sigaltstack(SB),7,$-8