Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp953471pxj; Fri, 21 May 2021 03:05:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQMCsN1rq1LVrmVHsWWvbAEgeE1hZZ7d8am6JSx+fH0nnxLHHHdDb5iY0ckPEzDmHxjE44 X-Received: by 2002:a17:907:10c7:: with SMTP id rv7mr9410685ejb.125.1621591527461; Fri, 21 May 2021 03:05:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621591527; cv=none; d=google.com; s=arc-20160816; b=pc8BbBP0wKBNrSvGUtP6M7VRmkazBzT5o1SIUilK66hmaCC599BMbpAp820CsZt88+ ERGs++X+aGCLyYNEPfr4mYSKx8rOjQgxK+uWGQSnjbhA7ueOro0dMAN4AfrjPu1XKHps xHbB2y/DtQUHxW9z0uPjSXn3rFCt9xVDUTj2PXmjGIyjBaywV33HUW49tFhSv9iH09oQ kyUNTq/udYI//KZGiS5Rl0VeFRXh4mVv2E0znoF/3YU7srtobQjmKQ9HdxsTTSvWJ2a3 oDdCVbkFMgfNcz+XHdIvc6R4weAFqIW/2GhJYbEpKbl7NWYtC+dfV0w4chBwzd/jn7zA HBCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to; bh=ttil5nZSr5faRXFCavs7C2bnzp5wpEcEzPCwl2iWr9I=; b=dFqgjXWXKVRCWwYtVXU8fk3Hctv5GJhMIM06+eA583iSC1tuWkoJca9SRWJFgZv5WE 2hevaPJJMG3xU/7pk3fSvOLW1eraJay1lnOJTUxp0ypnMJKfY1/AHlZBDFFzWIfgMd5r epZawVnxz2krxbCmT48JDWM62WJSfnX9ZsXtVVjFMmdvZ8/5buDc+utr6TiG7u9gTYxZ VV2d8U8fqTYmcjoTZ6XuELWzkrtHdssTbaOe9TdmBLrFSWKZ8p0s2hqNkA8z+dukNJo5 l2300EqHgXf3hvT1frv50NnSWHQVinxsI5wcqUABn+UthQY8VyojQFN+vfo/Iy9V6Dec 8Ecw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i3si2661526edb.243.2021.05.21.03.05.03; Fri, 21 May 2021 03:05:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235119AbhEUHFZ (ORCPT + 99 others); Fri, 21 May 2021 03:05:25 -0400 Received: from vps-vb.mhejs.net ([37.28.154.113]:46922 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234003AbhEUHFR (ORCPT ); Fri, 21 May 2021 03:05:17 -0400 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 1ljzCG-000549-5O; Fri, 21 May 2021 09:03:48 +0200 To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , 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 , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: From: "Maciej S. Szmigiero" Subject: Re: [PATCH v3 2/8] KVM: Integrate gfn_to_memslot_approx() into search_memslots() Message-ID: <4e24f674-6250-626d-48cd-4e0fe60defa4@maciej.szmigiero.name> Date: Fri, 21 May 2021 09:03:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 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 19.05.2021 23:24, Sean Christopherson wrote: > On Sun, May 16, 2021, Maciej S. Szmigiero wrote: >> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h >> index 8895b95b6a22..3c40c7d32f7e 100644 >> --- a/include/linux/kvm_host.h >> +++ b/include/linux/kvm_host.h >> @@ -1091,10 +1091,14 @@ bool kvm_arch_irqfd_allowed(struct kvm *kvm, struct kvm_irqfd *args); >> * gfn_to_memslot() itself isn't here as an inline because that would >> * bloat other code too much. >> * >> + * With "approx" set returns the memslot also when the address falls >> + * in a hole. In that case one of the memslots bordering the hole is >> + * returned. >> + * >> * IMPORTANT: Slots are sorted from highest GFN to lowest GFN! >> */ >> static inline struct kvm_memory_slot * >> -search_memslots(struct kvm_memslots *slots, gfn_t gfn) >> +search_memslots(struct kvm_memslots *slots, gfn_t gfn, bool approx) > > An alternative to modifying the PPC code would be to make the existing > search_memslots() a wrapper to __search_memslots(), with the latter taking > @approx. I guess you mean that if search_memslots() only does an exact search (like the current code does) its 3 callers won't have to be modified. Will do it then. > We might also want to make this __always_inline to improve the likelihood of the > compiler optimizing away @approx. I doubt it matters in practice... Sounds like a good idea, will do. Thanks, Maciej