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 98905C433ED for ; Thu, 6 May 2021 20:03:55 +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 E4FDD6121F for ; Thu, 6 May 2021 20:03:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4FDD6121F 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]:47780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lekDx-000704-W4 for qemu-devel@archiver.kernel.org; Thu, 06 May 2021 16:03:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lekBB-0006LV-Ki for qemu-devel@nongnu.org; Thu, 06 May 2021 16:01:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20383) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lekB1-0006gr-Pf for qemu-devel@nongnu.org; Thu, 06 May 2021 16:00:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620331248; 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=yudgmIQn3hghxVW4zyY5B4fizVer8MR7FSo3oxcCGgM=; b=Fb6QnEklM7DKUTKBWsxd9Uk9v9+QYYkOTPwGuFzQmXP5xxa/5FdCmIdirBbe7atp8A16jW TgFzTMHRtN9SLUGCb+XLNx67QBfGGnsh4xIZ4heD/TpHFHo1NyTcI1vbYFN7FHDUndLsa9 Nb/4NIJeQIYPJcLDPAmdNOdgJJD1fBY= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-569-UBP1TwIdMAS4Z5EfaskJsg-1; Thu, 06 May 2021 16:00:46 -0400 X-MC-Unique: UBP1TwIdMAS4Z5EfaskJsg-1 Received: by mail-wr1-f71.google.com with SMTP id q18-20020adfc5120000b029010c2bdd72adso2623953wrf.16 for ; Thu, 06 May 2021 13:00:46 -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:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=yudgmIQn3hghxVW4zyY5B4fizVer8MR7FSo3oxcCGgM=; b=umzsfth2a0YZ4XKkAgHvrAEkYfIfikMF2vG43o0bViVDdxyCJGu746GW8etL1x2lfC 5YIJDjlcJNfT0j7WfC+GukG6ZHVL4hr8covKd24Hkqk/8bFm5NWcd0BPlIQXLEd0oZ+u /leD8V7ocETBaUMZ7Q4tyt7Juc2P7at1bRybLpqMx2fMtE76zeaUguboR80Fvcvn0pb4 GZg2j3+HKMEbqqbIoMf1NZLmQ91kN387h+9svlHiPuxWvKPWw1ssJ366MHUQbvG0fGwA AkIBA2EAFETGHh7ZgymvyQMbD/+vui4rmsQjgo7FzWv2be/Q095ZsHHrKZUmm71VtnMA RDfQ== X-Gm-Message-State: AOAM530Q8OWGwvmkDHrdX0WLAWu0ok5HBL2iTjRBUEvk6ZBg8Qvn5ngn Bp9W+vJA8LOWshcqxvk868MzDKoUvt9cMigNkpNJiAteSMnxUYDQsG6vkr1SkEJRZ1/YhNUDIsy 9B3/6hxxntVxktuQ= X-Received: by 2002:a7b:c38d:: with SMTP id s13mr6024461wmj.115.1620331245866; Thu, 06 May 2021 13:00:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT17Q7lTDxN646PmD1cPyas9bOJppOKoF7DrDA/o1IfIl3SFlVCP5Zc6rBC1b4LeL2YZ1ctQ== X-Received: by 2002:a7b:c38d:: with SMTP id s13mr6024428wmj.115.1620331245553; Thu, 06 May 2021 13:00:45 -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 a15sm6603747wrx.9.2021.05.06.13.00.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 May 2021 13:00:45 -0700 (PDT) Subject: Re: [PATCH] virtio-blk: Convert QEMUBH callback to "bitops.h" API From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= To: Richard Henderson , qemu-devel@nongnu.org References: <20210506155419.1796056-1-philmd@redhat.com> <20266f2d-00e2-339a-0fdf-122c32ae4da1@redhat.com> Message-ID: <0f3dbab6-8b73-7988-213d-a248d48f2bbc@redhat.com> Date: Thu, 6 May 2021 22:00:43 +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: <20266f2d-00e2-339a-0fdf-122c32ae4da1@redhat.com> 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=216.205.24.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 9:42 PM, Philippe Mathieu-Daudé wrote: > 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, The max is 1Kb: #define VIRTIO_QUEUE_MAX 1024 > > 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 :) >