From patchwork Mon Dec 1 13:34:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 41770 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8E4E920672 for ; Mon, 1 Dec 2014 13:34:18 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id n15sf6526357lbi.8 for ; Mon, 01 Dec 2014 05:34:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=riYiq++njYdvgEvhPkTHrFNzOvMHR9AhCPaLc2u2Mfo=; b=TtECEDgauxvDeSOtG/dk7hbhh0gKEF4qhSM3lWqn506wONagheAYeH8ul8DwkQbunF m719EXiTpSLZTRio7GoWLHqKpmbwTiwdZV0jcAuTTjsODPL4LsjPBbniL8BLibmAC7YH SLnxALIechwr8E7oSsvtXStZFU4pT+Dc2/BBw+2hAY82NfEfvZlZ2Yv43NmVSXTR2zbD nAkmWfrmK/+EqqkH7ht0EX/Kwo06ci5z5TM0SoluBDi7hAUB9zIql0MNDogHRaRa314i bW8nYaTo9GGHUhkRU9DaR6yOP6dvqlguTVlbDI+MV/gYDEy3F5GH0QKNlqj2Jy1B7DFs OhmQ== X-Gm-Message-State: ALoCoQky99/7dxvdycw+HCf26StuocKlpigkQGWOfy4//8X2U6miiZWc7vI4og3D+gY2YuHXV6H6 X-Received: by 10.112.146.104 with SMTP id tb8mr14142lbb.22.1417440857517; Mon, 01 Dec 2014 05:34:17 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.165 with SMTP id x5ls733788lal.34.gmail; Mon, 01 Dec 2014 05:34:17 -0800 (PST) X-Received: by 10.112.205.65 with SMTP id le1mr42154514lbc.54.1417440857050; Mon, 01 Dec 2014 05:34:17 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id ml2si17730439lbc.7.2014.12.01.05.34.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Dec 2014 05:34:16 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so8408462lab.8 for ; Mon, 01 Dec 2014 05:34:16 -0800 (PST) X-Received: by 10.112.14.69 with SMTP id n5mr56823105lbc.34.1417440856642; Mon, 01 Dec 2014 05:34:16 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp286372lbc; Mon, 1 Dec 2014 05:34:15 -0800 (PST) X-Received: by 10.140.31.166 with SMTP id f35mr59976654qgf.66.1417440855236; Mon, 01 Dec 2014 05:34:15 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id i8si20526361qge.20.2014.12.01.05.34.14 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 01 Dec 2014 05:34:15 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XvR7D-0007p6-2Z; Mon, 01 Dec 2014 13:34:11 +0000 Received: from mail-lb0-f179.google.com ([209.85.217.179]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XvR76-0007oy-By for lng-odp@lists.linaro.org; Mon, 01 Dec 2014 13:34:04 +0000 Received: by mail-lb0-f179.google.com with SMTP id z11so8495823lbi.10 for ; Mon, 01 Dec 2014 05:33:58 -0800 (PST) X-Received: by 10.152.88.69 with SMTP id be5mr57366313lab.36.1417440838429; Mon, 01 Dec 2014 05:33:58 -0800 (PST) Received: from macmini.lan (84-217-193-77.tn.glocalnet.net. [84.217.193.77]) by mx.google.com with ESMTPSA id ba19sm2389549lab.23.2014.12.01.05.33.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Dec 2014 05:33:57 -0800 (PST) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Mon, 1 Dec 2014 14:34:01 +0100 Message-Id: <1417440841-8666-1-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH] linux-generic: odp_ticketlock.c: performance regression X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ola.liljedahl@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Ola Liljedahl --- Replaced an atomic RMW add with separate load, add and store operations. This avoids generating a "locked" instruction on x86 which implies unnecessary strong memory ordering and improves performance. This change could also prove beneficial on other architectures. platform/linux-generic/odp_ticketlock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/linux-generic/odp_ticketlock.c b/platform/linux-generic/odp_ticketlock.c index 6c5e74e..1e67ff5 100644 --- a/platform/linux-generic/odp_ticketlock.c +++ b/platform/linux-generic/odp_ticketlock.c @@ -32,7 +32,10 @@ void odp_ticketlock_lock(odp_ticketlock_t *ticketlock) void odp_ticketlock_unlock(odp_ticketlock_t *ticketlock) { - _odp_atomic_u32_add_mm(&ticketlock->cur_ticket, 1, _ODP_MEMMODEL_RLS); + uint32_t cur = _odp_atomic_u32_load_mm(&ticketlock->cur_ticket, + _ODP_MEMMODEL_RLX); + _odp_atomic_u32_store_mm(&ticketlock->cur_ticket, cur + 1, + _ODP_MEMMODEL_RLS); #if defined __OCTEON__ odp_sync_stores(); /* SYNCW to flush write buffer */