From owner-svn-src-all@freebsd.org Sun Jun 16 15:34:12 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C53A015C235D; Sun, 16 Jun 2019 15:34:11 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 65F208586E; Sun, 16 Jun 2019 15:34:11 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4C9DF1876D; Sun, 16 Jun 2019 15:34:11 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x5GFYBBv043969; Sun, 16 Jun 2019 15:34:11 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x5GFYB96043968; Sun, 16 Jun 2019 15:34:11 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201906161534.x5GFYB96043968@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Sun, 16 Jun 2019 15:34:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r349114 - stable/12/sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/12/sys/net X-SVN-Commit-Revision: 349114 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 65F208586E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.960,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Jun 2019 15:34:12 -0000 Author: marius Date: Sun Jun 16 15:34:10 2019 New Revision: 349114 URL: https://svnweb.freebsd.org/changeset/base/349114 Log: MFC: r347390 - Merge r338254 from cxgbe(4): Use fcmpset instead of cmpset when appropriate. - Revert r277226 of cxgbe(4), obsolete since r334320. Modified: stable/12/sys/net/mp_ring.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/mp_ring.c ============================================================================== --- stable/12/sys/net/mp_ring.c Sun Jun 16 15:30:07 2019 (r349113) +++ stable/12/sys/net/mp_ring.c Sun Jun 16 15:34:10 2019 (r349114) @@ -36,12 +36,6 @@ __FBSDID("$FreeBSD$"); #include #include #include - -#if defined(__i386__) -#define atomic_cmpset_acq_64 atomic_cmpset_64 -#define atomic_cmpset_rel_64 atomic_cmpset_64 -#endif - #include union ring_state { @@ -195,11 +189,12 @@ drain_ring_lockless(struct ifmp_ring *r, union ring_st n = r->drain(r, cidx, pidx); if (n == 0) { critical_enter(); + os.state = r->state; do { - os.state = ns.state = r->state; + ns.state = os.state; ns.cidx = cidx; ns.flags = STALLED; - } while (atomic_cmpset_64(&r->state, os.state, + } while (atomic_fcmpset_64(&r->state, &os.state, ns.state) == 0); critical_exit(); if (prev != STALLED) @@ -222,11 +217,13 @@ drain_ring_lockless(struct ifmp_ring *r, union ring_st if (cidx != pidx && pending < 64 && total < budget) continue; critical_enter(); + os.state = r->state; do { - os.state = ns.state = r->state; + ns.state = os.state; ns.cidx = cidx; ns.flags = state_to_flags(ns, total >= budget); - } while (atomic_cmpset_acq_64(&r->state, os.state, ns.state) == 0); + } while (atomic_fcmpset_acq_64(&r->state, &os.state, + ns.state) == 0); critical_exit(); if (ns.flags == ABDICATED) @@ -379,10 +376,8 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i if (abdicate) { if (os.flags == IDLE) ns.flags = ABDICATED; - } - else { + } else ns.flags = BUSY; - } r->state = ns.state; counter_u64_add(r->enqueues, n); @@ -398,7 +393,6 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i mtx_unlock(&r->lock); return (0); } - #else int ifmp_ring_enqueue(struct ifmp_ring *r, void **items, int n, int budget, int abdicate) @@ -414,8 +408,8 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i * Reserve room for the new items. Our reservation, if successful, is * from 'pidx_start' to 'pidx_stop'. */ + os.state = r->state; for (;;) { - os.state = r->state; if (n >= space_available(r, os)) { counter_u64_add(r->drops, n); MPASS(os.flags != IDLE); @@ -426,7 +420,7 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i ns.state = os.state; ns.pidx_head = increment_idx(r, os.pidx_head, n); critical_enter(); - if (atomic_cmpset_64(&r->state, os.state, ns.state)) + if (atomic_fcmpset_64(&r->state, &os.state, ns.state)) break; critical_exit(); cpu_spinwait(); @@ -456,17 +450,16 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i * Update the ring's pidx_tail. The release style atomic guarantees * that the items are visible to any thread that sees the updated pidx. */ + os.state = r->state; do { - os.state = ns.state = r->state; + ns.state = os.state; ns.pidx_tail = pidx_stop; if (abdicate) { if (os.flags == IDLE) ns.flags = ABDICATED; - } - else { + } else ns.flags = BUSY; - } - } while (atomic_cmpset_rel_64(&r->state, os.state, ns.state) == 0); + } while (atomic_fcmpset_rel_64(&r->state, &os.state, ns.state) == 0); critical_exit(); counter_u64_add(r->enqueues, n);