From patchwork Tue Oct 18 04:04:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 3931 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1772365wrs; Mon, 17 Oct 2022 21:35:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM452H7198zOEyL7hSL3CBtiRqcPwUQupBGiVI+TpxvbqDU3hwlryit4JQxufKj6ivG4opjD X-Received: by 2002:a05:6402:406:b0:458:a47:d14c with SMTP id q6-20020a056402040600b004580a47d14cmr884071edv.41.1666067704705; Mon, 17 Oct 2022 21:35:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666067704; cv=none; d=google.com; s=arc-20160816; b=jDYh4fGPxeTrjgEUu5iLl859Jp/5QdeshCz+soyYuMLHgk3RbOpvVV8KMRLwC32Brb ARYwXsk7LBROTocIhI+YjuIdFxGLzRtYZDE6TWZPJTyGPRCUsi55R7qK/1RNZY79i3+R R2iuVgh/coXcJeqTNHmef4ghZIAsvLZSU7ivsppS2ev7XpVgOnpK++A7xjEGaRnGO1N9 16Ku/BF0xnu4kLB7H1QPgdFgqTDkVVIHUy6cwV8idFDsAtjgFStATiLwen3tQef6kXZF DrJYecBOtFxH/N63vzvCsP0baXFMKV+uuVyQNpscn8W1T3IZFoLboMBMIKHydNg3Wgyy oFwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Vvc9nSeTOx+R9O1KRdNsOErR2cLTeHQp0FKXCgftjxs=; b=G2Gy910oheJWf0z2MEDEU7njXGYyjNfshLDNg9QBZEkYB8KPksJKMwd0E9hNsdNRLe O7en3LSSsrGdDYBM6qrt8uMc0Ymg2trzLXI4wGRnYZyODP4/ZxzLvLg89tv0Bbxq6giN wdjz9IrfYGZM3UmHSMIIWqWarU1xgjYzkAlr1C8da0UsWg1LwTr8IvQbPym9n5fLNVW7 tGO8R1fpTXwVYFuA82f1uwZNW+EorJwvg+ggQ3JR09CuwKoQEX+1JJnU7JdeCTC54cCI ISnCQD2P+jAfH+g6hL6ib2NRkyGnc8ydWQmeIHTQp63SuI8q/Q1H8JCGXarJsA/p5Uuh ElBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UtvkP4fl; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq10-20020a1709073f0a00b0078a9cbab78asi12120948ejc.738.2022.10.17.21.34.37; Mon, 17 Oct 2022 21:35:04 -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=UtvkP4fl; 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 S230223AbiJREF3 (ORCPT + 99 others); Tue, 18 Oct 2022 00:05:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230140AbiJREFT (ORCPT ); Tue, 18 Oct 2022 00:05:19 -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 697C53DBF9 for ; Mon, 17 Oct 2022 21:05:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666065915; 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=Vvc9nSeTOx+R9O1KRdNsOErR2cLTeHQp0FKXCgftjxs=; b=UtvkP4flYRfwfRdy8uEHwx3gOiinNAjGNhHneE4s8cSC6+6NxsrBiJp+QcNp1kb9k9rDNd 5JCPg55QIx6cE1kMMkykbCaVq/xiwiEwSOnvp0bl9aPXWgapeMlDLPWk3mFXVLvZ9noiW2 LeVZ/XH2Rp6HWLL7k2jsIKB7Hhh1Zj8= 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-528-zSOD3oF5P3itk5-d8L2GxA-1; Tue, 18 Oct 2022 00:05:10 -0400 X-MC-Unique: zSOD3oF5P3itk5-d8L2GxA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5273229AB3E9; Tue, 18 Oct 2022 04:05:10 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-70.bne.redhat.com [10.64.54.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F55E2166B41; Tue, 18 Oct 2022 04:05:04 +0000 (UTC) From: Gavin Shan To: kvmarm@lists.linux.dev Cc: kvmarm@lists.cs.columbia.edu, 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, mail@maciej.szmigiero.name, maciej.szmigiero@oracle.com, seanjc@google.com, peterx@redhat.com, ricarkol@google.com, zhenyzha@redhat.com, shan.gavin@gmail.com Subject: [PATCH v2 1/6] KVM: selftests: memslot_perf_test: Use data->nslots in prepare_vm() Date: Tue, 18 Oct 2022 12:04:49 +0800 Message-Id: <20221018040454.405719-2-gshan@redhat.com> In-Reply-To: <20221018040454.405719-1-gshan@redhat.com> References: <20221018040454.405719-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746998609574277326?= X-GMAIL-MSGID: =?utf-8?q?1746998609574277326?= In prepare_vm(), 'data->nslots' is assigned with 'max_mem_slots - 1' at the beginning, meaning they are interchangeable. Use 'data->nslots' isntead of 'max_mem_slots - 1'. With this, it becomes easier to move the logic of probing number of slots into upper layer in subsequent patches. No functional change intended. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/memslot_perf_test.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools/testing/selftests/kvm/memslot_perf_test.c index 44995446d942..231cc8449c2e 100644 --- a/tools/testing/selftests/kvm/memslot_perf_test.c +++ b/tools/testing/selftests/kvm/memslot_perf_test.c @@ -280,14 +280,14 @@ static bool prepare_vm(struct vm_data *data, int nslots, uint64_t *maxslots, ucall_init(data->vm, NULL); pr_info_v("Adding slots 1..%i, each slot with %"PRIu64" pages + %"PRIu64" extra pages last\n", - max_mem_slots - 1, data->pages_per_slot, rempages); + data->nslots, data->pages_per_slot, rempages); clock_gettime(CLOCK_MONOTONIC, &tstart); - for (slot = 1, guest_addr = MEM_GPA; slot < max_mem_slots; slot++) { + for (slot = 1, guest_addr = MEM_GPA; slot <= data->nslots; slot++) { uint64_t npages; npages = data->pages_per_slot; - if (slot == max_mem_slots - 1) + if (slot == data->nslots) npages += rempages; vm_userspace_mem_region_add(data->vm, VM_MEM_SRC_ANONYMOUS, @@ -297,12 +297,12 @@ static bool prepare_vm(struct vm_data *data, int nslots, uint64_t *maxslots, } *slot_runtime = timespec_elapsed(tstart); - for (slot = 0, guest_addr = MEM_GPA; slot < max_mem_slots - 1; slot++) { + for (slot = 0, guest_addr = MEM_GPA; slot < data->nslots; slot++) { uint64_t npages; uint64_t gpa; npages = data->pages_per_slot; - if (slot == max_mem_slots - 2) + if (slot == data->nslots - 1) npages += rempages; gpa = vm_phy_pages_alloc(data->vm, npages, guest_addr,