Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp808529pxy; Wed, 28 Apr 2021 14:45:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6xounPIWAbobY9nHWkXcTRadAoI4UsNRXBFdFo1iGv2pOOwGfnjXOzO2rfoWYryjuFkPU X-Received: by 2002:a05:6402:3591:: with SMTP id y17mr14177572edc.67.1619646340228; Wed, 28 Apr 2021 14:45:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619646340; cv=none; d=google.com; s=arc-20160816; b=QlW6xv+uc8OAWg88+6MEf7IhsIuCnPL8eVp9uuP7E60nJHN+dsgx1D6bC2X2BTUQh0 omwwJVwHQ4uelmyFwAATAVovl6jsm2vpDBlNuCwmhl+sht5MNR/ehu+Mp4J9TFu5WBDx pwCUYEO1/xyxBaU06rmzIabrT5Js/Y1xUMg5KbMF1XRymagcI0QEBsNM4Qe+tc1Y2ZAB 872O00PVO0s5ae3vOROC9RPgaHm5Yj3KWKY1XcVWBMcCzJE2nZuTgUoCus6vG2chWy11 cszxTFMqZumuhCEqnLnkrB2zlJzRDLTzzEGMFu/C3uf6pmsPHD3cQK/r/0D+w7MbaplK TrVg== 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:dkim-signature; bh=/v4ZNp/t+nbs+oINjnStizm6FqJH+orku1bF/7PUqww=; b=CcEgYSZtLK03nyvNxWnSWfzvuiBOFNOALl4wmBScQhtBHbMdu+gtcOYwH8+7rpob5v n06TWWU/OkIfsvncbEpeJkfY3gWbKUK3PvP9W3W/4qJP1QDwF7XXErWPk179efVGLQ4Q QVYjxaG2x+bIJ+7fXyIOfTbFV5GlhZTWyaxyWY430M/p3sScIFTRJ33sGSHZH5BMcVbt XP6JRgaHkSt/USsHcia7inqNrokirPv2X9KFD6EnXE+4KmdctyT335ULiRU1qlztXS66 rBUWKXfhuLNUPa+fRt9QhssY5Ro0zayvCIiBjp7sRiaf/adT1QSPY+vVT5PXqlcbgfgh qLXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=K95q2QVH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t6si1101467ejj.37.2021.04.28.14.45.15; Wed, 28 Apr 2021 14:45:40 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=K95q2QVH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231437AbhD1Vml (ORCPT + 99 others); Wed, 28 Apr 2021 17:42:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25612 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbhD1Vmk (ORCPT ); Wed, 28 Apr 2021 17:42:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619646115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/v4ZNp/t+nbs+oINjnStizm6FqJH+orku1bF/7PUqww=; b=K95q2QVHtgFv9TwoQa/he+iJXQMsxqHZeoI2is3hDO2VJa5DZdXgTDbYPtDIVvM5mHa1KY HZTyObVhcA9Ebc0d8CJgvHYwFzJf7QPPZd7VZWmGveiDHJWU3r3XWdUbFPqIRSL1soM6qk M7RvmwL9UDuKEX4G/VdyXAwd08g5lnw= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-70-8XYIYc6fOzOoj0_3uvpDeQ-1; Wed, 28 Apr 2021 17:41:50 -0400 X-MC-Unique: 8XYIYc6fOzOoj0_3uvpDeQ-1 Received: by mail-ej1-f70.google.com with SMTP id e18-20020a17090681d2b0290384d9ff1359so3922502ejx.16 for ; Wed, 28 Apr 2021 14:41:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/v4ZNp/t+nbs+oINjnStizm6FqJH+orku1bF/7PUqww=; b=Fbsi7SAEgmhhdmE7v4ytopw36GnskSZNtVzv2v8ldqbd0lJ8sv2PYlLVFsvRn8OtHw jqgufXhfGMCvW7ufHZL8iNLKhTS7N6nCALeW3tmvCVoEP6PhD9z4YY4MX+WnA52grHGR pi0dT5nRNRjvAOCLRKgMDuJQw3auqF5KhcawSjoEAZGMpDVPIDL1+TUhUh1n9EMy21w9 qZanmjGbVmwTRySSVx3O2PkauDAUqokd3N7CAhE3Yz9zGxOrOZoR4sROyspvOslN/4TR Mwu6L/m2Gm+0zN79eA5ZNKryw4mJZiCbm8d0viDYgkSQ4dIzUn/BNR2K0zppLOUBJuRc gZGw== X-Gm-Message-State: AOAM531HPDR9WKhNkEMI8XBKbjIfQiOQUNEq9M+Gtk8GE+vxApJIUOwx L+gU5vRstOLfSS92AYiMXKYi/1LcK3iU0wfcgjflMbbWsb75E1DanRGtE68XIE4UYPByF3WVcam QRCJCxRnplViaKDGwOTYJrlR7 X-Received: by 2002:a05:6402:154:: with SMTP id s20mr14652848edu.90.1619646109792; Wed, 28 Apr 2021 14:41:49 -0700 (PDT) X-Received: by 2002:a05:6402:154:: with SMTP id s20mr14652829edu.90.1619646109630; Wed, 28 Apr 2021 14:41:49 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:63a7:c72e:ea0e:6045? ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id z4sm734735edb.97.2021.04.28.14.41.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Apr 2021 14:41:48 -0700 (PDT) To: Ben Gardon Cc: LKML , kvm , Peter Xu , Sean Christopherson , Peter Shier , Junaid Shahid , Jim Mattson , Yulei Zhang , Wanpeng Li , Vitaly Kuznetsov , Xiao Guangrong References: <20210427223635.2711774-1-bgardon@google.com> <20210427223635.2711774-6-bgardon@google.com> <997f9fe3-847b-8216-c629-1ad5fdd2ffae@redhat.com> From: Paolo Bonzini Subject: Re: [PATCH 5/6] KVM: x86/mmu: Protect kvm->memslots with a mutex Message-ID: <5b4a0c30-118c-da1f-281c-130438a1c833@redhat.com> Date: Wed, 28 Apr 2021 23:41:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.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 28/04/21 22:40, Ben Gardon wrote: > ... However with the locking you propose below, we might still run > into issues on a move or delete, which would mean we'd still need the > separate memory allocation for the rmaps array. Or we do some > shenanigans where we try to copy the rmap pointers from the other set > of memslots. If that's (almost) as easy as passing old to kvm_arch_prepare_memory_region, that would be totally okay. > My only worry is the latency this could add to a nested VM launch, but > it seems pretty unlikely that that would be frequently coinciding with > a memslot change in practice. Right, memslot changes in practice occur only at boot and on hotplug. If that was a problem we could always make the allocation state off/in-progress/on, allowing to check the allocation state out of the lock. This would only potentially slow down the first nested VM launch. Paolo