From patchwork Thu Oct 20 07:12:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 5988 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp108281wrs; Thu, 20 Oct 2022 00:13:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5uro9pQ+sviGZmbFqMi/FB1JFE0eZSawnCWsBmJNqKuT3GmAsn2OOmMcFv5IqtiBez/p4F X-Received: by 2002:a17:90b:3845:b0:20d:ad62:bba1 with SMTP id nl5-20020a17090b384500b0020dad62bba1mr14344130pjb.183.1666250002827; Thu, 20 Oct 2022 00:13:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666250002; cv=none; d=google.com; s=arc-20160816; b=zTGfD0qRAUcbGPZ8snBLLUWTJN4IHZmWx7vbVAK8vioUpt0CvUviC/pg3d5OqUEE38 gI/5TTvdkXSW5+biyPRM9htCFRaVpAgeRrTWOHyATHWUwlUfFrmATs2D3jfzemRKuyLU FSmvxZR8WrcjeApkwi+6JGz1JYDxDeQJJV22E1jw4NQ6YsJm7F+ZpNvn/LuuEjDqO/Hf 81K3nNGQrfOEczh15xP1B1OL+8T5WBEEBAJJugGy1WbMwFXYscSL6+jlyXB+GEZ3Ebq4 gPVjf2ChO88J06Cu39CiSG4Jx/J/1mm3+V4Zq7R8GaW4EaPldLoKfmNOSs4z28VZ0wYH U7bA== 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=xIvr8fbVyYBR9DpwXGZpO2ZU+a7HYDL8tQS63CcwgNAMeOV2sh+uBlkhnXP1ZfVG7e OPS3uIvLS9/onI5Cly7q1Eg+9g7CUvbLu32eW7rrFtOldH/YWlgQIB32wEP+j5DTQnyX UMXm+YM9RbE+xVdZAQczW/REIcMxHZGgrgcOinSvduNIqHgXMfAGsZ6pjyW6ncH9fW5z KkKkIPSIahJtqZhxZEEmpy1qyn7Sr4K4AzO343LTf0ykZMTwZd6bPB0pB3Aktyq/oqCB rb7BSPifV9uY22xw95IhMKeQiZc2lQbqF7oxIAyJBvLbAvRw54Yg/IUo7sAJbj7ZfGF1 Hc4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CcvAsuDe; 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 y12-20020aa793cc000000b0052e677b7052si20031653pff.244.2022.10.20.00.13.10; Thu, 20 Oct 2022 00:13:22 -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=CcvAsuDe; 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 S230104AbiJTHMz (ORCPT + 99 others); Thu, 20 Oct 2022 03:12:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230030AbiJTHMx (ORCPT ); Thu, 20 Oct 2022 03:12:53 -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 92AFA159A16 for ; Thu, 20 Oct 2022 00:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666249971; 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=CcvAsuDev7iPCjmpV7AU/neC5M71gOuEEYaWRisGWyTIO7Jm2OTLCS+OIZaBQFxIBERdcw M4NwOGkAktP6AesiAFFNR/ATSdZ05/evfDL6LqIFRSzi6/P4wi0YsvEVyBItjfGbLtgmnu lJ9mXfkU3Ug5xsDfcj0jGefNj0pqZBw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-296-nI8UtPRCNiuaY4FWD93Yig-1; Thu, 20 Oct 2022 03:12:49 -0400 X-MC-Unique: nI8UtPRCNiuaY4FWD93Yig-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 51B56101A528; Thu, 20 Oct 2022 07:12:49 +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 574EA40C6EC2; Thu, 20 Oct 2022 07:12:44 +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, mail@maciej.szmigiero.name, maz@kernel.org, pbonzini@redhat.com, ajones@ventanamicro.com, shuah@kernel.org, peterx@redhat.com, oliver.upton@linux.dev, seanjc@google.com, ricarkol@google.com, zhenyzha@redhat.com, shan.gavin@gmail.com Subject: [PATCH v3 1/6] KVM: selftests: memslot_perf_test: Use data->nslots in prepare_vm() Date: Thu, 20 Oct 2022 15:12:04 +0800 Message-Id: <20221020071209.559062-2-gshan@redhat.com> In-Reply-To: <20221020071209.559062-1-gshan@redhat.com> References: <20221020071209.559062-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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?1747189762780536678?= X-GMAIL-MSGID: =?utf-8?q?1747189762780536678?= 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,