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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3FC0C433EF for ; Fri, 12 Nov 2021 01:05:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 B001661106 for ; Fri, 12 Nov 2021 01:05:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B001661106 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YTWn8piYEDtKhvcYWTxCu8YGk3N8PByoUbZ0y6adANg=; b=gQn5V04Pj9S7Is g344cPgJJNCWmK2tSSLL7/NZSZrYKfpwkyCL8UyqLLnOxqze+QcaSIpdGV8czutlqhMvDN0Dt87U9 Vm+ih5/g1WFlryKi6qSpCz9Wyy9x+YzgTdlbgV5wKs+bpTIQdWa4qeT6RxBHO7SuwXT9dLo2AmfJE w6AWQ5TvLe363t1hLcyTcAJ9wt1a/6ZOA/7MXvTCVWNCoKEtLYNpr4cjyfrJ5jP39TY+wPrKegKm1 CyC/yZRmzPuqhMF4/+a8W/rV2zoiHI1WvfqjfwnjWehpBaB413KDoKRRLqI2Sz2yjYvqMpEZ9jWGy 0xxVznAWP6PB3HGZoZWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mlKzA-0097Hq-9I; Fri, 12 Nov 2021 01:04:08 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mlKz4-0097FS-3k for linux-arm-kernel@lists.infradead.org; Fri, 12 Nov 2021 01:04:05 +0000 Received: by mail-pf1-x430.google.com with SMTP id x64so7072711pfd.6 for ; Thu, 11 Nov 2021 17:03:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=OqiUBkPNwVtm2ZpjSEzoYhMNAp4tNbVTba3KEv6WN8w=; b=pc7ejE9G9f2/DNPzPS7XIXvJtmGfBaF2LxIzkZwFvEfuQOri3Y1155wjk7xjt2PNCJ kE24TIPjCcGgUSYiX3UWCA1DBdTKkT1C74bahVgNb9tmSS/hJEwGE9hxKY7yJMJ5/gnk kd+TrPPKr0MuJqBAypaAOFEn7+cRqbZm+iMfctLBeivKDevpGMITf+s6vQitBcPNGTgw /amQnFMW1BnWMyjEaECoc/twxm/ddAt9qLXsEQJ21ZE/S+ANAhdIOkrMWTDwWGDr9sqH T2DNYEPOqsm0H4/svC1i15A5EDGrV+fHlrcxZdbN2PUtjvWHGe4Hnq190TEFtTm6CJzc ynvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=OqiUBkPNwVtm2ZpjSEzoYhMNAp4tNbVTba3KEv6WN8w=; b=SKrCf8wLW5I6A1yhVWxD2im2SvJcof0Dwxduiy9df0D/W65wFwfFomoZ8ghiBab7rI 1fWCyvrYWqCRZozziBxbayk/hY8GBnrKGCpqI2c03y0AMVMaKdSZaJJf/udSkG3TaESR lt1R1crOVGfc3bP30YcnU8BjFeHJM5u1GJzSgjnNQPJSj2OsVj+ewdLCv/mmibzk/K4z CCuVnLMrGj0E6VLuGB0neD+3JfWA5DC/VxDqeKzYUZDTxzbJqy8ORpf6cQ5skYszfuwD AlGjbK8whd+/W8e+rsG99vqH230RR8WhtnzPfTtlY1Jfu/7YXFYNtXMqwwZT88SUoYkj ONfw== X-Gm-Message-State: AOAM533Xo4DPzaz1Kbt8HH3L3mjLW8kOmAELpEplTsp/2FCFFgJC0g6s E98MfkiExWoUa+unzAEURvozWQ== X-Google-Smtp-Source: ABdhPJxMgoJUa9ek+o+tvzW6z5WeFQCDZekoSsl946lRj2FCOsMM6fcE3+3c50Ng/MtZ8Re7BsLCDg== X-Received: by 2002:a63:1441:: with SMTP id 1mr7559189pgu.66.1636679035969; Thu, 11 Nov 2021 17:03:55 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id t13sm4096818pfl.214.2021.11.11.17.03.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 17:03:55 -0800 (PST) Date: Fri, 12 Nov 2021 01:03:51 +0000 From: Sean Christopherson To: "Maciej S. Szmigiero" Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Atish Patra , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Ben Gardon , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Paolo Bonzini Subject: Re: [PATCH v5.5 23/30] KVM: Resolve memslot ID via a hash table instead of via a static array Message-ID: References: <20211104002531.1176691-1-seanjc@google.com> <20211104002531.1176691-24-seanjc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211111_170402_177481_D39153CE X-CRM114-Status: GOOD ( 26.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Nov 12, 2021, Maciej S. Szmigiero wrote: > On 04.11.2021 01:25, Sean Christopherson wrote: > > From: Maciej S. Szmigiero > > > > Memslot ID to the corresponding memslot mappings are currently kept as > > indices in static id_to_index array. > > The size of this array depends on the maximum allowed memslot count > > (regardless of the number of memslots actually in use). > > > > This has become especially problematic recently, when memslot count cap was > > removed, so the maximum count is now full 32k memslots - the maximum > > allowed by the current KVM API. > > > > Keeping these IDs in a hash table (instead of an array) avoids this > > problem. > > > > Resolving a memslot ID to the actual memslot (instead of its index) will > > also enable transitioning away from an array-based implementation of the > > whole memslots structure in a later commit. > > > > Signed-off-by: Maciej S. Szmigiero > > Co-developed-by: Sean Christopherson > > Signed-off-by: Sean Christopherson > > --- > > include/linux/kvm_host.h | 16 +++---- > > virt/kvm/kvm_main.c | 96 +++++++++++++++++++++++++++++++--------- > > 2 files changed, 84 insertions(+), 28 deletions(-) > > > (..) > > @@ -1259,17 +1257,49 @@ static int kvm_alloc_dirty_bitmap(struct kvm_memory_slot *memslot) > > return 0; > > } > > +static void kvm_replace_memslot(struct kvm_memslots *slots, > > + struct kvm_memory_slot *old, > > + struct kvm_memory_slot *new) > > +{ > > + /* > > + * Remove the old memslot from the hash list, copying the node data > > + * would corrupt the list. > > + */ > > + if (old) { > > + hash_del(&old->id_node); > > + > > + if (!new) > > + return; > > + } > > + > > + /* Copy the source *data*, not the pointer, to the destination. */ > > + if (old) > > + *new = *old; > > This way of writing it (that, is re-checking whether "old" is not-NULL) > suggests that it could have been set to NULL inside the previous block > (since the last check), which isn't true. Yeah, I think I was trying to minimize the logic delta in future patches, but looking back at the diffs, that didn't pan out. I've no objection to folding the two together. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel