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 7D2E8C433EF for ; Wed, 1 Dec 2021 15:47:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351158AbhLAPud (ORCPT ); Wed, 1 Dec 2021 10:50:33 -0500 Received: from vps-vb.mhejs.net ([37.28.154.113]:46404 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351106AbhLAPt0 (ORCPT ); Wed, 1 Dec 2021 10:49:26 -0500 Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1msRnl-0008HA-LA; Wed, 01 Dec 2021 16:45:45 +0100 To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Igor Mammedov , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandru Elisei , Atish Patra , Ben Gardon , kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <9698a99ccd1938a36dd0c7399262f888dcdf01ac.1638304316.git.maciej.szmigiero@oracle.com> From: "Maciej S. Szmigiero" Subject: Re: [PATCH v6 27/29] KVM: Optimize overlapping memslots check Message-ID: Date: Wed, 1 Dec 2021 16:45:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01.12.2021 04:08, Sean Christopherson wrote: > On Tue, Nov 30, 2021, Maciej S. Szmigiero wrote: >> From: "Maciej S. Szmigiero" >> >> Do a quick lookup for possibly overlapping gfns when creating or moving >> a memslot instead of performing a linear scan of the whole memslot set. >> >> Signed-off-by: Maciej S. Szmigiero >> [sean: tweaked params to avoid churn in future cleanup] >> Signed-off-by: Sean Christopherson >> --- >> virt/kvm/kvm_main.c | 35 +++++++++++++++++++++-------------- >> 1 file changed, 21 insertions(+), 14 deletions(-) >> >> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c >> index 086f18969bc3..52117f65bc5b 100644 >> --- a/virt/kvm/kvm_main.c >> +++ b/virt/kvm/kvm_main.c >> @@ -1817,6 +1817,18 @@ static int kvm_set_memslot(struct kvm *kvm, >> return 0; >> } >> >> +static bool kvm_check_memslot_overlap(struct kvm_memslots *slots, int id, >> + gfn_t start, gfn_t end) >> +{ >> + struct kvm_memslot_iter iter; >> + >> + kvm_for_each_memslot_in_gfn_range(&iter, slots, start, end) > > The for loop needs curly braces, per coding-style.rst: > > Also, use braces when a loop contains more than a single simple statement: > > .. code-block:: c > > while (condition) { > if (test) > do_something(); > } > > With that, > > Reviewed-by: Sean Christopherson > Will add these braces (and your R-b, too). Thanks, Maciej