From patchwork Tue Nov 1 20:39:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pranith Kumar X-Patchwork-Id: 9408025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9091760721 for ; Tue, 1 Nov 2016 20:40:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8559029A92 for ; Tue, 1 Nov 2016 20:40:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79ED329A94; Tue, 1 Nov 2016 20:40:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6432129A92 for ; Tue, 1 Nov 2016 20:40:17 +0000 (UTC) Received: from localhost ([::1]:51133 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1fqy-0001kF-3m for patchwork-qemu-devel@patchwork.kernel.org; Tue, 01 Nov 2016 16:40:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1fqh-0001k5-He for qemu-devel@nongnu.org; Tue, 01 Nov 2016 16:40:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1fqe-0008Rm-GD for qemu-devel@nongnu.org; Tue, 01 Nov 2016 16:39:59 -0400 Received: from mail-yb0-x244.google.com ([2607:f8b0:4002:c09::244]:35191) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c1fqe-0008RY-BP for qemu-devel@nongnu.org; Tue, 01 Nov 2016 16:39:56 -0400 Received: by mail-yb0-x244.google.com with SMTP id e129so790191yba.2 for ; Tue, 01 Nov 2016 13:39:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=5n48D7fLUmCXsx/NbeRR4wlG14hxs4h9LbtzjUnx3Dc=; b=RP0TWSbYiRo1l8bECGCnSlaXye6c+KemUYkkdIf/xOAuazfatLA3gj/FdYaiE2dCAy K4/ZoCzwOdrqBCpf3Rk0kiZEqZshDjR10UohUa6d21G2AcZVFORa5eZvsWtrM92Y+MUU mQS/oAzBtrUsH51uYmvOoMwG9B7cVoRO8pQo73RGQHnpVT0KlZyOWzNQB3exetMbOCwo pLg5jdF+y1lAL/VRlSvCPHt64aioG/4jLSNhAixmt+yd7xmhVTa6j9rRDY3AOBE0L5/T /lnIZQkvW/AHy1XVQ8/rvADjU0ssaffeXJ/32M0Dlg1JisTLf64uNH4o5RuhitJyvA16 UVAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=5n48D7fLUmCXsx/NbeRR4wlG14hxs4h9LbtzjUnx3Dc=; b=enLJnsiYsyZ0Vb1ZqU+Zsq/IDGw3Po15M6TU3n6rrCfce/wAFvIQ+WcYkL2onxWI6F WikpGRTquBDterq7bj89a7A13YfDaFzpa8rz0iOTmCsSoJR57Yp5tPc31vUXG9Xp5pjD /O2iSUtbN9FanOTv6qLYusTG7fwGEPFgGLn+nV57alnW6mlgVhWYBiOB5c55Mb8992t4 3X31ETjrsGCGMTJENX9OWlIMzPb01vHwNUJTQR1A859UaF9wCI6cMAacXIut6nF6Z6Nd Mdvgy+4KnnmyZ1WA42c1W4YfILrzAujTKDLtUXCwPnlK3YYhyF8AB8n4VStbvdB4duwF Y1Gg== X-Gm-Message-State: ABUngvcNdEtn6PmmKr0lF8+Rv0Tbtcg3H7AQRqKLHSEbG4Ybz/QCvSzvhQewW/T2VEA4Bg== X-Received: by 10.37.7.197 with SMTP id 188mr9125486ybh.9.1478032795606; Tue, 01 Nov 2016 13:39:55 -0700 (PDT) Received: from localhost.localdomain (c-73-207-178-95.hsd1.ga.comcast.net. [73.207.178.95]) by smtp.gmail.com with ESMTPSA id v8sm2663188ywb.28.2016.11.01.13.39.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Nov 2016 13:39:54 -0700 (PDT) From: Pranith Kumar To: Paolo Bonzini , "Emilio G. Cota" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , qemu-devel@nongnu.org (open list:All patches CC here) Date: Tue, 1 Nov 2016 16:39:53 -0400 Message-Id: <20161101203953.18065-1-bobby.prani@gmail.com> X-Mailer: git-send-email 2.10.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4002:c09::244 Subject: [Qemu-devel] [PATCH] atomic.h: Use __atomic_load_n() primitive X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use __atomic_load_n() primitive saving a load and store to a local variable. Signed-off-by: Pranith Kumar --- include/qemu/atomic.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index 878fa07..be44094 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -120,20 +120,22 @@ * same, but this slows down atomic_rcu_read unnecessarily. */ #ifdef __SANITIZE_THREAD__ -#define atomic_rcu_read__nocheck(ptr, valptr) \ - __atomic_load(ptr, valptr, __ATOMIC_CONSUME); +#define atomic_rcu_read__nocheck(ptr) \ + __atomic_load_n(ptr, __ATOMIC_CONSUME); #else -#define atomic_rcu_read__nocheck(ptr, valptr) \ - __atomic_load(ptr, valptr, __ATOMIC_RELAXED); \ - smp_read_barrier_depends(); +#define atomic_rcu_read__nocheck(ptr) \ + ({ \ + typeof_strip_qual(*ptr) _val; \ + __atomic_load(ptr, &_val, __ATOMIC_RELAXED); \ + smp_read_barrier_depends(); \ + _val; \ + }) #endif #define atomic_rcu_read(ptr) \ ({ \ QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ - typeof_strip_qual(*ptr) _val; \ - atomic_rcu_read__nocheck(ptr, &_val); \ - _val; \ + atomic_rcu_read__nocheck(ptr); \ }) #define atomic_rcu_set(ptr, i) do { \ @@ -144,9 +146,7 @@ #define atomic_load_acquire(ptr) \ ({ \ QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ - typeof_strip_qual(*ptr) _val; \ - __atomic_load(ptr, &_val, __ATOMIC_ACQUIRE); \ - _val; \ + __atomic_load_n(ptr, __ATOMIC_ACQUIRE); \ }) #define atomic_store_release(ptr, i) do { \