Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp402141pxb; Tue, 9 Feb 2021 03:26:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOr81o24R/7G9rxBjbAOZmCSU+BGgLkg2dNrSwD3UC/gcAIAGbysUmw5tM/BONfbyLEvRu X-Received: by 2002:a50:cbc7:: with SMTP id l7mr16079527edi.134.1612870016254; Tue, 09 Feb 2021 03:26:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612870016; cv=none; d=google.com; s=arc-20160816; b=pk4j/dsjAaNBvAQVhbhQLmpO5YXOdyV6zRNd3Acnq5PTeqdi2GukH5pE3Q4dqwBDQR djftszyTYYNQ7OKLXwj58zAaoKL/78ZnuDDB5gSp0dK9+7u+DivUBwF88bv/8GgjzUYT YKiU4EM+6f01nkyiLbL+KhKsjCQFuI+LR74DHDbVk7KuAmXILJBl1JHh5ERb1fRJ/8Gf Ydl5rRjOPijfs0rhh7ERgB6FM3uAOiCqH4VLDxQ7juFnIW9RiEo5vawCm1XZ1krS32Bm PnyutS+bN5Oc+CNIJmxS6tCMw1kwnHSiHoz4ii77JhkbSXHPbmywIvudyEDhejOHVFxd zgQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=XtGq6ro+7d6sUXazosVig3qwawWXO4OzxY25A8VjMJA=; b=a7JPh2l6WNWU3mJxkFybIx5IvYbeHrVObzRQDbVmE3x6zbNSISqGYfLnxTANWF+YGg gSiGnkaHBW2w6uhnwd28Nv5HFGupYnnz1v5Uh6QAPZl0Ym8/3xQrHOKBovuEHpEezgxH h6Xip2SSKeQrWMsND+U00DaH3NhluNhsUcbPAFD5g2rf2QPYgUX0mL1uFfyA775+6Zbm SMrytrVstx9jfDP59Y8wnDbfKIjzY9mKDcttcVf0+0kGcpNWPLXnxvzjhZUXsOzr/NpC PoC+EXffeczxVheCSGO7L9ZHbdakkSH10l3pjFoSBKgxUKtPlDFu/5GGWIXOGBDbYZg1 UwIg== 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 y6si15038435edp.379.2021.02.09.03.26.33; Tue, 09 Feb 2021 03:26:56 -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 S229850AbhBILYn (ORCPT + 99 others); Tue, 9 Feb 2021 06:24:43 -0500 Received: from szxga01-in.huawei.com ([45.249.212.187]:2582 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbhBILWc (ORCPT ); Tue, 9 Feb 2021 06:22:32 -0500 Received: from dggeme764-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4DZgQY40tpzW2Zc; Tue, 9 Feb 2021 19:19:33 +0800 (CST) Received: from [10.174.187.128] (10.174.187.128) by dggeme764-chm.china.huawei.com (10.3.19.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2106.2; Tue, 9 Feb 2021 19:21:47 +0800 Subject: Re: [RFC PATCH 1/2] KVM: selftests: Add a macro to get string of vm_mem_backing_src_type To: Ben Gardon CC: kvm , , LKML , Paolo Bonzini , Shuah Khan , Andrew Jones , Marc Zyngier , Peter Xu , Sean Christopherson , Aaron Lewis , Vitaly Kuznetsov , , References: <20210208090841.333724-1-wangyanan55@huawei.com> <20210208090841.333724-2-wangyanan55@huawei.com> From: "wangyanan (Y)" Message-ID: Date: Tue, 9 Feb 2021 19:21:47 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.174.187.128] X-ClientProxiedBy: dggeme704-chm.china.huawei.com (10.1.199.100) To dggeme764-chm.china.huawei.com (10.3.19.110) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/2/9 2:13, Ben Gardon wrote: > On Mon, Feb 8, 2021 at 1:08 AM Yanan Wang wrote: >> 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. > Coincidentally, I sent out a change last week to do the same thing: > "KVM: selftests: Add backing src parameter to dirty_log_perf_test" > (https://lkml.org/lkml/2021/2/2/1430) > Whichever way this ends up being implemented, I'm happy to see others > interested in testing different backing source types too. Thanks Ben! I have a little question here. Can we just present three IDs (0/1/2) but not strings for users to choose which backing_src_type to use like the way of guest modes, which I think can make cmdlines more consise and easier to print. And is it better to make a universal API to get backing_src_strings like Sean have suggested, so that the API can be used elsewhere ? >> 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 >> > .