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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 994EEC10DC3 for ; Mon, 4 Dec 2023 19:14:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230479AbjLDTO0 (ORCPT ); Mon, 4 Dec 2023 14:14:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231577AbjLDTOX (ORCPT ); Mon, 4 Dec 2023 14:14:23 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3437CF0 for ; Mon, 4 Dec 2023 11:14:30 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8608FC433C9; Mon, 4 Dec 2023 19:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701717269; bh=kfWReJzoKyST0mYqrsmPO5P8wLRuTmZubW3mAnPQP1g=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=cgoZfdq9gW9Pr9xKC3b01h9h3v8ELo9+WYL+fDpUCEbba0Kz1rfxZrAVrfOiZ5ruo YYDDg+vGo/pozOJAZgQK+y7PQcUAxfjLp6o0Ooy6UQWcHYTSXGnDvlAmy/gGlqd5KB b240NbfpFBWcCsgduQYsKm1O4Dtc0KWopgQSlnpsbNvjKfcpCNbqOnvKX17fn73iuM GyuyUC9MRhbkFtHIt5uMPCk+mnhGG8PoLRI0F+Z2WcSpw3wtlgyziIknClpvQkUn21 KheiX6gnBS2zjZ/rNqJwvtF8Mfp/WUhOkqSZIAqDOi1apTQrjxAyT85f3u8xQOv3Zu yD8PBrrw69Wqg== Date: Mon, 4 Dec 2023 13:14:27 -0600 From: Bjorn Helgaas To: Yury Norov Cc: linux-kernel@vger.kernel.org, "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, Jan Kara , Mirsad Todorovac , Matthew Wilcox , Rasmus Villemoes , Andy Shevchenko , Maxim Kuvyrkov , Alexey Klimov , Bart Van Assche , Sergey Shtylyov , Michael Kelley Subject: Re: [PATCH v2 14/35] PCI: hv: switch hv_get_dom_num() to use atomic find_bit() Message-ID: <20231204191427.GA623236@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231203193307.542794-13-yury.norov@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 03, 2023 at 11:32:46AM -0800, Yury Norov wrote: > The function traverses bitmap with for_each_clear_bit() just to allocate > a bit atomically. We can do it better with a dedicated find_and_set_bit(). No objection from me, but please tweak the subject line to match previous hv history, i.e., capitalize the first word after the prefix: PCI: hv: Use atomic find_and_set_bit() I think there's value in using similar phrasing across the whole series. Some subjects say "optimize xyz()", some say "rework xyz()", some "rework xyz()", etc. I think it's more informative to include the "atomic" and "find_bit()" ideas in the subject than the specific functions that *use* it. I also like how some of the other commit logs clearly say what the patch does, e.g., "Simplify by using dedicated find_and_set_bit()", as opposed to just "We can do it better ..." which technically doesn't say what the patch does. Very nice simplification in all these users, thanks for doing it! I assume you'll merge these all together since they depend on [01/35], so: Acked-by: Bjorn Helgaas > Signed-off-by: Yury Norov > Reviewed-by: Michael Kelley > --- > drivers/pci/controller/pci-hyperv.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c > index 30c7dfeccb16..033b1fb7f4eb 100644 > --- a/drivers/pci/controller/pci-hyperv.c > +++ b/drivers/pci/controller/pci-hyperv.c > @@ -3605,12 +3605,9 @@ static u16 hv_get_dom_num(u16 dom) > if (test_and_set_bit(dom, hvpci_dom_map) == 0) > return dom; > > - for_each_clear_bit(i, hvpci_dom_map, HVPCI_DOM_MAP_SIZE) { > - if (test_and_set_bit(i, hvpci_dom_map) == 0) > - return i; > - } > + i = find_and_set_bit(hvpci_dom_map, HVPCI_DOM_MAP_SIZE); > > - return HVPCI_DOM_INVALID; > + return i < HVPCI_DOM_MAP_SIZE ? i : HVPCI_DOM_INVALID; > } > > /** > -- > 2.40.1 >