Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6206742rwi; Tue, 18 Oct 2022 09:20:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5E6UsqgOqeOhSTEl8dr85gp0n888j1goJy8cJcj2W4yIWVlJRpOiprYNNc4V4F27drARPV X-Received: by 2002:a05:6402:1906:b0:45d:db20:7709 with SMTP id e6-20020a056402190600b0045ddb207709mr3207870edz.406.1666110036282; Tue, 18 Oct 2022 09:20:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666110036; cv=none; d=google.com; s=arc-20160816; b=XnA6Y3+Y+TlnH28kzDzkngAp/qIi9mdPk5fYDtLQ4FZ9K0/BBpn9g2KB+GO2NxQins /KJbPD1jKNQv6xEPKT5RULRjnYE547mmVK5GHH8X+m4Pp5XuEXFW/5oGPlpSsfBH64GB njT/Q7jzeaLPDaTXcX7kityG4XLqw5IZKBcw8G2B8iEsWcktHb5XfFrnJ/0MeRrUIuWy BqVYPMULy4Mh4kgAkw4VYgSlvEKEr3QDADGUreDF84KLI1BGL/Qr+Ne4NOu4VOQ5/b/m k8lXDblRzNkbNQTwcFKkQXwqAUxfqYc/DqyXM0yEeEqHfApVWPhXgg/jO0IjHk83a5Bq 8mxw== 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:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id; bh=bKQl04+ktowA+tAr2lDKtEKJUm/DmgFy8CFOrfqL6TY=; b=k/cKZEamP9v3qNjH7Bkfh9c7baglkSQjTHl2EGpfUwc+PE9mDMFUFE0WCzYKvVAd+c 84vzbYlvPVTR1nxncyuVtMEiVj148XKLb/wqvhDhI/Gtn2ZC0/TwsyGUzafnc0CFdi7r DkAedTFtdWus9htV1xsJHPlPt97DTzYQ7a1iT7xRLoMRsn/uch0sESaIzpcmxC5l+EiR A0XoI6IY1NiX0/pAVjRavuJNG0V6gAWdMx73C0S9o0k3v3/NC42a7brvPkJJwZDNdDUA uTZ+F/cfho5o+t+aFAGU1vdVIg8DlG9kBHiIaPS0V3nrgD/Rb6r1Z82Z4IK6QwMRm06D J9vg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l25-20020a170906415900b0077951929340si11377092ejk.271.2022.10.18.09.20.09; Tue, 18 Oct 2022 09:20:36 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230514AbiJRP4m (ORCPT + 99 others); Tue, 18 Oct 2022 11:56:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230087AbiJRP4k (ORCPT ); Tue, 18 Oct 2022 11:56:40 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1598414011; Tue, 18 Oct 2022 08:56:38 -0700 (PDT) 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 1okoxF-0006rH-E8; Tue, 18 Oct 2022 17:56:33 +0200 Message-ID: Date: Tue, 18 Oct 2022 17:56:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Content-Language: en-US, pl-PL To: Gavin Shan Cc: kvm@vger.kernel.org, maz@kernel.org, linux-kernel@vger.kernel.org, zhenyzha@redhat.com, shan.gavin@gmail.com, kvmarm@lists.linux.dev, pbonzini@redhat.com, shuah@kernel.org, kvmarm@lists.cs.columbia.edu, ajones@ventanamicro.com References: <20221014071914.227134-1-gshan@redhat.com> <20221014071914.227134-5-gshan@redhat.com> <3eecebca-a526-d10a-02d3-496ce919d577@maciej.szmigiero.name> From: "Maciej S. Szmigiero" Subject: Re: [PATCH 4/6] KVM: selftests: memslot_perf_test: Support variable guest page size In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS 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 18.10.2022 02:51, Gavin Shan wrote: > On 10/18/22 8:46 AM, Gavin Shan wrote: >> On 10/18/22 5:31 AM, Maciej S. Szmigiero wrote: >>> On 14.10.2022 09:19, Gavin Shan wrote: >>>> The test case is obviously broken on aarch64 because non-4KB guest >>>> page size is supported. The guest page size on aarch64 could be 4KB, >>>> 16KB or 64KB. >>>> >>>> This supports variable guest page size, mostly for aarch64. >>>> >>>>    - The host determines the guest page size when virtual machine is >>>>      created. The value is also passed to guest through the synchronization >>>>      area. >>>> >>>>    - The number of guest pages are unknown until the virtual machine >>>>      is to be created. So all the related macros are dropped. Instead, >>>>      their values are dynamically calculated based on the guest page >>>>      size. >>>> >>>>    - The static checks on memory sizes and pages becomes dependent >>>>      on guest page size, which is unknown until the virtual machine >>>>      is about to be created. So all the static checks are converted >>>>      to dynamic checks, done in check_memory_sizes(). >>>> >>>>    - As the address passed to madvise() should be aligned to host page, >>>>      the size of page chunk is automatically selected, other than one >>>>      page. >>>> >>>>    - All other changes included in this patch are almost mechanical >>>>      replacing '4096' with 'guest_page_size'. >>>> >>>> Signed-off-by: Gavin Shan >>>> --- >>>>   .../testing/selftests/kvm/memslot_perf_test.c | 191 +++++++++++------- >>>>   1 file changed, 115 insertions(+), 76 deletions(-) >>>> >>>> diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools/testing/selftests/kvm/memslot_perf_test.c >>>> index d5aa9148f96f..d587bd952ff9 100644 >>>> --- a/tools/testing/selftests/kvm/memslot_perf_test.c >>>> +++ b/tools/testing/selftests/kvm/memslot_perf_test.c (...) >>>> @@ -77,8 +61,7 @@ static_assert(MEM_TEST_UNMAP_SIZE_PAGES % >>>>    * for the total size of 25 pages. >>>>    * Hence, the maximum size here is 50 pages. >>>>    */ >>>> -#define MEM_TEST_MOVE_SIZE_PAGES    (50) >>>> -#define MEM_TEST_MOVE_SIZE        (MEM_TEST_MOVE_SIZE_PAGES * 4096) >>>> +#define MEM_TEST_MOVE_SIZE        0x32000 >>> >>> The above number seems less readable than an explicit value of 50 pages. >>> >>> In addition to that, it's 50 pages only with 4k page size, so at least >>> the comment above needs to be updated to reflect this fact. >>> >> >> Yeah, I will change the comments like below in next revision. >> >>   /* >>    * When running this test with 32k memslots, actually 32763 excluding >>    * the reserved memory slot 0, the memory for each slot is 0x4000 bytes. >>    * The last slot contains 0x19000 bytes memory. Hence, the maximum size >>    * here is 0x32000 bytes. >>    */ >> > > I will replace those numbers with readable ones like below :) > > /* >  * When running this test with 32k memslots, actually 32763 excluding >  * the reserved memory slot 0, the memory for each slot is 16KB. The >  * last slot contains 100KB memory with the remaining 84KB. Hence, >  * the maximum size is double of that (200KB) >  */ Still, these numbers are for x86, which has KVM_INTERNAL_MEM_SLOTS defined as 3. As far as I can see aarch64 has KVM_INTERNAL_MEM_SLOTS equal to 0, so this arch has 32766 slot available for the test memory. Quick calculations show that this will result in 112 KiB of memory in the last slot for 4 KiB page size (while for 64 KiB page size the maximum slot count for this test is 8192 anyway - not counting slot 0). > Thanks, > Gavin > Thanks, Maciej