Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp1586657lkv; Wed, 19 May 2021 13:26:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9dhGYK+M3yUU1fMJl40IH93CnaUWCoyXiVV+TtSQFTsJuUGUT4ygdzzfWNvBqFei9VwI3 X-Received: by 2002:a05:6402:498:: with SMTP id k24mr932183edv.80.1621455965006; Wed, 19 May 2021 13:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621455965; cv=none; d=google.com; s=arc-20160816; b=tyqHBLF0QHFOr7iQtIBhKJvfMIpyCHmGAyZQwmfRJugemIjzGQfwi7ok9njHGpYh7S 8wEEHyBfri4pRkPfErd6UY14DnrJcR5caAomUFi1YI6Z9CNwceD10ku4bo5SKPQM4i6D 0qaRjswUB983JYIG9jd+LOcRmAUy1ckNWSCUAIZezDYlucf6wIK/wSj2FM84/pljSx+U UdGKOcD0hjgIoxgQB6el3KkdcfS0/MXsXgfZJaVsjvZEUw+R3yRB/BD+5ZYl7wYF8iSQ eQZWsbNZ3oj6B8cLOEpo8UrpzONx5ockYs9BVJKjFKZ3emQBs04+vpPBBdJ7H3Err36S UdJQ== 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:dkim-signature; bh=tlTQaP6r3uJCMYh9e3cNPNgqQCjX8re8AUT1/sJlsgs=; b=U+LGxv1TVjeVCuB08+Pmo3Ul+2Q1mR0zWTR9l6M7hK18hTPhvslQx27tGeM6k6Nsm4 emYEV/lV+1ZuxWFGKM6S1AFlKXx9SnCKx+w9C8yIgDXxRhvb2xWt/M3DRCRc60k93UA4 cUnHiiYVFhS1kV8WljKOToTwfdMuhmAcVZNWXHSm6tdL8xEi9KkySFj5FZIBhCfYCIZK J4daYaYPBtOMripR/RyK+VLM1tiKrRNsjbqQgWQs7AmOy4hsB035ipidFRf3qwCqPtD3 X/GfcXaY6Qkwf+diYzGoc6rT0DcOLSx0w44YXYAZABePry3cP1KRCz0xboaPw1zKObXe Y7PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rFmQtjZe; 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 t16si246691edi.299.2021.05.19.13.25.41; Wed, 19 May 2021 13:26:04 -0700 (PDT) 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=rFmQtjZe; 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 S232700AbhESUFa (ORCPT + 99 others); Wed, 19 May 2021 16:05:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232808AbhESUFU (ORCPT ); Wed, 19 May 2021 16:05:20 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26E1DC061342 for ; Wed, 19 May 2021 13:03:59 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id s8-20020a5b04480000b029049fb35700b9so19658339ybp.5 for ; Wed, 19 May 2021 13:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=tlTQaP6r3uJCMYh9e3cNPNgqQCjX8re8AUT1/sJlsgs=; b=rFmQtjZe9RYFX+tPbUuHk7Z7fNZNixYSjXLsfPRlf0/fGpNcZdJATEmw0/FPJOfPoJ n3b204YrvYZ4PnW6zaZoAgOPvN1EhcUvDlYhNyIKE/9E/t+R79kOa/sKhal2uZP0F1+2 a/77hmjaqxFjcsIWHfWrzCq9fZeZU4jkms28fr7Y9pSntDHcIhq8Dp4mWHPP/3a1WWS8 0E4CCqTStU29JAvUfVddAGuj2uc9eM0bs1zXRBO4iK0F4fh/mgsOVl7v+hmKc1i9KrXt jKeIqsCA3M+3G8+PDzPav2K4bx4BWZ295RawYQUPAkksDIoMtzWjnATt9p/mLTnWGHej TiCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=tlTQaP6r3uJCMYh9e3cNPNgqQCjX8re8AUT1/sJlsgs=; b=mBVeclFX7Qr/XnqBlMaG/QXFQSFAPQFTLi+hbCDZW7zDVIA4iLRyFJnP62olXdpkPl DE0e0T9wucMU/YyKhOELnziPFca5vXtItgpvvqpbLAXtzDyTpju0utCXTnUfYjEJ4ZFO ZhKvvMe+ZvKG4D2Zbwk1dqrPEah/6eqkabo1zrjlFZkURMIYmfydvOLbrzKX82iHXJvE DD3Bc2Vbl6ZwVL0pVNOmeL3J2rduEZI2Z7lX9Tipa1ejy0D9EzaWF1jGNDhnprH3hGHu 16u3uS65UjOTdxdW5TKMxInZKbfpN0TIRhGm1MQyiUO9VWkMn6ZNebF2aJs4MzGklJ/i 4thg== X-Gm-Message-State: AOAM532gtrrvi20L77a3vE0RR9sASAW94imj/OurxKlopSupb+Zue8kq svPgDIUoz+nQKD5StTG4YTMlXYOtvm8RQ6F0FTej X-Received: from ajr0.svl.corp.google.com ([2620:15c:2cd:203:7eb5:10bb:834a:d5ec]) (user=axelrasmussen job=sendgmr) by 2002:a25:86c1:: with SMTP id y1mr1922580ybm.82.1621454638208; Wed, 19 May 2021 13:03:58 -0700 (PDT) Date: Wed, 19 May 2021 13:03:34 -0700 In-Reply-To: <20210519200339.829146-1-axelrasmussen@google.com> Message-Id: <20210519200339.829146-6-axelrasmussen@google.com> Mime-Version: 1.0 References: <20210519200339.829146-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.31.1.751.gd2f1c929bd-goog Subject: [PATCH v2 05/10] KVM: selftests: allow different backing source types From: Axel Rasmussen To: Aaron Lewis , Alexander Graf , Andrew Jones , Andrew Morton , Ben Gardon , Emanuele Giuseppe Esposito , Eric Auger , Jacob Xu , Makarand Sonare , Oliver Upton , Paolo Bonzini , Peter Xu , Shuah Khan , Yanan Wang Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Axel Rasmussen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add an argument which lets us specify a different backing memory type for the test. The default is just to use anonymous, matching existing behavior. This is in preparation for testing UFFD minor faults. For that, we'll need to use a new backing memory type which is setup with MAP_SHARED. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/kvm/demand_paging_test.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/kvm/demand_paging_test.c b/tools/testing/selftests/kvm/demand_paging_test.c index 94cf047358d5..01890a7b0155 100644 --- a/tools/testing/selftests/kvm/demand_paging_test.c +++ b/tools/testing/selftests/kvm/demand_paging_test.c @@ -241,6 +241,7 @@ static void setup_demand_paging(struct kvm_vm *vm, struct test_params { bool use_uffd; useconds_t uffd_delay; + enum vm_mem_backing_src_type src_type; bool partition_vcpu_memory_access; }; @@ -258,11 +259,11 @@ static void run_test(enum vm_guest_mode mode, void *arg) int r; vm = perf_test_create_vm(mode, nr_vcpus, guest_percpu_mem_size, - VM_MEM_SRC_ANONYMOUS); + p->src_type); perf_test_args.wr_fract = 1; - demand_paging_size = get_backing_src_pagesz(VM_MEM_SRC_ANONYMOUS); + demand_paging_size = get_backing_src_pagesz(p->src_type); guest_data_prototype = malloc(demand_paging_size); TEST_ASSERT(guest_data_prototype, @@ -378,7 +379,7 @@ static void help(char *name) { puts(""); printf("usage: %s [-h] [-m mode] [-u] [-d uffd_delay_usec]\n" - " [-b memory] [-v vcpus] [-o]\n", name); + " [-b memory] [-t type] [-v vcpus] [-o]\n", name); guest_modes_help(); printf(" -u: use User Fault FD to handle vCPU page\n" " faults.\n"); @@ -388,6 +389,8 @@ static void help(char *name) printf(" -b: specify the size of the memory region which should be\n" " demand paged by each vCPU. e.g. 10M or 3G.\n" " Default: 1G\n"); + printf(" -t: The type of backing memory to use. Default: anonymous\n"); + backing_src_help(); printf(" -v: specify the number of vCPUs to run.\n"); printf(" -o: Overlap guest memory accesses instead of partitioning\n" " them into a separate region of memory for each vCPU.\n"); @@ -399,13 +402,14 @@ int main(int argc, char *argv[]) { int max_vcpus = kvm_check_cap(KVM_CAP_MAX_VCPUS); struct test_params p = { + .src_type = VM_MEM_SRC_ANONYMOUS, .partition_vcpu_memory_access = true, }; int opt; guest_modes_append_default(); - while ((opt = getopt(argc, argv, "hm:ud:b:v:o")) != -1) { + while ((opt = getopt(argc, argv, "hm:ud:b:t:v:o")) != -1) { switch (opt) { case 'm': guest_modes_cmdline(optarg); @@ -420,6 +424,9 @@ int main(int argc, char *argv[]) case 'b': guest_percpu_mem_size = parse_size(optarg); break; + case 't': + p.src_type = parse_backing_src_type(optarg); + break; case 'v': nr_vcpus = atoi(optarg); TEST_ASSERT(nr_vcpus > 0 && nr_vcpus <= max_vcpus, -- 2.31.1.751.gd2f1c929bd-goog