Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1716083pxb; Wed, 10 Feb 2021 15:14:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyn4/aDQmscJ8iWXJLXUYRhtz0g+18+xbUrZZMaLeMjelN/UIqdlwAqT8xnbWpUugMnrQo/ X-Received: by 2002:a17:906:cc50:: with SMTP id mm16mr5284344ejb.366.1612998894289; Wed, 10 Feb 2021 15:14:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612998894; cv=none; d=google.com; s=arc-20160816; b=p6kC1mOsCjIMLg6vGLdb4rbMcjp2WxgILeX/ylxmWX6JpiPc1sJdoINsnvys0+p2LR LjqzEG81sHNwEBXUzz4ZsKXfmykyFo7uyqTHlBLg4CuwNgrJgbhlszMPsHv6EsBNl3M2 720DLUpF6dgNsx/d0/W452Pt45+Wi3ZSNQ6GFPb0ndiqGDAaD9kB8CZrUTP3UeEHwZQ/ /a0rCgyuYIYAyj2+i+xTDRJdYt+WusRHhx4LjEQ9vUfJ5DW8oVJLXb5kZhjfta1M3bUH veBS2PmGampIho2jetBIKczh+Nzeqvg6SHDECmx2/7C3P6BEaLK/vwkhveTV35CAYl4o d+Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:sender:dkim-signature; bh=zexaMXro/uaxLhK2Ywnxpp0MxR9oLew721YTh9TC4c0=; b=WRA2pg+v4HOFLIdRGRNsmsSfuBhPjxmsdnN1rve94ycadXqlUjCUqenUjzmo/DufBU 6hLRK3Jcsd5iZCUOJWTSTqzvIDMKA7fpF16fQKg6bx3WwjxklLgNAEyB0GmF61NnvZYq QoPEKGP/3vcdZaTCD2jXAdm+IWkUUWiQOA/O+cq1zz39sk0z3KVTZp02RlN8zk19b3wK Y6xlO9AhvOskkVZoAEEr3OWDThldi+A1OdiGTkJNBr0JAiDO2UnCzI8G7Cy04Aw2xnDC XeOWOTvzOpQv0svy1E9xK7LSwk+0eaYrQyIyOYM6iDbFIcsxkqtu29o/NBWgruwZtk15 zADw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=m+ofpum4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si2515185ejr.160.2021.02.10.15.14.29; Wed, 10 Feb 2021 15:14:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=m+ofpum4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234060AbhBJXJP (ORCPT + 99 others); Wed, 10 Feb 2021 18:09:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233852AbhBJXH6 (ORCPT ); Wed, 10 Feb 2021 18:07:58 -0500 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D6A1C0617A7 for ; Wed, 10 Feb 2021 15:06:46 -0800 (PST) Received: by mail-qt1-x84a.google.com with SMTP id f3so2829356qtx.18 for ; Wed, 10 Feb 2021 15:06:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=zexaMXro/uaxLhK2Ywnxpp0MxR9oLew721YTh9TC4c0=; b=m+ofpum45E0qQzUCK9BqF/eJF8IGA80dCP1QfNiACUXUp+xm2K/dUceYkdjHQUWUp/ rvu2UecmRFWufyqARJu6NPqBuXWXKrb+yyK3P9awLxiLd5zz5xRPa4B9kon5Sv8640+L Nacd9BMcN2NJOck1+bVJJdZ4FroMm2Eb/Jvc3RBFRrH934AaNCziP62PTOBfEaSwJgE0 LCoKOV67Ja+Vv0SThQnTclLLoCyNLzm3a65DNBeOwZJVFkLwGY/5n9R7n+qbJCX/uWvO t0DWMeaha2V5Up5a0+uLCQICoRhwyQAWpbcvM3OAVOLbx6bsacTkv7oViI/oMC3HIBLO nbDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=zexaMXro/uaxLhK2Ywnxpp0MxR9oLew721YTh9TC4c0=; b=Z6AyazzalGMYk4+5QSzgGno5eAdVpYX1QemwW5vNn189oHl5DH9xZB76qqy/4YIMGQ Po+dS/drG/5pOZOAJ+q3pKDfo2C8LVmd+4TUHSuGY8SDhx1mLJLqoeB/6+WPge90/z4+ oHl1QedW4lJYiR1icZxm0X9YDGnjyNIc7mmA3dcFBfDD2PJlvqkHFmT1j/LYx/FQTcUd JkPOinGoHijr596DlgL2GY5nbnvq74AGEOyRu8z5GZIoQAq6Uh9CIgLeLQsKzMuoUVHO QSGbz2ERdmywIM4JaaY1DKzbgGE2+8tkJtCeO3D32wqx2lVIdS1OiwelAvFD/xlwxvs+ ND9Q== X-Gm-Message-State: AOAM533AT1i+jIQOQuH84xtNz5T4pnenq+ATtPiKGG3S1YuM3EQC5SuR 9JJoH+jT84pSyRmn42qHyNxDJlOoMSo= Sender: "seanjc via sendgmr" X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:11fc:33d:bf1:4cb8]) (user=seanjc job=sendgmr) by 2002:a05:6214:125:: with SMTP id w5mr5212953qvs.20.1612998405853; Wed, 10 Feb 2021 15:06:45 -0800 (PST) Reply-To: Sean Christopherson Date: Wed, 10 Feb 2021 15:06:16 -0800 In-Reply-To: <20210210230625.550939-1-seanjc@google.com> Message-Id: <20210210230625.550939-7-seanjc@google.com> Mime-Version: 1.0 References: <20210210230625.550939-1-seanjc@google.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01-goog Subject: [PATCH 06/15] KVM: selftests: Use shorthand local var to access struct perf_tests_args From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Ben Gardon , Yanan Wang , Andrew Jones , Peter Xu , Aaron Lewis Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use 'pta' as a local pointer to the global perf_tests_args in order to shorten line lengths and make the code borderline readable. No functional change intended. Signed-off-by: Sean Christopherson --- .../selftests/kvm/lib/perf_test_util.c | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/selftests/kvm/lib/perf_test_util.c index f187b86f2e14..73b0fccc28b9 100644 --- a/tools/testing/selftests/kvm/lib/perf_test_util.c +++ b/tools/testing/selftests/kvm/lib/perf_test_util.c @@ -23,7 +23,8 @@ static uint64_t guest_test_virt_mem = DEFAULT_GUEST_TEST_MEM; */ static void guest_code(uint32_t vcpu_id) { - struct perf_test_vcpu_args *vcpu_args = &perf_test_args.vcpu_args[vcpu_id]; + struct perf_test_args *pta = &perf_test_args; + struct perf_test_vcpu_args *vcpu_args = &pta->vcpu_args[vcpu_id]; uint64_t gva; uint64_t pages; int i; @@ -36,9 +37,9 @@ static void guest_code(uint32_t vcpu_id) while (true) { for (i = 0; i < pages; i++) { - uint64_t addr = gva + (i * perf_test_args.guest_page_size); + uint64_t addr = gva + (i * pta->guest_page_size); - if (i % perf_test_args.wr_fract == 0) + if (i % pta->wr_fract == 0) *(uint64_t *)addr = 0x0123456789ABCDEF; else READ_ONCE(*(uint64_t *)addr); @@ -52,32 +53,32 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, uint64_t vcpu_memory_bytes, enum vm_mem_backing_src_type backing_src) { + struct perf_test_args *pta = &perf_test_args; struct kvm_vm *vm; uint64_t guest_num_pages; pr_info("Testing guest mode: %s\n", vm_guest_mode_string(mode)); - perf_test_args.host_page_size = getpagesize(); + pta->host_page_size = getpagesize(); /* * Snapshot the non-huge page size. This is used by the guest code to * access/dirty pages at the logging granularity. */ - perf_test_args.guest_page_size = vm_guest_mode_params[mode].page_size; + pta->guest_page_size = vm_guest_mode_params[mode].page_size; guest_num_pages = vm_adjust_num_guest_pages(mode, - (vcpus * vcpu_memory_bytes) / perf_test_args.guest_page_size); + (vcpus * vcpu_memory_bytes) / pta->guest_page_size); - TEST_ASSERT(vcpu_memory_bytes % perf_test_args.host_page_size == 0, + TEST_ASSERT(vcpu_memory_bytes % pta->host_page_size == 0, "Guest memory size is not host page size aligned."); - TEST_ASSERT(vcpu_memory_bytes % perf_test_args.guest_page_size == 0, + TEST_ASSERT(vcpu_memory_bytes % pta->guest_page_size == 0, "Guest memory size is not guest page size aligned."); vm = vm_create_with_vcpus(mode, vcpus, - (vcpus * vcpu_memory_bytes) / perf_test_args.guest_page_size, + (vcpus * vcpu_memory_bytes) / pta->guest_page_size, 0, guest_code, NULL); - - perf_test_args.vm = vm; + pta->vm = vm; /* * If there should be more memory in the guest test region than there @@ -90,8 +91,8 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, vcpu_memory_bytes); guest_test_phys_mem = (vm_get_max_gfn(vm) - guest_num_pages) * - perf_test_args.guest_page_size; - guest_test_phys_mem &= ~(perf_test_args.host_page_size - 1); + pta->guest_page_size; + guest_test_phys_mem &= ~(pta->host_page_size - 1); if (backing_src == VM_MEM_SRC_ANONYMOUS_THP || backing_src == VM_MEM_SRC_ANONYMOUS_HUGETLB) guest_test_phys_mem &= ~(KVM_UTIL_HUGEPAGE_ALIGNMENT - 1); @@ -125,30 +126,31 @@ void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus, uint64_t vcpu_memory_bytes, bool partition_vcpu_memory_access) { + struct perf_test_args *pta = &perf_test_args; vm_paddr_t vcpu_gpa; struct perf_test_vcpu_args *vcpu_args; int vcpu_id; for (vcpu_id = 0; vcpu_id < vcpus; vcpu_id++) { - vcpu_args = &perf_test_args.vcpu_args[vcpu_id]; + vcpu_args = &pta->vcpu_args[vcpu_id]; vcpu_args->vcpu_id = vcpu_id; if (partition_vcpu_memory_access) { vcpu_args->gva = guest_test_virt_mem + (vcpu_id * vcpu_memory_bytes); vcpu_args->pages = vcpu_memory_bytes / - perf_test_args.guest_page_size; + pta->guest_page_size; vcpu_gpa = guest_test_phys_mem + (vcpu_id * vcpu_memory_bytes); } else { vcpu_args->gva = guest_test_virt_mem; vcpu_args->pages = (vcpus * vcpu_memory_bytes) / - perf_test_args.guest_page_size; + pta->guest_page_size; vcpu_gpa = guest_test_phys_mem; } pr_debug("Added VCPU %d with test mem gpa [%lx, %lx)\n", vcpu_id, vcpu_gpa, vcpu_gpa + - (vcpu_args->pages * perf_test_args.guest_page_size)); + (vcpu_args->pages * pta->guest_page_size)); } } -- 2.30.0.478.g8a0d178c01-goog