payload: {"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/36122","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/36122/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/36122/comments","events_url":"https://api.github.com/repos/golang/go/issues/36122/events","html_url":"https://github.com/golang/go/issues/36122","id":537408336,"node_id":"MDU6SXNzdWU1Mzc0MDgzMzY=","number":36122,"title":"runtime: LockOSThread: unexpected gopreempt","user":{"login":"ChenYahui2019","id":50737858,"node_id":"MDQ6VXNlcjUwNzM3ODU4","avatar_url":"https://avatars0.githubusercontent.com/u/50737858?v=4","gravatar_id":"","url":"https://api.github.com/users/ChenYahui2019","html_url":"https://github.com/ChenYahui2019","followers_url":"https://api.github.com/users/ChenYahui2019/followers","following_url":"https://api.github.com/users/ChenYahui2019/following{/other_user}","gists_url":"https://api.github.com/users/ChenYahui2019/gists{/gist_id}","starred_url":"https://api.github.com/users/ChenYahui2019/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChenYahui2019/subscriptions","organizations_url":"https://api.github.com/users/ChenYahui2019/orgs","repos_url":"https://api.github.com/users/ChenYahui2019/repos","events_url":"https://api.github.com/users/ChenYahui2019/events{/privacy}","received_events_url":"https://api.github.com/users/ChenYahui2019/received_events","type":"User","site_admin":false},"labels":[{"id":373402289,"node_id":"MDU6TGFiZWwzNzM0MDIyODk=","url":"https://api.github.com/repos/golang/go/labels/NeedsInvestigation","name":"NeedsInvestigation","color":"ededed","default":false,"description":"Someone must examine and confirm this is a valid issue and not a duplicate of an existing one."},{"id":357033853,"node_id":"MDU6TGFiZWwzNTcwMzM4NTM=","url":"https://api.github.com/repos/golang/go/labels/WaitingForInfo","name":"WaitingForInfo","color":"ededed","default":false,"description":"Issue is not actionable because of missing required information, which needs to be provided."}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/117","html_url":"https://github.com/golang/go/milestone/117","labels_url":"https://api.github.com/repos/golang/go/milestones/117/labels","id":4737058,"node_id":"MDk6TWlsZXN0b25lNDczNzA1OA==","number":117,"title":"Backlog","description":null,"creator":{"login":"rsc","id":104030,"node_id":"MDQ6VXNlcjEwNDAzMA==","avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"open_issues":952,"closed_issues":93,"state":"open","created_at":"2019-10-09T17:14:22Z","updated_at":"2019-12-20T03:40:22Z","due_on":null,"closed_at":null},"comments":12,"created_at":"2019-12-13T08:15:33Z","updated_at":"2019-12-20T08:50:41Z","closed_at":null,"author_association":"NONE","body":"<!-- Please answer these questions before submitting your issue. Thanks! -->\r\n\r\n### What version of Go are you using (`go version`)?\r\n\r\n<pre>\r\n$ go version\r\ngo version go1.13.4 linux/amd64\r\n\r\n</pre>\r\n\r\n### Does this issue reproduce with the latest release?\r\nNA\r\n\r\n\r\n### What operating system and processor architecture are you using (`go env`)?\r\n\r\n<details><summary><code>go env</code> Output</summary><br><pre>\r\n$ go env\r\nGO111MODULE=\"\"\r\nGOARCH=\"amd64\"\r\nGOBIN=\"\"\r\nGOCACHE=\"/root/.cache/go-build\"\r\nGOENV=\"/root/.config/go/env\"\r\nGOEXE=\"\"\r\nGOFLAGS=\"\"\r\nGOHOSTARCH=\"amd64\"\r\nGOHOSTOS=\"linux\"\r\nGONOPROXY=\"\"\r\nGONOSUMDB=\"\"\r\nGOOS=\"linux\"\r\nGOPATH=\"/root/go\"\r\nGOPRIVATE=\"\"\r\nGOPROXY=\"https://proxy.golang.org,direct\"\r\nGOROOT=\"/usr/lib/golang\"\r\nGOSUMDB=\"sum.golang.org\"\r\nGOTMPDIR=\"\"\r\nGOTOOLDIR=\"/usr/lib/golang/pkg/tool/linux_amd64\"\r\nGCCGO=\"gccgo\"\r\nAR=\"ar\"\r\nCC=\"gcc\"\r\nCXX=\"g++\"\r\nCGO_ENABLED=\"1\"\r\nGOMOD=\"\"\r\nCGO_CFLAGS=\"-g -O2\"\r\nCGO_CPPFLAGS=\"\"\r\nCGO_CXXFLAGS=\"-g -O2\"\r\nCGO_FFLAGS=\"-g -O2\"\r\nCGO_LDFLAGS=\"-g -O2\"\r\nPKG_CONFIG=\"pkg-config\"\r\nGOGCCFLAGS=\"-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build467654165=/tmp/go-build -gno-record-gcc-switches\"\r\n\r\n</pre></details>\r\n\r\n### What did you do?\r\n\r\n<!--\r\nIf possible, provide a recipe for reproducing the error.\r\nA complete runnable program is good.\r\nA link on play.golang.org is best.\r\n-->\r\nI am trying to use `runtime.LockOSThread()` bind G and M, unexpectedly, I discover gopreempt actions on this G.\r\n\r\nHere's the code:\r\n\r\n```go\r\npackage main\r\n\r\nimport \"runtime\"\r\nimport \"time\"\r\n\r\n// go build -gcflags '-N -l'\r\nfunc a() {\r\n        i := 10000000\r\n        j := 0\r\n        k := 0\r\n\r\n        for i > 0 {\r\n                i--\r\n                j++\r\n        }\r\n        if i > j {\r\n                k++\r\n        }\r\n        if i < j {\r\n                k++\r\n        }\r\n        b(i,j,k)\r\n}\r\n\r\nfunc b(i,j,k int) int{\r\n        temp:=i*j+k\r\n        temp = temp+1\r\n        return temp\r\n}\r\n\r\nfunc main() {\r\n        go func() {\r\n                runtime.LockOSThread()\r\n                i := 0\r\n                for true {\r\n                        i++\r\n                        a()\r\n                }\r\n        }()\r\n        time.Sleep(time.Hour)\r\n}\r\n\r\n```\r\n\r\n\r\n### What did you expect to see?\r\nNo preempt, G keep running always\r\n\r\n\r\n### What did you see instead?\r\nBelows are my debugging steps:\r\n\r\n$ pidstat -p 12692 -t 1\r\nLinux 3.10.0-862.el7.x86_64 (openstack-22)      12/13/2019      _x86_64_        (24 CPU)\r\n\r\n03:42:47 PM   UID      TGID       TID    %usr %system  %guest    %CPU   CPU  Command\r\n03:42:48 PM     0     12692         -  100.00    0.00    0.00  100.00     8  lockosthread\r\n03:42:48 PM     0         -     12692    0.00    0.00    0.00    0.00     8  |__lockosthread\r\n03:42:48 PM     0         -     12693    0.00    0.00    0.00    0.00    11  |__lockosthread\r\n03:42:48 PM     0         -     12694  100.00    0.00    0.00  100.00    21  |__lockosthread\r\n03:42:48 PM     0         -     12695    0.00    0.00    0.00    0.00    23  |__lockosthread\r\n03:42:48 PM     0         -     12696    0.00    0.00    0.00    0.00    11  |__lockosthread\r\n03:42:48 PM     0         -     12697    0.00    0.00    0.00    0.00    23  |__lockosthread\r\n\r\n03:42:48 PM   UID      TGID       TID    %usr %system  %guest    %CPU   CPU  Command\r\n03:42:49 PM     0     12692         -  100.00    0.00    0.00  100.00     8  lockosthread\r\n03:42:49 PM     0         -     12692    0.00    0.00    0.00    0.00     8  |__lockosthread\r\n03:42:49 PM     0         -     12693    0.00    0.00    0.00    0.00    11  |__lockosthread\r\n03:42:49 PM     0         -     12694  100.00    0.00    0.00  100.00    21  |__lockosthread\r\n03:42:49 PM     0         -     12695    0.00    0.00    0.00    0.00    23  |__lockosthread\r\n03:42:49 PM     0         -     12696    0.00    0.00    0.00    0.00    11  |__lockosthread\r\n03:42:49 PM     0         -     12697    0.00    0.00    0.00    0.00    23  |__lockosthread\r\n^C\r\n\r\nAverage:      UID      TGID       TID    %usr %system  %guest    %CPU   CPU  Command\r\nAverage:        0     12692         -  100.00    0.00    0.00  100.00     -  lockosthread\r\nAverage:        0         -     12692    0.00    0.00    0.00    0.00     -  |__lockosthread\r\nAverage:        0         -     12693    0.00    0.00    0.00    0.00     -  |__lockosthread\r\nAverage:        0         -     12694  100.00    0.00    0.00  100.00     -  |__lockosthread\r\nAverage:        0         -     12695    0.00    0.00    0.00    0.00     -  |__lockosthread\r\nAverage:        0         -     12696    0.00    0.00    0.00    0.00     -  |__lockosthread\r\nAverage:        0         -     12697    0.00    0.00    0.00    0.00     -  |__lockosthread\r\n\r\n$ strace -p 12694 -ttT\r\nstrace: Process 12694 attached\r\n15:43:17.197854 futex(0xc000078148, FUTEX_WAKE_PRIVATE, 1) = 1 <0.000021>\r\n15:43:17.229295 futex(0xc000078148, FUTEX_WAKE_PRIVATE, 1) = 1 <0.000017>\r\n15:43:17.260622 futex(0xc000078148, FUTEX_WAKE_PRIVATE, 1) = 1 <0.000018>\r\n15:43:17.291778 futex(0xc000078148, FUTEX_WAKE_PRIVATE, 1) = 1 <0.000017>\r\n15:43:17.323010 futex(0xc000078148, FUTEX_WAKE_PRIVATE, 1) = 1 <0.000014>\r\n15:43:17.354231 futex(0xc000078148, FUTEX_WAKE_PRIVATE, 1) = 1 <0.000018>\r\n15:43:17.385496 futex(0xc000078148, FUTEX_WAKE_PRIVATE, 1) = 1 <0.000021>\r\n15:43:17.416749 futex(0xc000078148, FUTEX_WAKE_PRIVATE, 1) = 1 <0.000021>\r\n15:43:17.448026 futex(0xc000078148, FUTEX_WAKE_PRIVATE, 1) = 1 <0.000021>\r\n15:43:17.479394 futex(0xc000078148, FUTEX_WAKE_PRIVATE, 1) = 1 <0.000021>\r\n15:43:17.510628 futex(0xc000078148, FUTEX_WAKE_PRIVATE, 1) = 1 <0.000021>\r\n15:43:17.541912 futex(0xc000078148, FUTEX_WAKE_PRIVATE, 1) = 1 <0.000020>\r\n15:43:17.573335 futex(0xc000078148, FUTEX_WAKE_PRIVATE, 1) = 1 <0.000021>\r\n15:43:17.604672 futex(0xc000078148, FUTEX_WAKE_PRIVATE, 1) = 1 <0.000021>\r\n\r\n// as above show, about every 31ms has a futex\r\n// as below show, goroutine preempt happened when calling futex\r\n\r\n(dlv) bt\r\n0  0x000000000042d88f in runtime.gopreempt_m\r\n   at /usr/lib/golang/src/runtime/proc.go:2649\r\n1  0x0000000000456ba5 in main.a\r\n   at ./lockosthread.go:7\r\n2  0x0000000000456c9e in main.main.func1\r\n   at ./lockosthread.go:37\r\n3  0x000000000044d191 in runtime.goexit\r\n   at /usr/lib/golang/src/runtime/asm_amd64.s:1357\r\n(dlv) goroutine\r\nThread 12694 at /usr/lib/golang/src/runtime/proc.go:2649\r\nGoroutine 5:\r\n        Runtime: /usr/lib/golang/src/runtime/proc.go:2649 runtime.gopreempt_m (0x42d88f)\r\n        User: ./lockosthread.go:7 main.a (0x456ba5)\r\n        Go: ./lockosthread.go:32 main.main (0x456c35)\r\n        Start: ./lockosthread.go:32 main.main.func1 (0x456c60)\r\n"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/567845018","html_url":"https://github.com/golang/go/issues/36122#issuecomment-567845018","issue_url":"https://api.github.com/repos/golang/go/issues/36122","id":567845018,"node_id":"MDEyOklzc3VlQ29tbWVudDU2Nzg0NTAxOA==","user":{"login":"ChenYahui2019","id":50737858,"node_id":"MDQ6VXNlcjUwNzM3ODU4","avatar_url":"https://avatars0.githubusercontent.com/u/50737858?v=4","gravatar_id":"","url":"https://api.github.com/users/ChenYahui2019","html_url":"https://github.com/ChenYahui2019","followers_url":"https://api.github.com/users/ChenYahui2019/followers","following_url":"https://api.github.com/users/ChenYahui2019/following{/other_user}","gists_url":"https://api.github.com/users/ChenYahui2019/gists{/gist_id}","starred_url":"https://api.github.com/users/ChenYahui2019/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChenYahui2019/subscriptions","organizations_url":"https://api.github.com/users/ChenYahui2019/orgs","repos_url":"https://api.github.com/users/ChenYahui2019/repos","events_url":"https://api.github.com/users/ChenYahui2019/events{/privacy}","received_events_url":"https://api.github.com/users/ChenYahui2019/received_events","type":"User","site_admin":false},"created_at":"2019-12-20T08:50:41Z","updated_at":"2019-12-20T08:50:41Z","author_association":"NONE","body":"@ianlancetaylor If `GOMAXPROCS` is zero or big enough, `sysmon` do not preempt the `LockOSThread` goroutine. Except GC or the `GOMAXPROCS`, `LockOSThread` goroutine just keeps running. Is this solution feasible?"}}
other: {"actor":{"display_login":"ChenYahui2019"}}