]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: ignore failure from madvise
authorRuss Cox <rsc@golang.org>
Sat, 22 Dec 2012 20:06:28 +0000 (15:06 -0500)
committerRuss Cox <rsc@golang.org>
Sat, 22 Dec 2012 20:06:28 +0000 (15:06 -0500)
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

src/pkg/runtime/sys_darwin_386.s
src/pkg/runtime/sys_darwin_amd64.s
src/pkg/runtime/sys_freebsd_386.s
src/pkg/runtime/sys_freebsd_amd64.s
src/pkg/runtime/sys_freebsd_arm.s
src/pkg/runtime/sys_linux_386.s
src/pkg/runtime/sys_linux_amd64.s
src/pkg/runtime/sys_linux_arm.s
src/pkg/runtime/sys_netbsd_386.s
src/pkg/runtime/sys_netbsd_amd64.s
src/pkg/runtime/sys_openbsd_amd64.s

index bdbe0737f26ee83b0a07d4378661743cb78d9445..8a938f9f4c5aff5436a175dbbac99ba0766c3109 100644 (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
index c91501a91279a7edba3a1462289a2089cc5d7e2b..4e43a76c3c36ba43669e22df83dab44133fdce73 100644 (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
index a30c7ba01fb86babf784a4a19fad58bc78cf64ed..4a9d7b40faf5d604daa34ba34cd8b243da6b515a 100644 (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
index 7b1359167b946466475e6dd83e2aff41bd771138..e8c0899cf797aebef1f90ae2efcec5ef18e58f25 100644 (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
index ec8134e4c55132263f9a8de8de70e925da962dec..0c30d44957ffccef3680fecc036d9cc3cf53c706 100644 (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
index 60f76fa92fb85dc61c797efd72a96733e634208b..f27fd47130df3a59cb61f1506e0dfa035d89949d 100644 (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,
index 3f7a207f375368cf9ae203f97cabb6faeaf6f15c..e45943758293e826a35d14a26fcf6b2ab8725d35 100644 (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,
index eda7b1f568bd79e4b713319db20d354fe4e4a892..53eb7b19d888c63eb47b4eae134c2be43f4a2187 100644 (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
index 1a4ff95b6d63204d2f8668866d7f9fe3c6130b26..3d3d312736e91f9cfc3341e70b6d0cc1f76017d1 100644 (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
index fc5f28ca79bdde3b0d6bfc4cde0abdc8aa836204..e73e83ded28040ce0d05e0f64f072550f7530b4f 100644 (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
index 49eb7a9815ca838b06365320e9c8dbdef5ef78a6..8a736507ff5b7c71f3a6805087134b89b5465c9b 100644 (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