!412 [sync] PR-400: sync upstream patches
Merge pull request !412 from openeuler-sync-bot/sync-pr400-master-to-openEuler-24.03-LTS
This commit is contained in:
commit
588df37ce2
@ -0,0 +1,79 @@
|
||||
From fef8644451930464ffd9f13c82bcd451f58fa575 Mon Sep 17 00:00:00 2001
|
||||
From: Andy Pan <panjf2000@gmail.com>
|
||||
Date: Tue, 17 Oct 2023 22:38:17 +0800
|
||||
Subject: [PATCH 03/20] [release-branch.go1.21] internal/poll: add
|
||||
SPLICE_F_NONBLOCK flag for splice to avoid inconsistency with O_NONBLOCK
|
||||
|
||||
Fixes #63801
|
||||
Updates #59041
|
||||
Updates #63795
|
||||
|
||||
Conflict:NA
|
||||
Reference:https://go-review.googlesource.com/c/go/+/536015
|
||||
|
||||
Details: https://github.com/golang/go/issues/59041#issuecomment-1766610087
|
||||
|
||||
Change-Id: Id3fc1df6d86b7c4cc383d09f9465fa8f4cc2a559
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/536015
|
||||
Reviewed-by: Bryan Mills <bcmills@google.com>
|
||||
Reviewed-by: Ian Lance Taylor <iant@google.com>
|
||||
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
||||
Auto-Submit: Ian Lance Taylor <iant@google.com>
|
||||
(cherry picked from commit 40cdf69fc9279ab28f84a6e0f965de8382c578fe)
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/538117
|
||||
Auto-Submit: Heschi Kreinick <heschi@google.com>
|
||||
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
|
||||
Reviewed-by: Heschi Kreinick <heschi@google.com>
|
||||
---
|
||||
src/internal/poll/splice_linux.go | 21 +++++++++++++++++++--
|
||||
1 file changed, 19 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/internal/poll/splice_linux.go b/src/internal/poll/splice_linux.go
|
||||
index 9505c5dcfc1e..72cca34fe4ae 100644
|
||||
--- a/src/internal/poll/splice_linux.go
|
||||
+++ b/src/internal/poll/splice_linux.go
|
||||
@@ -13,6 +13,12 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
+ // spliceNonblock doesn't make the splice itself necessarily nonblocking
|
||||
+ // (because the actual file descriptors that are spliced from/to may block
|
||||
+ // unless they have the O_NONBLOCK flag set), but it makes the splice pipe
|
||||
+ // operations nonblocking.
|
||||
+ spliceNonblock = 0x2
|
||||
+
|
||||
// maxSpliceSize is the maximum amount of data Splice asks
|
||||
// the kernel to move in a single call to splice(2).
|
||||
// We use 1MB as Splice writes data through a pipe, and 1MB is the default maximum pipe buffer size,
|
||||
@@ -89,7 +95,11 @@ func spliceDrain(pipefd int, sock *FD, max int) (int, error) {
|
||||
return 0, err
|
||||
}
|
||||
for {
|
||||
- n, err := splice(pipefd, sock.Sysfd, max, 0)
|
||||
+ // In theory calling splice(2) with SPLICE_F_NONBLOCK could end up an infinite loop here,
|
||||
+ // because it could return EAGAIN ceaselessly when the write end of the pipe is full,
|
||||
+ // but this shouldn't be a concern here, since the pipe buffer must be sufficient for
|
||||
+ // this data transmission on the basis of the workflow in Splice.
|
||||
+ n, err := splice(pipefd, sock.Sysfd, max, spliceNonblock)
|
||||
if err == syscall.EINTR {
|
||||
continue
|
||||
}
|
||||
@@ -127,7 +137,14 @@ func splicePump(sock *FD, pipefd int, inPipe int) (int, error) {
|
||||
}
|
||||
written := 0
|
||||
for inPipe > 0 {
|
||||
- n, err := splice(sock.Sysfd, pipefd, inPipe, 0)
|
||||
+ // In theory calling splice(2) with SPLICE_F_NONBLOCK could end up an infinite loop here,
|
||||
+ // because it could return EAGAIN ceaselessly when the read end of the pipe is empty,
|
||||
+ // but this shouldn't be a concern here, since the pipe buffer must contain inPipe size of
|
||||
+ // data on the basis of the workflow in Splice.
|
||||
+ n, err := splice(sock.Sysfd, pipefd, inPipe, spliceNonblock)
|
||||
+ if err == syscall.EINTR {
|
||||
+ continue
|
||||
+ }
|
||||
// Here, the condition n == 0 && err == nil should never be
|
||||
// observed, since Splice controls the write side of the pipe.
|
||||
if n > 0 {
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -0,0 +1,89 @@
|
||||
From 05bf700ebeec865b73500bd6a2ae93ddbd051692 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Anthony Knyszek <mknyszek@google.com>
|
||||
Date: Fri, 10 Nov 2023 21:23:38 +0000
|
||||
Subject: [PATCH 04/20] [release-branch.go1.21] runtime: call
|
||||
enableMetadataHugePages and its callees on the systemstack
|
||||
|
||||
Conflict:NA
|
||||
Reference:https://go-review.googlesource.com/c/go/+/541635
|
||||
|
||||
These functions acquire the heap lock. If they're not called on the
|
||||
systemstack, a stack growth could cause a self-deadlock since stack
|
||||
growth may allocate memory from the page heap.
|
||||
|
||||
This has been a problem for a while. If this is what's plaguing the
|
||||
ppc64 port right now, it's very surprising (and probably just
|
||||
coincidental) that it's showing up now.
|
||||
|
||||
For #64050.
|
||||
For #64062.
|
||||
For #64067.
|
||||
Fixes #64073.
|
||||
|
||||
Change-Id: I2b95dc134d17be63b9fe8f7a3370fe5b5438682f
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/541635
|
||||
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
||||
Run-TryBot: Michael Knyszek <mknyszek@google.com>
|
||||
Auto-Submit: Michael Knyszek <mknyszek@google.com>
|
||||
TryBot-Result: Gopher Robot <gobot@golang.org>
|
||||
Reviewed-by: Michael Pratt <mpratt@google.com>
|
||||
Reviewed-by: Paul Murphy <murp@ibm.com>
|
||||
(cherry picked from commit 5f08b4479930af266d4a84c1533b320ed75edba7)
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/541955
|
||||
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
|
||||
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
|
||||
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
|
||||
---
|
||||
src/runtime/malloc.go | 4 ++++
|
||||
src/runtime/mgc.go | 4 +++-
|
||||
src/runtime/mpagealloc.go | 4 ++++
|
||||
3 files changed, 11 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
|
||||
index 44479cc2be26..b2026ad0dc72 100644
|
||||
--- a/src/runtime/malloc.go
|
||||
+++ b/src/runtime/malloc.go
|
||||
@@ -853,6 +853,10 @@ retry:
|
||||
//
|
||||
// The heap lock must not be held over this operation, since it will briefly acquire
|
||||
// the heap lock.
|
||||
+//
|
||||
+// Must be called on the system stack because it acquires the heap lock.
|
||||
+//
|
||||
+//go:systemstack
|
||||
func (h *mheap) enableMetadataHugePages() {
|
||||
// Enable huge pages for page structure.
|
||||
h.pages.enableChunkHugePages()
|
||||
diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go
|
||||
index de5ae0ae00c4..a12dbfe9df29 100644
|
||||
--- a/src/runtime/mgc.go
|
||||
+++ b/src/runtime/mgc.go
|
||||
@@ -1186,7 +1186,9 @@ func gcMarkTermination() {
|
||||
|
||||
// Enable huge pages on some metadata if we cross a heap threshold.
|
||||
if gcController.heapGoal() > minHeapForMetadataHugePages {
|
||||
- mheap_.enableMetadataHugePages()
|
||||
+ systemstack(func() {
|
||||
+ mheap_.enableMetadataHugePages()
|
||||
+ })
|
||||
}
|
||||
|
||||
semrelease(&worldsema)
|
||||
diff --git a/src/runtime/mpagealloc.go b/src/runtime/mpagealloc.go
|
||||
index 3e789ab85cc0..2861fa93ebf0 100644
|
||||
--- a/src/runtime/mpagealloc.go
|
||||
+++ b/src/runtime/mpagealloc.go
|
||||
@@ -437,6 +437,10 @@ func (p *pageAlloc) grow(base, size uintptr) {
|
||||
//
|
||||
// The heap lock must not be held over this operation, since it will briefly acquire
|
||||
// the heap lock.
|
||||
+//
|
||||
+// Must be called on the system stack because it acquires the heap lock.
|
||||
+//
|
||||
+//go:systemstack
|
||||
func (p *pageAlloc) enableChunkHugePages() {
|
||||
// Grab the heap lock to turn on huge pages for new chunks and clone the current
|
||||
// heap address space ranges.
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -0,0 +1,91 @@
|
||||
From 4ef68a16e21a2e63f2f6bdc498fe34c9ca994011 Mon Sep 17 00:00:00 2001
|
||||
From: Jorropo <jorropo.pgm@gmail.com>
|
||||
Date: Sun, 5 Nov 2023 22:40:01 +0100
|
||||
Subject: [PATCH 05/20] [release-branch.go1.21] cmd/compile: fix findIndVar so
|
||||
it does not match disjointed loop headers
|
||||
|
||||
Fix #63984
|
||||
|
||||
Conflict:NA
|
||||
Reference:https://go-review.googlesource.com/c/go/+/539977
|
||||
|
||||
parseIndVar, prove and maybe more are on the assumption that the loop header
|
||||
is a single block. This can be wrong, ensure we don't match theses cases we
|
||||
don't know how to handle.
|
||||
|
||||
In the future we could update them so that they know how to handle such cases
|
||||
but theses cases seems rare so I don't think the value would be really high.
|
||||
We could also run a loop canonicalization pass first which could handle this.
|
||||
|
||||
The repro case looks weird because I massaged it so it would crash with the
|
||||
previous compiler.
|
||||
|
||||
Change-Id: I4aa8afae9e90a17fa1085832250fc1139c97faa6
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/539977
|
||||
Reviewed-by: Heschi Kreinick <heschi@google.com>
|
||||
Reviewed-by: Keith Randall <khr@golang.org>
|
||||
Reviewed-by: Keith Randall <khr@google.com>
|
||||
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
||||
(cherry picked from commit 8b4e1259d0e82c8fe38a1456f997a4e9d63573a2)
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/540535
|
||||
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
|
||||
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
|
||||
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
|
||||
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
|
||||
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
|
||||
Reviewed-by: Michael Knyszek <mknyszek@google.com>
|
||||
---
|
||||
src/cmd/compile/internal/ssa/loopbce.go | 7 +++++++
|
||||
test/fixedbugs/issue63955.go | 22 ++++++++++++++++++++++
|
||||
2 files changed, 29 insertions(+)
|
||||
create mode 100644 test/fixedbugs/issue63955.go
|
||||
|
||||
diff --git a/src/cmd/compile/internal/ssa/loopbce.go b/src/cmd/compile/internal/ssa/loopbce.go
|
||||
index b7dfaa33e3bf..7f432e61ba50 100644
|
||||
--- a/src/cmd/compile/internal/ssa/loopbce.go
|
||||
+++ b/src/cmd/compile/internal/ssa/loopbce.go
|
||||
@@ -127,6 +127,13 @@ func findIndVar(f *Func) []indVar {
|
||||
less = false
|
||||
}
|
||||
|
||||
+ if ind.Block != b {
|
||||
+ // TODO: Could be extended to include disjointed loop headers.
|
||||
+ // I don't think this is causing missed optimizations in real world code often.
|
||||
+ // See https://go.dev/issue/63955
|
||||
+ continue
|
||||
+ }
|
||||
+
|
||||
// Expect the increment to be a nonzero constant.
|
||||
if !inc.isGenericIntConst() {
|
||||
continue
|
||||
diff --git a/test/fixedbugs/issue63955.go b/test/fixedbugs/issue63955.go
|
||||
new file mode 100644
|
||||
index 000000000000..258e874220f0
|
||||
--- /dev/null
|
||||
+++ b/test/fixedbugs/issue63955.go
|
||||
@@ -0,0 +1,22 @@
|
||||
+// compile
|
||||
+
|
||||
+// Copyright 2023 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.
|
||||
+
|
||||
+package j
|
||||
+
|
||||
+func f(try func() int, shouldInc func() bool, N func(int) int) {
|
||||
+ var n int
|
||||
+loop: // we want to have 3 preds here, the function entry and both gotos
|
||||
+ if v := try(); v == 42 || v == 1337 { // the two || are to trick findIndVar
|
||||
+ if n < 30 { // this aims to be the matched block
|
||||
+ if shouldInc() {
|
||||
+ n++
|
||||
+ goto loop
|
||||
+ }
|
||||
+ n = N(n) // try to prevent some block joining
|
||||
+ goto loop
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
14
golang.spec
14
golang.spec
@ -66,7 +66,7 @@
|
||||
|
||||
Name: golang
|
||||
Version: 1.21.4
|
||||
Release: 17
|
||||
Release: 20
|
||||
Summary: The Go Programming Language
|
||||
License: BSD and Public Domain
|
||||
URL: https://golang.org/
|
||||
@ -136,6 +136,9 @@ Patch6012: backport-0012-net-http-send-body-or-close-connection-on-expect-100.pa
|
||||
Patch6013: backport-0013-release-branch.go1.21-net-http-update-bundled-golang.patch
|
||||
Patch6014: backport-0014-cmd-compile-handle-constant-pointer-offsets-in-dead-.patch
|
||||
Patch6015: backport-0015-release-branch.go1.21-cmd-compile-ensure-pointer-ari.patch
|
||||
Patch6016: backport-0016-release-branch.go1.21-internal-poll-add-SPLICE_F_NON.patch
|
||||
Patch6017: backport-0017-release-branch.go1.21-runtime-call-enableMetadataHug.patch
|
||||
Patch6018: backport-0018-release-branch.go1.21-cmd-compile-fix-findIndVar-so-.patch
|
||||
|
||||
ExclusiveArch: %{golang_arches}
|
||||
|
||||
@ -374,6 +377,15 @@ fi
|
||||
%files devel -f go-tests.list -f go-misc.list -f go-src.list
|
||||
|
||||
%changelog
|
||||
* Thu Aug 1 2024 EulerOSWander <314264452@qq.com> - 1.21.4-20
|
||||
- cmd/compile: fix findIndVar so it does not match disjointed loop headers
|
||||
|
||||
* Thu Aug 1 2024 EulerOSWander <314264452@qq.com> - 1.21.4-19
|
||||
- runtime: call enableMetadataHugePages and its callees on the systemstack
|
||||
|
||||
* Thu Aug 1 2024 EulerOSWander <314264452@qq.com> - 1.21.4-18
|
||||
- internal/poll:add SPLICE_F_NONBLOCK flag for splice to avoid insonsistency with O_NONBLOCK
|
||||
|
||||
* Mon Jul 30 2024 jingxiaolu <lujingxiao@huawei.com> - 1.21.4-17
|
||||
- cmd/compile: ensure pointer arithmetic happens after the nil check
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user