From patchwork Wed Jun 11 14:29:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 31776 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 947B32054B for ; Wed, 11 Jun 2014 14:37:41 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f10sf8850912yha.11 for ; Wed, 11 Jun 2014 07:37:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=nW9Ud5xZ3j0wnepMde0CXuAL9lR3Hk14hzikZBwgiQ8=; b=XO6nO9xHMwAbnRdlwKBQQe3FNI2ZUAOrdfOiorZ/k0ZSP/IBHDGG3QvABe2hc1eYEC ws7ThgYjlbPeECr111V1X8F4k/HpYm+UwG890p0hgW/t+7v9KsA5sj7G5fQjfhDMVGYP gApAGsP+EGfKph6QH4JGUpH4hXfoWKrrsFjvQxcsKafZWRI/R1NWya/SV1VO45BBji1N J2D2mQXvFNk1JhFPoZa7R+yKk4oDx78rAywrTFwVQPMexI7cU9/gSJib8JxGD4nC9Oci u2cRXLXvmKKHQJx+cdrBPfb0jDs4eUwZjvpp/IjnAYKZnAf2eFRCh2RexOqfuWf935fk tjAQ== X-Gm-Message-State: ALoCoQmVrVp6Z2gZxfBaVaGHX+HPdLxqiPmbFUVrkKM5vStCoxbH/DD5d/uUa/SVN75upDhuSG4u X-Received: by 10.236.231.238 with SMTP id l104mr11910833yhq.51.1402497461190; Wed, 11 Jun 2014 07:37:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.52 with SMTP id n49ls2722191qge.29.gmail; Wed, 11 Jun 2014 07:37:41 -0700 (PDT) X-Received: by 10.58.123.71 with SMTP id ly7mr39372100veb.11.1402497461025; Wed, 11 Jun 2014 07:37:41 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id q6si13018644vcm.67.2014.06.11.07.37.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Jun 2014 07:37:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.173 as permitted sender) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id db11so5793705veb.32 for ; Wed, 11 Jun 2014 07:37:40 -0700 (PDT) X-Received: by 10.220.133.197 with SMTP id g5mr39065220vct.20.1402497460919; Wed, 11 Jun 2014 07:37:40 -0700 (PDT) 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.221.54.6 with SMTP id vs6csp308904vcb; Wed, 11 Jun 2014 07:37:40 -0700 (PDT) X-Received: by 10.140.32.97 with SMTP id g88mr48208439qgg.17.1402497459926; Wed, 11 Jun 2014 07:37:39 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 8si31701931qai.36.2014.06.11.07.37.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 11 Jun 2014 07:37:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:46879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wujel-0005xH-6S for patch@linaro.org; Wed, 11 Jun 2014 10:37:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WujXT-0004rx-76 for qemu-devel@nongnu.org; Wed, 11 Jun 2014 10:30:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WujXS-0008RX-58 for qemu-devel@nongnu.org; Wed, 11 Jun 2014 10:30:07 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:48600) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WujXR-0008DN-V8 for qemu-devel@nongnu.org; Wed, 11 Jun 2014 10:30:06 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WujXF-00075e-Ra; Wed, 11 Jun 2014 15:29:53 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Wed, 11 Jun 2014 15:29:44 +0100 Message-Id: <1402496993-27206-7-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1402496993-27206-1-git-send-email-peter.maydell@linaro.org> References: <1402496993-27206-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Cc: Blue Swirl Subject: [Qemu-devel] [PULL 06/15] vhost: replace ffsl with ctzl X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@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.128.173 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 From: Natanael Copa Avoid using the GNU extesion ffsl which is not implemented in musl libc. The atomic_xchg() means we know that vhost_log_chunk_t will never be larger than the 'long' type, so ctzl() is always sufficient. See also commit fbeadf50 (bitops: unify bitops_ffsl with the one in host-utils.h, call it bitops_ctzl) on why ctzl should be used instead of ffsl. Signed-off-by: Natanael Copa Reviewed-by: Paolo Bonzini Signed-off-by: Peter Maydell --- hw/virtio/vhost.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 9e336ad..f62cfaf 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -41,7 +41,6 @@ static void vhost_dev_sync_region(struct vhost_dev *dev, for (;from < to; ++from) { vhost_log_chunk_t log; - int bit; /* We first check with non-atomic: much cheaper, * and we expect non-dirty to be the common case. */ if (!*from) { @@ -51,12 +50,11 @@ static void vhost_dev_sync_region(struct vhost_dev *dev, /* Data must be read atomically. We don't really need barrier semantics * but it's easier to use atomic_* than roll our own. */ log = atomic_xchg(from, 0); - while ((bit = sizeof(log) > sizeof(int) ? - ffsll(log) : ffs(log))) { + while (log) { + int bit = ctzl(log); hwaddr page_addr; hwaddr section_offset; hwaddr mr_offset; - bit -= 1; page_addr = addr + bit * VHOST_LOG_PAGE; section_offset = page_addr - section->offset_within_address_space; mr_offset = section_offset + section->offset_within_region;