Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3849283pxb; Mon, 8 Feb 2021 01:29:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTdUNzhE+SeXtz1tkPAEQsjFfbXzKFLAcCtDA6JcjQcZjT1262mv5DJMINqFWW9b2d4tB/ X-Received: by 2002:a05:6402:c9:: with SMTP id i9mr16063481edu.123.1612776569382; Mon, 08 Feb 2021 01:29:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612776569; cv=none; d=google.com; s=arc-20160816; b=XplGUQhqQzO4+2+gvX+v7FjP5g8XQm4q8NUPKmqrF/xfpd8S6pPmDSBbqsZo66+LWS sranWwZFuY6XNjngNYnx0Ox2hQgQZ6PtK/rFSqTgxtPHhyMCTGOBBHDOyMQc38Zmeeoy Yt6tCBq+UST/ViU6YIvl2ThbFF/eWt5CAD4tXHpISKREV5UT3UtjKqPzf7F0ula702oM vStgcglmOD6OOH8dZMHzbyn3wf1YAvaBxFn0WBpBIwj/ZuHxOEILd8pcGkP2S8072JM+ 2+liTDdkqR8MG72hXiRCF6MBjU1W1RxTST9KQTDnp7F7jctsU/RPuskGgzx8UIdbLXKY +nAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=AHkZ1eZvEHXUoPXI5e117OiqRkwz1bORk2Q3fUhv5P0=; b=yeVRGpinJMlV+a56g7T94FIuISo/Pbvue1rwZA+5bWIacEEvIWiP2lMJuZCGK6CXdA pZNUi64Bs9UYu6oiYEZUNN5RurY748Nr4GVIVGMTzXTcy1+rA3Z+CpeHYxogo5gZD5v8 n1SOY8znc7HZkiO3gCzgn8Hhwrb5z7u+Gog9+iIMYkH061LFEVrn1U9kTDmTr9r63MAZ FQjFJGmxw2xwXgz7UGXFgRN4E/M7pPDDYLYYP3QpU7M2OJI03MaLxSUQbmGc8JYi/Z4D HBDkgGDkyw0eLSbrPmipEoaOEyQMtVmtTbLCfxPErXySL7iDaXOVeKCXnkOiwUzBsIvq NnsQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h12si11399727eds.288.2021.02.08.01.29.05; Mon, 08 Feb 2021 01:29:29 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231683AbhBHJ2K (ORCPT + 99 others); Mon, 8 Feb 2021 04:28:10 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:12488 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230484AbhBHJJu (ORCPT ); Mon, 8 Feb 2021 04:09:50 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DZ0Xf2sm8zjL4s; Mon, 8 Feb 2021 17:07:30 +0800 (CST) Received: from DESKTOP-TMVL5KK.china.huawei.com (10.174.187.128) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Mon, 8 Feb 2021 17:08:45 +0800 From: Yanan Wang To: , , CC: Paolo Bonzini , Shuah Khan , "Andrew Jones" , Marc Zyngier , Ben Gardon , Peter Xu , Sean Christopherson , Aaron Lewis , Vitaly Kuznetsov , , , Yanan Wang Subject: [RFC PATCH 1/2] KVM: selftests: Add a macro to get string of vm_mem_backing_src_type Date: Mon, 8 Feb 2021 17:08:40 +0800 Message-ID: <20210208090841.333724-2-wangyanan55@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20210208090841.333724-1-wangyanan55@huawei.com> References: <20210208090841.333724-1-wangyanan55@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.187.128] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a macro to get string of the backing source memory type, so that application can add choices for source types in the help() function, and users can specify which type to use for testing. Signed-off-by: Yanan Wang --- tools/testing/selftests/kvm/include/kvm_util.h | 3 +++ tools/testing/selftests/kvm/lib/kvm_util.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h index 5cbb861525ed..f5fc29dc9ee6 100644 --- a/tools/testing/selftests/kvm/include/kvm_util.h +++ b/tools/testing/selftests/kvm/include/kvm_util.h @@ -69,7 +69,9 @@ enum vm_guest_mode { #define PTES_PER_MIN_PAGE ptes_per_page(MIN_PAGE_SIZE) #define vm_guest_mode_string(m) vm_guest_mode_string[m] +#define vm_mem_backing_src_type_string(s) vm_mem_backing_src_type_string[s] extern const char * const vm_guest_mode_string[]; +extern const char * const vm_mem_backing_src_type_string[]; struct vm_guest_mode_params { unsigned int pa_bits; @@ -83,6 +85,7 @@ enum vm_mem_backing_src_type { VM_MEM_SRC_ANONYMOUS, VM_MEM_SRC_ANONYMOUS_THP, VM_MEM_SRC_ANONYMOUS_HUGETLB, + NUM_VM_BACKING_SRC_TYPES, }; int kvm_check_cap(long cap); diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index fa5a90e6c6f0..a9b651c7f866 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -165,6 +165,14 @@ const struct vm_guest_mode_params vm_guest_mode_params[] = { _Static_assert(sizeof(vm_guest_mode_params)/sizeof(struct vm_guest_mode_params) == NUM_VM_MODES, "Missing new mode params?"); +const char * const vm_mem_backing_src_type_string[] = { + "VM_MEM_SRC_ANONYMOUS ", + "VM_MEM_SRC_ANONYMOUS_THP ", + "VM_MEM_SRC_ANONYMOUS_HUGETLB", +}; +_Static_assert(sizeof(vm_mem_backing_src_type_string)/sizeof(char *) == NUM_VM_BACKING_SRC_TYPES, + "Missing new source type strings?"); + /* * VM Create * -- 2.23.0