From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FD0B2F864; Mon, 4 Dec 2023 19:14:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cgoZfdq9" 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> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231203193307.542794-13-yury.norov@gmail.com> 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 >