Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp730151rwb; Tue, 27 Sep 2022 04:01:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM539UTBNLTdqt1ASa6wY+/XSbNdYKgk6T8Kmu3iWI3vLHIdu5benU7Csm75+84slF0cUvMe X-Received: by 2002:a65:62c5:0:b0:434:d997:5848 with SMTP id m5-20020a6562c5000000b00434d9975848mr23394002pgv.603.1664276519666; Tue, 27 Sep 2022 04:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664276519; cv=none; d=google.com; s=arc-20160816; b=WQyQvtEoWS6jrdIfbQ6lERH4MY0wqTP/Hmbj8+kCZuZ6DsVD7Xjj7LgOjGIn/5WPDg /sVgJO4NyWcGexW0Xoz9+oVjUSFn1iuiwtc399zR/wKWabft/aR5PScUN3xNUpy3OTYq hgAmqpAVnW8M6/X2eRrs9lsxV/x4ylHkW3Hx/FMOuezU0n2PwyLM0YrfUfIvNKTQ+c+f Iodm5OewMTJjZTC/uYzTtym1OZzXVzZ5vXqcxJaykL+1+/TCZmb+vtCUe7eSJbuTRLwE N57u2pzeREh3MkC8WNCwF0EMrF8klwebe+aClPnC8SpXT0dCMdC6xpFN/MDwVYJdKbxf 70/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=6+Ba1/Qa0bdARicBepVl0B2bwfkxaeMWLDXIhxaAd8k=; b=fDEE0GQWOSC6q/y3arhj4cTaqB4+7EdT2xWwcJ1XdkYNtbsqbrI1wL8G/kLu2k1rIq WWcB9fqDQETJzT5KKrnzgXTNqoGoie0Qr9kDpCN0+VSrzSB9BE/ItU5SUZRhCr/sdZj1 KKK1cwBpJ3baqZZ2PZi2p9s6fX9tXjWRMP06uDxdn2Z7zB1L52J8E+AaNyTjPBk2hzb9 x+fwm50b/vyS7S1es9lnUnw4dPd2r2DX/kKxm3isBpOnlcOr2Ka3cIC00mw8tIoDSBhf +sABXBLc35DbTw7bUEOk4lK/TX9gJfDbE+tJ+i7sFiBaid8UIfPXb1Bw4VUHxRO8aWss GkBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="EeOA/5iw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o5-20020a1709026b0500b001782a6fbc7csi1297520plk.463.2022.09.27.04.01.47; Tue, 27 Sep 2022 04:01:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="EeOA/5iw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231875AbiI0JYm (ORCPT + 99 others); Tue, 27 Sep 2022 05:24:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231872AbiI0JYU (ORCPT ); Tue, 27 Sep 2022 05:24:20 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7486FB311 for ; Tue, 27 Sep 2022 02:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664270544; 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=6+Ba1/Qa0bdARicBepVl0B2bwfkxaeMWLDXIhxaAd8k=; b=EeOA/5iwGUlOLM5Kpm189twXoxm8y9AEd1WTuJN6hZVSn20rVhh2NYIfLYG6VNXRB910H0 m5uL0zPyB3pSsFdWr54c19af92Dblf8F0OdPcb8yGrG56+IooM6Yr7zTEDJ14rRghVQOoO +w/paGdPU697EBJYUlPLkiChmPcJ9o4= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-330-Qut-A9wYO8-6Bv6bEVj91A-1; Tue, 27 Sep 2022 05:22:23 -0400 X-MC-Unique: Qut-A9wYO8-6Bv6bEVj91A-1 Received: by mail-wr1-f70.google.com with SMTP id g15-20020adfbc8f000000b0022a4510a491so1968943wrh.12 for ; Tue, 27 Sep 2022 02:22:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date; bh=6+Ba1/Qa0bdARicBepVl0B2bwfkxaeMWLDXIhxaAd8k=; b=epXnjqsAevbtNpI1CyV/ILfTr26NWRvUARbML88ISASeZ/WHcdwB+Me4li8JLTv87Y jQ+RUELBJKz6mDQDd29Mo0hJh5Zj0jHVQOXQ5uTHExgIo1tqae7rfzeUvVawyYsoIQip avWNpT0oaD/RpYW5WXa7t/ACmPoGJdVDdo5L/d+QLg2QESoAAjzhkT07r1gWHM5las// pxZaEi8cqXQOPVrYQhxYw52QTTgwNm2XgZNUePAynUnezCqeBSPTfQi7cgsufYyQbN/b dNTZ+YP/VJOkD64fiJ3XGv8pqASHjz5ViSX3sV3cR8g7uFVB5Hen7r5KM/K3y/z42xRZ hmtQ== X-Gm-Message-State: ACrzQf26CbFFZPhiQ67cV1dwi99XOdFxz3z5eQO4dYRt94t7tu9DZ/3i /u43hB9e3EAlo3rjULJMHGWy85HCxXSVgwKtSk9kttojib2ZD2Qe2yhCB5174xqO12UfnM9Xrut nQxnDQK+IW66H1nC3qCra8Epl X-Received: by 2002:a5d:6d4e:0:b0:22c:9dfd:4159 with SMTP id k14-20020a5d6d4e000000b0022c9dfd4159mr7051784wri.307.1664270542274; Tue, 27 Sep 2022 02:22:22 -0700 (PDT) X-Received: by 2002:a5d:6d4e:0:b0:22c:9dfd:4159 with SMTP id k14-20020a5d6d4e000000b0022c9dfd4159mr7051751wri.307.1664270541978; Tue, 27 Sep 2022 02:22:21 -0700 (PDT) Received: from ?IPV6:2003:cb:c705:ff00:9ec2:6ff6:11a1:3e80? (p200300cbc705ff009ec26ff611a13e80.dip0.t-ipconnect.de. [2003:cb:c705:ff00:9ec2:6ff6:11a1:3e80]) by smtp.gmail.com with ESMTPSA id d12-20020adfe88c000000b002205a5de337sm1226236wrm.102.2022.09.27.02.22.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Sep 2022 02:22:21 -0700 (PDT) Message-ID: Date: Tue, 27 Sep 2022 11:22:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [RFC PATCH 9/9] kvm_main.c: handle atomic memslot update Content-Language: en-US To: Emanuele Giuseppe Esposito , kvm@vger.kernel.org Cc: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Maxim Levitsky , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org References: <20220909104506.738478-1-eesposit@redhat.com> <20220909104506.738478-10-eesposit@redhat.com> <07014070-5186-ca95-7028-82f77612dedd@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <07014070-5186-ca95-7028-82f77612dedd@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27.09.22 10:35, Emanuele Giuseppe Esposito wrote: > > > Am 27/09/2022 um 09:46 schrieb David Hildenbrand: >> On 09.09.22 12:45, Emanuele Giuseppe Esposito wrote: >>> When kvm_vm_ioctl_set_memory_region_list() is invoked, we need >>> to make sure that all memslots are updated in the inactive list >>> and then swap (preferreably only once) the lists, so that all >>> changes are visible immediately. >>> >>> The only issue is that DELETE and MOVE need to perform 2 swaps: >>> firstly replace old memslot with invalid, and then remove invalid. >>> >> >> I'm curious, how would a resize (grow/shrink) or a split be handled? >> > > There are only 4 operations possible in KVM: KVM_MR_{DELETE, MOVE, > CREATE, FLAGS_ONLY}. > > A resize should be implemented in QEMU as DELETE+CREATE. > > Therefore a resize on memslot X will be implemented as: > First pass on the userspace operations: > invalidate memslot X; > swap_memslot_list(); // NOW it is visible to the guest > > What guest sees: memslot X is invalid, so MMU keeps retrying the page fault > > Second pass: > create new memslot X > delete old memslot X Thanks a lot for the very nice explanation! Does the invalidation already free up memslot metadata (especially the rmaps) or will we end up temporarily allocating twice the memslot metadata? -- Thanks, David / dhildenb