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 mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06890C433FE for ; Mon, 17 Oct 2022 22:19:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 76C674B77B; Mon, 17 Oct 2022 18:19:25 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@redhat.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LHXFVpfQKMRl; Mon, 17 Oct 2022 18:19:22 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 382B94B75C; Mon, 17 Oct 2022 18:19:22 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 4913B4B731 for ; Mon, 17 Oct 2022 18:19:21 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Rm4UMSkfswco for ; Mon, 17 Oct 2022 18:19:19 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mm01.cs.columbia.edu (Postfix) with ESMTP id E9E224B632 for ; Mon, 17 Oct 2022 18:19:19 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666045159; h=from:from:reply-to: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=J22Buvx1QUdA1KfjsZHS/HHBKp3etxDqB4gvS2Hya9U=; b=HDV6SDWrVFTxyWMVeiNCwXRnb+H4BZHMbt9X9WrWSlbTiwyLDtFc0kZn5ncWViH2iajw5T vi8QVRUPdTymVM6BmckxE/3SW8PFvvIfxj8i8KgiD+7TJ11GgiorWbgRjBtUeicfPoRjCH XwOi0CqHIgUEZhZv+fB8t9qHUzLwZMo= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-357-6odBANwtM_CYot3N0g1dxg-1; Mon, 17 Oct 2022 18:19:18 -0400 X-MC-Unique: 6odBANwtM_CYot3N0g1dxg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11E3A1C1436E; Mon, 17 Oct 2022 22:19:02 +0000 (UTC) Received: from [10.64.54.70] (vpn2-54-70.bne.redhat.com [10.64.54.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C7C2640C206B; Mon, 17 Oct 2022 22:18:41 +0000 (UTC) Subject: Re: [PATCH 3/6] KVM: selftests: memslot_perf_test: Probe memory slots for once To: "Maciej S. Szmigiero" References: <20221014071914.227134-1-gshan@redhat.com> <20221014071914.227134-4-gshan@redhat.com> From: Gavin Shan Message-ID: Date: Tue, 18 Oct 2022 06:18:39 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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 X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Gavin Shan List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu T24gMTAvMTgvMjIgMTozNCBBTSwgTWFjaWVqIFMuIFN6bWlnaWVybyB3cm90ZToKPiBPbiAxNC4x MC4yMDIyIDA5OjE5LCBHYXZpbiBTaGFuIHdyb3RlOgo+PiBwcmVwYXJlX3ZtKCkgaXMgY2FsbGVk IGluIGV2ZXJ5IGl0ZXJhdGlvbiBhbmQgcnVuLiBUaGUgYWxsb3dlZCBtZW1vcnkKPj4gc2xvdHMg KEtWTV9DQVBfTlJfTUVNU0xPVFMpIGFyZSBwcm9iZWQgZm9yIG11bHRpcGxlIHRpbWVzLiBJdCdz IG5vdAo+PiBmcmVlIGFuZCB1bm5lY2Vzc2FyeS4KPj4KPj4gTW92ZSB0aGUgcHJvYmluZyBsb2dp YyBmb3IgdGhlIGFsbG93ZWQgbWVtb3J5IHNsb3RzIHRvIHBhcnNlX2FyZ3MoKQo+PiBmb3Igb25j ZSwgd2hpY2ggaXMgdXBwZXIgbGF5ZXIgb2YgcHJlcGFyZV92bSgpLgo+Pgo+PiBObyBmdW5jdGlv bmFsIGNoYW5nZSBpbnRlbmRlZC4KPj4KPj4gU2lnbmVkLW9mZi1ieTogR2F2aW4gU2hhbiA8Z3No YW5AcmVkaGF0LmNvbT4KPj4gLS0tCj4+IMKgIC4uLi90ZXN0aW5nL3NlbGZ0ZXN0cy9rdm0vbWVt c2x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GF2b2lkIGV4dHJhIHZhcmlhYmxlIEBtYXhfbWVtX3Nsb3RzIGFuZCB0aGUKY2FwcGluZyBp cyBtaXNzZWQuIEkgd2lsbCBmaXggaXQgdXAgaW4gbmV4dCByZXZpc2lvbi4KCj4+IMKgwqDCoMKg wqAgcmV0dXJuIHRydWU7Cj4+IMKgIH0KClRoYW5rcywKR2F2aW4KCl9fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCmt2bWFybSBtYWlsaW5nIGxpc3QKa3ZtYXJt QGxpc3RzLmNzLmNvbHVtYmlhLmVkdQpodHRwczovL2xpc3RzLmNzLmNvbHVtYmlhLmVkdS9tYWls bWFuL2xpc3RpbmZvL2t2bWFybQo= From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 65D557F for ; Mon, 17 Oct 2022 22:19:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666045161; h=from:from:reply-to: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=J22Buvx1QUdA1KfjsZHS/HHBKp3etxDqB4gvS2Hya9U=; b=XZF2VhGdq3IhiXgxQz0F3loLAMYBYRpHHXdGso6+qv6rGxIgmwQpeM7iJ52R6DE2DTaqTV pK+NTvs0rz4obGiBNfXDjZRPalhGxYfTrrpJk/VztnoiYayILQjX9rXPhoypGtfjtMj9kJ /ffwcLIQrvewAjTw8Suzk+MR8HgLDlU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-357-6odBANwtM_CYot3N0g1dxg-1; Mon, 17 Oct 2022 18:19:18 -0400 X-MC-Unique: 6odBANwtM_CYot3N0g1dxg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11E3A1C1436E; Mon, 17 Oct 2022 22:19:02 +0000 (UTC) Received: from [10.64.54.70] (vpn2-54-70.bne.redhat.com [10.64.54.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C7C2640C206B; Mon, 17 Oct 2022 22:18:41 +0000 (UTC) Reply-To: Gavin Shan Subject: Re: [PATCH 3/6] KVM: selftests: memslot_perf_test: Probe memory slots for once To: "Maciej S. Szmigiero" 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, seanjc@google.com, peterx@redhat.com, ricarkol@google.com, zhenyzha@redhat.com, shan.gavin@gmail.com References: <20221014071914.227134-1-gshan@redhat.com> <20221014071914.227134-4-gshan@redhat.com> From: Gavin Shan Message-ID: Date: Tue, 18 Oct 2022 06:18:39 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Message-ID: <20221017221839.VlJIz8p1oz6ZzPVEWalmbZ6hi_o7lvLucQfU7WUUXkU@z> On 10/18/22 1:34 AM, Maciej S. Szmigiero wrote: > On 14.10.2022 09:19, Gavin Shan wrote: >> prepare_vm() is called in every iteration and run. The allowed memory >> slots (KVM_CAP_NR_MEMSLOTS) are probed for multiple times. It's not >> free and unnecessary. >> >> Move the probing logic for the allowed memory slots to parse_args() >> for once, which is upper layer of prepare_vm(). >> >> No functional change intended. >> >> Signed-off-by: Gavin Shan >> --- >>   .../testing/selftests/kvm/memslot_perf_test.c | 29 ++++++++++--------- >>   1 file changed, 16 insertions(+), 13 deletions(-) >> >> diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools/testing/selftests/kvm/memslot_perf_test.c >> index dcb492b3f27b..d5aa9148f96f 100644 >> --- a/tools/testing/selftests/kvm/memslot_perf_test.c >> +++ b/tools/testing/selftests/kvm/memslot_perf_test.c >> @@ -245,27 +245,17 @@ static bool prepare_vm(struct vm_data *data, int nslots, uint64_t *maxslots, >>                  void *guest_code, uint64_t mempages, >>                  struct timespec *slot_runtime) >>   { >> -    uint32_t max_mem_slots; >>       uint64_t rempages; >>       uint64_t guest_addr; >>       uint32_t slot; >>       struct timespec tstart; >>       struct sync_area *sync; >> -    max_mem_slots = kvm_check_cap(KVM_CAP_NR_MEMSLOTS); >> -    TEST_ASSERT(max_mem_slots > 1, >> -            "KVM_CAP_NR_MEMSLOTS should be greater than 1"); >> -    TEST_ASSERT(nslots > 1 || nslots == -1, >> -            "Slot count cap should be greater than 1"); >> -    if (nslots != -1) >> -        max_mem_slots = min(max_mem_slots, (uint32_t)nslots); >> -    pr_info_v("Allowed number of memory slots: %"PRIu32"\n", max_mem_slots); >> - >>       TEST_ASSERT(mempages > 1, >>               "Can't test without any memory"); >>       data->npages = mempages; >> -    data->nslots = max_mem_slots - 1; >> +    data->nslots = nslots; >>       data->pages_per_slot = mempages / data->nslots; >>       if (!data->pages_per_slot) { >>           *maxslots = mempages + 1; >> @@ -885,8 +875,8 @@ static bool parse_args(int argc, char *argv[], >>               break; >>           case 's': >>               targs->nslots = atoi(optarg); >> -            if (targs->nslots <= 0 && targs->nslots != -1) { >> -                pr_info("Slot count cap has to be positive or -1 for no cap\n"); >> +            if (targs->nslots <= 1 && targs->nslots != -1) { >> +                pr_info("Slot count cap must be larger than 1 or -1 for no cap\n"); >>                   return false; >>               } >>               break; >> @@ -932,6 +922,19 @@ static bool parse_args(int argc, char *argv[], >>           return false; >>       } >> +    /* Memory slot 0 is reserved */ >> +    if (targs->nslots == -1) { >> +        targs->nslots = kvm_check_cap(KVM_CAP_NR_MEMSLOTS) - 1; >> +        if (targs->nslots < 1) { >> +            pr_info("KVM_CAP_NR_MEMSLOTS should be greater than 1\n"); >> +            return false; >> +        } >> +    } else { >> +        targs->nslots--; >> +    } >> + >> +    pr_info_v("Number of memory slots: %d\n", targs->nslots); >> + > > Can't see any capping of the command line provided slot count to > KVM_CAP_NR_MEMSLOTS value, like the old code did. > Indeed. I wanted to avoid extra variable @max_mem_slots and the capping is missed. I will fix it up in next revision. >>       return true; >>   } Thanks, Gavin