From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39CD9C433ED for ; Thu, 6 May 2021 19:44:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9AA5B61289 for ; Thu, 6 May 2021 19:44:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9AA5B61289 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lejuw-0001So-Ie for qemu-devel@archiver.kernel.org; Thu, 06 May 2021 15:44:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lejtf-0000S6-LZ for qemu-devel@nongnu.org; Thu, 06 May 2021 15:42:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46656) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lejtc-0005QL-Ur for qemu-devel@nongnu.org; Thu, 06 May 2021 15:42:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620330171; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eraw/UcYLb3IMC/zDSK6jL0qoObBOVSM50npVJ+FeZo=; b=MCoiCRWotYOCu90FjbQjU1emcDfjqC3mKmPiFjju/JQ80nJWTCY6RNSZEkL5zyZicCuVc+ uGt7/dWQCa0vEJfDr5FbgnCNfb8YaYUvkFTfbycdWn8JS9UHqu3UnxhBeq1TJK1Q4IJgXX XLgtaykdhBPS41p9ozPVWCEyYzz637I= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-394-s3iOfwGENPqcYg11fv6QdQ-1; Thu, 06 May 2021 15:42:50 -0400 X-MC-Unique: s3iOfwGENPqcYg11fv6QdQ-1 Received: by mail-wm1-f72.google.com with SMTP id j3-20020a1c55030000b029012e7c06101aso1182230wmb.5 for ; Thu, 06 May 2021 12:42:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=eraw/UcYLb3IMC/zDSK6jL0qoObBOVSM50npVJ+FeZo=; b=JWEN7sb+JwlZKhh5QO8nsAUbXv2fpJs+4BbZ9hglKBGpE8+UwV4ES+F05prQNk1z2l cqyD4bgVLvdXcsqbZ4+bAYBnWet7tA/HGlqmgfOzxyd2wLnqs+sbuQacOBKvIa4zlL4L 3Bpu9u1bBnGX5+44TLjab/ba4XWwy59r4hNc4VPIbk35Q5DrVO+qpe0Pxx2I9UDbH2rd 4GBriA70mTXTsbhmsljZYWq7UfqH5dNqOOKHUECNozYUbU6/m08NX5YYXGru54guWB/S CZb3KGnp+ahiwy27YYT5CN9jf9RqMt+mx0DNRnEpBCJNf2gjvM+auxhL1X3eSegB0VoA Heuw== X-Gm-Message-State: AOAM533CGnlxkUc9q3CMLtIEN73MrMO2hsSln+KeBKlCrMWGwwTqg2WX 0vP4Enx3q+4UxR2aa161Jm3rMZpFL1gIvzUv3zE3IBco66M2g8HcUWl689fJpHLGTSq06kZZiB6 hBRuUtK0TEFQqMaU= X-Received: by 2002:a5d:4386:: with SMTP id i6mr7517744wrq.207.1620330168932; Thu, 06 May 2021 12:42:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybGGwg96Gl/8F4LwrCaxZn8kuuGbkG7H/lTWm+y40xAAWp1qAJzNjSiTz5nXyHEICPDQ5ZAg== X-Received: by 2002:a5d:4386:: with SMTP id i6mr7517717wrq.207.1620330168757; Thu, 06 May 2021 12:42:48 -0700 (PDT) Received: from [192.168.1.19] (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id u9sm4738917wmc.38.2021.05.06.12.42.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 May 2021 12:42:48 -0700 (PDT) Subject: Re: [PATCH] virtio-blk: Convert QEMUBH callback to "bitops.h" API To: Richard Henderson , qemu-devel@nongnu.org References: <20210506155419.1796056-1-philmd@redhat.com> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Message-ID: <20266f2d-00e2-339a-0fdf-122c32ae4da1@redhat.com> Date: Thu, 6 May 2021 21:42:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.69, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Li Hangjing , Sergio Lopez , qemu-block@nongnu.org, Max Reitz , Chai Wen , Stefan Hajnoczi , Xie Yongji Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 5/6/21 8:22 PM, Richard Henderson wrote: > On 5/6/21 8:54 AM, Philippe Mathieu-Daudé wrote: >>   static void notify_guest_bh(void *opaque) >>   { >>       VirtIOBlockDataPlane *s = opaque; >> -    unsigned nvqs = s->conf->num_queues; >> -    unsigned long bitmap[BITS_TO_LONGS(nvqs)]; >> -    unsigned j; >>   -    memcpy(bitmap, s->batch_notify_vqs, sizeof(bitmap)); >> -    memset(s->batch_notify_vqs, 0, sizeof(bitmap)); >> - >> -    for (j = 0; j < nvqs; j += BITS_PER_LONG) { >> -        unsigned long bits = bitmap[j / BITS_PER_LONG]; >> - >> -        while (bits != 0) { >> -            unsigned i = j + ctzl(bits); >> +    for (unsigned i = 0; i < s->conf->num_queues; i++) { > > Is this bitmap dense enough that you want to iterate by index, By 'iterate by index' do you mean the actual iteration with 'j'? > or is it > sparse enough to iterate via find_first_bit/find_next_bit? I looked at find_first_bit/find_next_bit() but they seemed to do a lot more than test_and_clear_bit(). As Stefan said this is hot path, I thought this would be cheaper, but haven't profiled the performance. > In either case, leave the copy of  s->conf->num_queues to a local variable. That is sensible to do :)