From patchwork Thu Jan 30 00:40:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 1231241 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518532-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=golang.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=c6p+oKTf; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=golang-org.20150623.gappssmtp.com header.i=@golang-org.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=w3g1lFi6; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487M3P1Sh9z9sNT for ; Thu, 30 Jan 2020 11:41:05 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=Vm9xE5zKGmYwuqsuQC4cLKh4268+DfvZG2x1Lm7BZb0pD6 xX23cIoazEVkIKdxIZsvhtDi60y1yogJHAGBGN9fL+7zFQmktyOZKiBDZOsb7YZa k7sSk2K9ozHWLbQbJSTyCGTIhFvt0daiFeMO61KcH13CKNVlofIJYeug/ktrs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=HMMa55GYeEopNQm6u9PfPH2+LDA=; b=c6p+oKTf4S7DrV7QzqWw T5LUa2zvHE7IvxjQCcCNcZcjYnPuDvVgVumjBtGw2IIPKz63o4xjeY4uud2D9rSb LOZuA3TN/lzKRw1F4E0UTYkICyvn+aGKxyMPASz6NTWKlkOck5R2Fz5Q5HMrcM6Y QtC18zjMRHqLwPTCOxKYTAA= Received: (qmail 112723 invoked by alias); 30 Jan 2020 00:40:57 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 112709 invoked by uid 89); 30 Jan 2020 00:40:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=unlock, UD:netpoll_hurd.go, netpoll_hurdgo, interrupted X-HELO: mail-ed1-f43.google.com Received: from mail-ed1-f43.google.com (HELO mail-ed1-f43.google.com) (209.85.208.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Jan 2020 00:40:55 +0000 Received: by mail-ed1-f43.google.com with SMTP id c26so1859622eds.8 for ; Wed, 29 Jan 2020 16:40:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golang-org.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=ZkAaFjNajn8uT4uUZUU5J7nRBk+XYgsJ/bT25RwUeWw=; b=w3g1lFi6m436nRXQuyg1rIjID0AZy3pM4URhobrYBU94teXw75O+o8Rf2pyy9OvUnS sKAf32MXXCTehFQO1jbLw3upMQBViwyiUAyCSXq67EVFszQJoOzAbtVQ2ISPcVkaEGim hYsvMxU5oBxdJqJN26s/EpFGylMHZK9JGofrw0MmZ1ZsrqGxus7uSASFZpUW2rwZ6VLe hyJGjcs1D/8mBR5yyvgBiJ+8Dwftnc3evee90H6/laPVX70kAnX8+h776piBU+3aM2ao +9z0jaYnMgm8SpHNSlNstauXpAS1wbHy/YnMt22rv33Y60sP1X+aRRplyVKcB5KPQ7rL 13MA== MIME-Version: 1.0 From: Ian Lance Taylor Date: Wed, 29 Jan 2020 16:40:41 -0800 Message-ID: Subject: libgo patch committed: Update netpoll_hurd for Go 1.14beta1 changes To: gcc-patches , gofrontend-dev This patch by Svante Signell updates runtime/netpoll_hurd.go for the changes in the Go 1.14beta1 release. Bootstrapped on x86_64-pc-linux-gnu. Committed to mainline. Ian 58d788fafbc4cc8cc25ca432e8127e1effdc0672 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 49312fa10f7..8d08e91211d 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -132e0e61d59aaa52f8fdb03a925300c1ced2a0f2 +5b438257e6fe5f344ae2f973313f394cda85bf62 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/go/runtime/netpoll_hurd.go b/libgo/go/runtime/netpoll_hurd.go index b74ad2fe128..3d3fa4b76d3 100644 --- a/libgo/go/runtime/netpoll_hurd.go +++ b/libgo/go/runtime/netpoll_hurd.go @@ -85,6 +85,10 @@ func netpolldescriptor() uintptr { return uintptr(rdwake<<16 | wrwake) } +func netpollIsPollDescriptor(fd uintptr) bool { + return fd == uintptr(rdwake) || fd == uintptr(wrwake) +} + // netpollwakeup writes on wrwake to wakeup poll before any changes. func netpollwakeup() { if pendingUpdates == 0 { @@ -158,17 +162,32 @@ func netpollarm(pd *pollDesc, mode int) { unlock(&mtxset) } -// polls for ready network connections -// returns list of goroutines that become runnable +// netpollBreak interrupts an epollwait. +func netpollBreak() { + netpollwakeup() +} + +// netpoll checks for ready network connections. +// Returns list of goroutines that become runnable. +// delay < 0: blocks indefinitely +// delay == 0: does not block, just polls +// delay > 0: block for up to that many nanoseconds //go:nowritebarrierrec -func netpoll(block bool) gList { +func netpoll(delay int64) gList { timeout := int32(0) - if !block { + if delay < 0 { timeout = 0 + } else if delay == 0 { + // TODO: call poll with timeout == 0 return gList{} - } - if pollVerbose { - println("*** netpoll", block) + } else if delay < 1e6 { + timeout = 1 + } else if delay < 1e15 { + timeout = int32(delay / 1e6) + } else { + // An arbitrary cap on how long to wait for a timer. + // 1e9 ms == ~11.5 days. + timeout = 1e9 } retry: lock(&mtxpoll) @@ -176,40 +195,37 @@ retry: pendingUpdates = 0 unlock(&mtxpoll) - if pollVerbose { - println("*** netpoll before poll") - } n := libc_poll(&pfds[0], int32(len(pfds)), timeout) - if pollVerbose { - println("*** netpoll after poll", n) - } if n < 0 { e := errno() if e != _EINTR { println("errno=", e, " len(pfds)=", len(pfds)) throw("poll failed") } - if pollVerbose { - println("*** poll failed") - } unlock(&mtxset) + // If a timed sleep was interrupted, just return to + // recalculate how long we should sleep now. + if timeout > 0 { + return gList{} + } goto retry } // Check if some descriptors need to be changed if n != 0 && pfds[0].revents&(_POLLIN|_POLLHUP|_POLLERR) != 0 { - var b [1]byte - for read(rdwake, unsafe.Pointer(&b[0]), 1) == 1 { - if pollVerbose { - println("*** read 1 byte from pipe") + if delay != 0 { + // A netpollwakeup could be picked up by a + // non-blocking poll. Only clear the wakeup + // if blocking. + var b [1]byte + for read(rdwake, unsafe.Pointer(&b[0]), 1) == 1 { } } - // Do not look at the other fds in this case as the mode may have changed - // XXX only additions of flags are made, so maybe it is ok - unlock(&mtxset) - goto retry + // Still look at the other fds even if the mode may have + // changed, as netpollBreak might have been called. + n-- } var toRun gList - for i := 0; i < len(pfds) && n > 0; i++ { + for i := 1; i < len(pfds) && n > 0; i++ { pfd := &pfds[i] var mode int32 @@ -222,19 +238,14 @@ retry: pfd.events &= ^_POLLOUT } if mode != 0 { - if pollVerbose { - println("*** netpollready i=", i, "revents=", pfd.revents, "events=", pfd.events, "pd=", pds[i]) + pds[i].everr = false + if pfd.revents == _POLLERR { + pds[i].everr = true } netpollready(&toRun, pds[i], mode) n-- } } unlock(&mtxset) - if block && toRun.empty() { - goto retry - } - if pollVerbose { - println("*** netpoll returning end") - } return toRun }