Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp663756pxb; Tue, 9 Feb 2021 09:21:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpzxGrzwigHLawt6ZgZPbRKUR1CwI65wpfgqkhtjKA1ONhzqyVU5gQgdfInkDeS6gGeYRA X-Received: by 2002:a05:6402:4242:: with SMTP id g2mr24359515edb.103.1612891294897; Tue, 09 Feb 2021 09:21:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612891294; cv=none; d=google.com; s=arc-20160816; b=tQpH5tz6urJYA1WS0MWDZcJsKDLy1s0mlVy51Zab4mOXtXmwZBRrSlOYK9ynAXTCv1 GzTmkxlEffo10E18+B7+2kG4qFIrgO3LUXo9pm5PNnIrsDleAI+u5lihm0t27zzBLIF7 vbhxPgCa10wipRUy2k1nfjq3o+SxaaBWKVsOxJU7Rpq7EPoEuCIE8jXMRGfSlovOc51R 7h77M3/QfGwZiQBEUyeKAq/znymoxm7VJYUOJqJ8AYkFkXvxaK3wU5Y8OCicRmrSvKX+ 4X698Q6Ky059sjos59xS3e0hpzI8QoywgmpjeIM/iw76SGLAXePO0H1lSKiSe50GJjc5 lDPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=lUtnzAW46dlZiTOiwqO9uCdRWksCkXtHA4sUKlf1iCA=; b=M3Crs5ZHLs+nHwDQ7THJCDtbREURGoi9PlUs9RCDR65jJQSWtuwdrz6eqBDkmc09fW kjpoM8YWnGI4UU3kq0EHB/9E12h49UCICHCIDYygRZrmjzto6sUzp/Fb5ehYVE/2umPu dkLnMVJFfvb/wU5ujSE9QZINTIRA+VZn/9EaGF0+hg6A1eK8Uw/xoAqDSZ9u8oz0yg55 uc7qUHMOcEnDhLDWJf5+DWo0HGIi+HqUU1GIiSz8B/qSen/Oorh5DE7OIOMygMq/dQWY NAdKYMWcNP8t0rajGGqoc/FPLIBKWIL6yYBVO2oYqpjy1Eb4cykErY0MN5+JIKz7ePaK 2Tjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mPGpo9Tq; 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 d4si14603246edo.136.2021.02.09.09.20.59; Tue, 09 Feb 2021 09:21:34 -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=mPGpo9Tq; 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 S233018AbhBIRT0 (ORCPT + 99 others); Tue, 9 Feb 2021 12:19:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232909AbhBIRTY (ORCPT ); Tue, 9 Feb 2021 12:19:24 -0500 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86725C061574 for ; Tue, 9 Feb 2021 09:18:44 -0800 (PST) Received: by mail-io1-xd32.google.com with SMTP id n14so19597184iog.3 for ; Tue, 09 Feb 2021 09:18:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lUtnzAW46dlZiTOiwqO9uCdRWksCkXtHA4sUKlf1iCA=; b=mPGpo9TqUVCxuvsIWZXrYrqbXhuqiZq4/bgvFH8ETfoC2cwS70d9kNXKaa/2ycZ8Le uGL/hKxZtc6ngGicBNMeisLGHgorEunI3Vjzy3q8yFjX3LGq+595QxFtPFoqqE+6Q50+ v6NQApSLIfutLGyuvNhgDhcX8dJUIuVmGBTCnhABsgfj3ezGTVmwE7U4BBCmhEsIBd1j 2rDoNUGKb2DDJ7VQ9Ve4rBhO+ucSyHWN04kGaQUYkFWHJNDzbedAZDmJfz8gKFd1q5Xt ymQY579V9yr3YpEHKROPs/8D5XBXvAz9ksqH71y8prOYXRi/qMzDNM0792csQnSYnq0T EmJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lUtnzAW46dlZiTOiwqO9uCdRWksCkXtHA4sUKlf1iCA=; b=RqVLF1KcMVxL2KJc+EEETD0sCG0z5CCkxEptYDs3EMIhXk82bg2jPS5u/6NtGKo3YC YBcOWkcZNU84Hf3vAN9464MO1sk28IkK1khTaPzOrxA+oQVZlwexOvLmAzgMTFmLOijy 8MoPEsfP0qLJjLjgJw8px5CwZhrkhtQlXyR7DAJ+WX+V0ltZx4ElyrpBhmzotvbXLvjr hmgQSiNV9O/NcopEAmR24e/8NXlMD/Pe8wbF06KdmDtPx1xrz3cT2xcdRguhkgOQZ3jW qezci7Ac3j9TnGcbwbF4qyk784IJjgPNxKVkX30zrC7e7JhUBxxVVmQJCOpnWcxMBcek OuNA== X-Gm-Message-State: AOAM530+H7xa6Fml92es/9Ws3yPAmpH9rQOoR4w8irVTrKq/6c8XouGd 0gaY9/LyvgQRm0/1xfIjVqB7Az0fN3qShRFnjb3Chg== X-Received: by 2002:a05:6602:2e8c:: with SMTP id m12mr20049870iow.19.1612891123762; Tue, 09 Feb 2021 09:18:43 -0800 (PST) MIME-Version: 1.0 References: <20210208090841.333724-1-wangyanan55@huawei.com> <20210208090841.333724-2-wangyanan55@huawei.com> In-Reply-To: From: Ben Gardon Date: Tue, 9 Feb 2021 09:18:32 -0800 Message-ID: Subject: Re: [RFC PATCH 1/2] KVM: selftests: Add a macro to get string of vm_mem_backing_src_type To: "wangyanan (Y)" Cc: kvm , linux-kselftest@vger.kernel.org, LKML , Paolo Bonzini , Shuah Khan , Andrew Jones , Marc Zyngier , Peter Xu , Sean Christopherson , Aaron Lewis , Vitaly Kuznetsov , wanghaibin.wang@huawei.com, yuzenghui@huawei.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 9, 2021 at 3:21 AM wangyanan (Y) wrote: > > > 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, That would be fine with me. The string names are easier for me to read than an ID number (especially if you were to add additional options e.g. 1G hugetlb or file backed / shared memory) but it's mostly an aesthetic preference, so I don't have strong feelings either way. > > 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 ? Definitely. This should be as easy as possible to incorporate into all selftests. > > >> 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 > >> > > .