1. 04 Sep, 2019 1 commit
  2. 09 May, 2019 1 commit
  3. 18 Sep, 2018 1 commit
    • Tobias Klauser's avatar
      runtime: use MADV_FREE on Linux if available · 77f9b272
      Tobias Klauser authored
      On Linux, sysUnused currently uses madvise(MADV_DONTNEED) to signal the
      kernel that a range of allocated memory contains unneeded data. After a
      successful call, the range (but not the data it contained before the
      call to madvise) is still available but the first access to that range
      will unconditionally incur a page fault (needed to 0-fill the range).
      
      A faster alternative is MADV_FREE, available since Linux 4.5. The
      mechanism is very similar, but the page fault will only be incurred if
      the kernel, between the call to madvise and the first access, decides to
      reuse that memory for something else.
      
      In sysUnused, test whether MADV_FREE is supported and fall back to
      MADV_DONTNEED in case it isn't. This requires making the return value of
      the madvise syscall available to the caller, so change runtime.madvise
      to return it.
      
      Fixes #23687
      
      Change-Id: I962c3429000dd9f4a00846461ad128b71201bb04
      Reviewed-on: https://go-review.googlesource.com/135395
      
      
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      77f9b272
  4. 07 Sep, 2018 1 commit
    • Michael Pratt's avatar
      runtime: use tgkill for raise · 43f54c8d
      Michael Pratt authored
      raise uses tkill to send a signal to the current thread. For this use,
      tgkill is functionally equivalent to tkill expect that it also takes the
      pid as the first argument.
      
      Using tgkill makes it simpler to run a Go program in a strict sandbox.
      With kill and tgkill, the sandbox policy (e.g., seccomp) can prevent the
      program from sending signals to other processes by checking that the
      first argument == getpid().
      
      With tkill, the policy must whitelist all tids in the process, which is
      effectively impossible given Go's dynamic thread creation.
      
      Fixes #27548
      
      Change-Id: I8ed282ef1f7215b02ef46de144493e36454029ea
      Reviewed-on: https://go-review.googlesource.com/133975
      
      
      Run-TryBot: Michael Pratt <mpratt@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      43f54c8d
  5. 01 Aug, 2018 1 commit
    • David Wimmer's avatar
      runtime: fix syscall error returns on mips/mips64/ppc64 · acd30e9a
      David Wimmer authored
      The linux syscall functions used in runtime are designed around the calling
      convention of returning errors as negative numbers. On some other systems
      (like mips and ppc) the actual syscalls signal errors in other ways. This
      means that the assembly implementations of the syscall functions on these
      platforms need to transform the return values in the error cases to match
      the expected negative errno values. This was addressed for certain syscalls
      in https://golang.org/cl/19455 and https://golang.org/cl/89235. This patch
      handles the rest of the syscall functions in sys_linux_*.s that return any
      value for mips/mips64/ppc64.
      
      Fixes #23446
      
      Change-Id: I302100261231f76d5850ab2c2ea080170d7dba72
      GitHub-Last-Rev: e358e2b08c76897b13f917cfa12b5085e20337f9
      GitHub-Pull-Request: golang/go#26606
      Reviewed-on: https://go-review.googlesource.com/125895
      
      
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      acd30e9a
  6. 24 Apr, 2018 2 commits
  7. 05 Mar, 2018 1 commit
  8. 17 Feb, 2018 1 commit
  9. 14 Feb, 2018 1 commit
  10. 13 Feb, 2018 1 commit
  11. 12 Feb, 2018 1 commit
    • Austin Clements's avatar
      runtime: use NOFRAME on mips and mips64 · dfbf568c
      Austin Clements authored
      This replaces frame size -4/-8 with the NOFRAME flag in mips and
      mips64 assembly.
      
      This was automated with:
      
      sed -i -e 's/\(^TEXT.*[A-Z]\),\( *\)\$-[84]/\1|NOFRAME,\2$0/' $(find -name '*_mips*.s')
      
      Plus a manual fix to mkduff.go.
      
      The go binary is identical on both architectures before and after this
      change.
      
      Change-Id: I0310384d1a584118c41d1cd3a042bb8ea7227efb
      Reviewed-on: https://go-review.googlesource.com/92044
      
      
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      dfbf568c
  12. 18 Oct, 2017 1 commit
    • Austin Clements's avatar
      runtime: separate error result for mmap · 193088b2
      Austin Clements authored
      Currently mmap returns an unsafe.Pointer that encodes OS errors as
      values less than 4096. In practice this is okay, but it borders on
      being really unsafe: for example, the value has to be checked
      immediately after return and if stack copying were ever to observe
      such a value, it would panic. It's also not remotely idiomatic.
      
      Fix this by making mmap return a separate pointer value and error,
      like a normal Go function.
      
      Updates #22218.
      
      Change-Id: Iefd965095ffc82cc91118872753a5d39d785c3a6
      Reviewed-on: https://go-review.googlesource.com/71270
      
      
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      193088b2
  13. 11 Oct, 2017 1 commit
    • Austin Clements's avatar
      runtime: make it possible to exit Go-created threads · eff2b262
      Austin Clements authored
      Currently, threads created by the runtime exist until the whole
      program exits. For #14592 and #20395, we want to be able to exit and
      clean up threads created by the runtime. This commit implements that
      mechanism.
      
      The main difficulty is how to clean up the g0 stack. In cgo mode and
      on Solaris and Windows where the OS manages thread stacks, we simply
      arrange to return from mstart and let the system clean up the thread.
      If the runtime allocated the g0 stack, then we use a new exitThread
      syscall wrapper that arranges to clear a flag in the M once the stack
      can safely be reaped and call the thread termination syscall.
      
      exitThread is based on the existing exit1 wrapper, which was always
      meant to terminate the calling thread. However, exit1 has never been
      used since it was introduced 9 years ago, so it was broken on several
      platforms. exitThread also has the additional complication of having
      to flag that the stack is unused, which requires some tricks on
      platforms that use the stack for syscalls.
      
      This still leaves the problem of how to reap the unused g0 stacks. For
      this, we move the M from allm to a new freem list as part of the M
      exiting. Later, allocm scans the freem list, finds Ms that are marked
      as done with their stack, removes these from the list and frees their
      g0 stacks. This also allows these Ms to be garbage collected.
      
      This CL does not yet use any of this functionality. Follow-up CLs
      will. Likewise, there are no new tests in this CL because we'll need
      follow-up functionality to test it.
      
      Change-Id: Ic851ee74227b6d39c6fc1219fc71b45d3004bc63
      Reviewed-on: https://go-review.googlesource.com/46037
      
      
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarKeith Randall <khr@golang.org>
      eff2b262
  14. 21 Apr, 2017 1 commit
    • Austin Clements's avatar
      runtime: inform arena placement using sbrk(0) · bb6309cd
      Austin Clements authored
      On 32-bit architectures (or if we fail to map a 64-bit-style arena),
      we try to map the heap arena just above the end of the process image.
      While we can accept any address, using lower addresses is preferable
      because lower addresses cause us to map less of the heap bitmap.
      
      However, if a program is linked against C code that has global
      constructors, those constructors may call brk/sbrk to allocate memory
      (e.g., many C malloc implementations do this for small allocations).
      The brk also starts just above the process image, so this may adjust
      the brk past the beginning of where we want to put the heap arena. In
      this case, the kernel will pick a different address for the arena and
      it will usually be very high (at least, as these things go in a 32-bit
      address space).
      
      Fix this by consulting the current value of the brk and using this in
      addition to the end of the process image to compute the initial arena
      placement.
      
      This is implemented only on Linux currently, since we have no evidence
      that it's an issue on any other OSes.
      
      Fixes #19831.
      
      Change-Id: Id64b45d08d8c91e4f50d92d0339146250b04f2f8
      Reviewed-on: https://go-review.googlesource.com/39810
      
      
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      bb6309cd
  15. 03 Feb, 2017 1 commit
  16. 27 Oct, 2016 1 commit
  17. 24 Sep, 2016 1 commit
    • Ian Lance Taylor's avatar
      runtime: unify some signal handling functions · ab552aa3
      Ian Lance Taylor authored
      Unify the OS-specific versions of msigsave, msigrestore, sigblock,
      updatesigmask, and unblocksig into single versions in signal_unix.go.
      To do this, make sigprocmask work the same way on all systems, which
      required adding a definition of sigprocmask for linux and openbsd.
      Also add a single OS-specific function sigmaskToSigset.
      
      Change-Id: I7cbf75131dddb57eeefe648ef845b0791404f785
      Reviewed-on: https://go-review.googlesource.com/29689
      
      
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
      ab552aa3
  18. 30 Aug, 2016 1 commit
  19. 25 Aug, 2016 1 commit
  20. 04 May, 2016 1 commit
  21. 01 May, 2016 1 commit
    • Cherry Zhang's avatar
      cmd/internal/obj/mips et al.: introduce SB register on mips64x · 98139510
      Cherry Zhang authored
      SB register (R28) is introduced for access external addresses with shorter
      instruction sequences. It is loaded at entry points. External data within
      2G of SB can be accessed this way.
      
      cmd/internal/obj: relocaltion R_ADDRMIPS is split into two relocations
      R_ADDRMIPS and R_ADDRMIPSU, handling the low 16 bits and the "upper" 16
      bits of external addresses, respectively, since the instructios may not
      be adjacent. It might be better if relocation Variant could be used.
      
      cmd/link/internal/mips64: support new relocations.
      
      cmd/compile/internal/mips64: reserve SB register.
      
      runtime: initialize SB register at entry points.
      
      Change-Id: I5f34868f88c5a9698c042a8a1f12f76806c187b9
      Reviewed-on: https://go-review.googlesource.com/19802
      
      Reviewed-by: default avatarMinux Ma <minux@golang.org>
      98139510
  22. 01 Apr, 2016 1 commit
  23. 12 Feb, 2016 1 commit
  24. 12 Nov, 2015 1 commit