From patchwork Wed Sep 6 15:57:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 810689 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xnSsk6Cb7z9t4s for ; Thu, 7 Sep 2017 01:58:02 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3ACAFAE1; Wed, 6 Sep 2017 15:57:59 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id D5A98AC8 for ; Wed, 6 Sep 2017 15:57:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 45E20433 for ; Wed, 6 Sep 2017 15:57:57 +0000 (UTC) X-Originating-IP: 208.91.2.3 Received: from sigabrt.benpfaff.org (unknown [208.91.2.3]) (Authenticated sender: blp@ovn.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id A8E80FB8B1; Wed, 6 Sep 2017 17:57:53 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Wed, 6 Sep 2017 08:57:45 -0700 Message-Id: <20170906155745.1031-1-blp@ovn.org> X-Mailer: git-send-email 2.10.2 X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff , Alin Serdean Subject: [ovs-dev] [PATCH] dpif-netdev: Avoid side-effect in argument of atomic_store_relaxed(). X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Some of the implementations of atomic_store_relaxed() evaluate their first argument more than once, so arguments with side effects cause strange behavior. This fixes a problem observed on 64-bit Windows. Reported-by: Alin Serdean Signed-off-by: Ben Pfaff Acked-by: Alin Serdean Acked-by: Darrell Ball --- lib/dpif-netdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 071ec141f1d1..0ceef9d82914 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -3201,8 +3201,8 @@ static void dp_netdev_rxq_set_intrvl_cycles(struct dp_netdev_rxq *rx, unsigned long long cycles) { - atomic_store_relaxed(&rx->cycles_intrvl[rx->intrvl_idx++ - % PMD_RXQ_INTERVAL_MAX], cycles); + unsigned int idx = rx->intrvl_idx++ % PMD_RXQ_INTERVAL_MAX; + atomic_store_relaxed(&rx->cycles_intrvl[idx], cycles); } static uint64_t