From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 420DB1C12 for ; Mon, 17 Oct 2022 22:57:08 +0000 (UTC) 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 1okZ2Z-00024i-Nz; Tue, 18 Oct 2022 00:56:59 +0200 Message-ID: <93529fb7-f558-cc5f-d5bd-7923eb4b492c@maciej.szmigiero.name> Date: Tue, 18 Oct 2022 00:56:53 +0200 Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH 5/6] KVM: selftests: memslot_perf_test: Consolidate memory sizes Content-Language: en-US, pl-PL To: Gavin Shan , Sean Christopherson Cc: kvmarm@lists.cs.columbia.edu, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, ajones@ventanamicro.com, pbonzini@redhat.com, maz@kernel.org, shuah@kernel.org, oliver.upton@linux.dev, peterx@redhat.com, ricarkol@google.com, zhenyzha@redhat.com, shan.gavin@gmail.com References: <20221014071914.227134-1-gshan@redhat.com> <20221014071914.227134-6-gshan@redhat.com> <9781c88f-06f9-4d17-8fa6-3cd82a739ccb@redhat.com> From: "Maciej S. Szmigiero" In-Reply-To: <9781c88f-06f9-4d17-8fa6-3cd82a739ccb@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <20221017225653.7Ste2_vfR4qwyAvxrcVu3ANlSmSXyufygAdDbOFBh3w@z> On 18.10.2022 00:51, Gavin Shan wrote: > On 10/18/22 6:08 AM, Sean Christopherson wrote: >> On Mon, Oct 17, 2022, Maciej S. Szmigiero wrote: >>>> +#define MEM_EXTRA_SIZE        0x10000 >>> >>> Also, an expression like "(64 << 10)" is more readable than a "1" >>> with a tail of zeroes (it's easy to add one zero too many or be one >>> zero short). >> >> +1 to not open coding raw numbers. >> >> I think it's high time KVM selftests add #defines for the common sizes, e.g. SIZE_4KB, >> 16KB, 64K, 2MB, 1GB, etc... >> >> Alternatively (or in addition), just #define 1KB, 1MB, 1GB, and 1TB, and then do >> math off of those. >> > > Ok. I will have one separate patch to define those sizes in kvm_util_base.h, > right after '#define NSEC_PER_SEC 1000000000L'. Sean, could you let me know > if it looks good to you? > >     #define KB         (1UL << 10) >     #define MB         (1UL << 20) >     #define GB         (1UL << 30) >     #define TB         (1UL << 40) > >     /* Base page and huge page size */ >     #define SIZE_4KB   (  4 * KB) >     #define SIZE_16KB  ( 16 * KB) >     #define SIZE_64KB  ( 64 * KB) >     #define SIZE_2MB   (  2 * MB) >     #define SIZE_32MB  ( 32 * MB) >     #define SIZE_512MB (512 * MB) >     #define SIZE_1GB   (  1 * GB) >     #define SIZE_16GB  ( 16 * GB) FYI, QEMU uses KiB, MiB, GiB, etc., see [1]. > Thanks, > Gavin > Thanks, Maciej [1]: https://git.qemu.org/?p=qemu.git;a=blob;f=include/qemu/units.h;hb=HEAD