Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp665212iog; Fri, 24 Jun 2022 11:15:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uEgbfQFa4B/qfPc9q91sPnZbSrpjbX54Ijm3aa9bTGqWRF6g6YegxWnBXMMXnqwRdAXeqt X-Received: by 2002:a17:903:10c:b0:16a:1166:4ee9 with SMTP id y12-20020a170903010c00b0016a11664ee9mr331286plc.138.1656094509920; Fri, 24 Jun 2022 11:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656094509; cv=none; d=google.com; s=arc-20160816; b=UKza0qcx2I55Ycez+AwEtQljb8mJOXIoTOfQxhLWVsIAQChHx0XW6m+A1ofZbzg4s3 Yp5ZS4V0Uoi4GruHWvCdftyTzGWYQrjPIqocNBUlXBMG+OJKUHHEPbKc389b6RBP6rqQ KaDXPalFXw5Le5oNGfxoDTWai1MuFOiZdZsYXhPoMS1pzzfFi5N0hbVRUIpMMa9J9hI3 F+hfpFhk8LtdPo+2FeSe0K2EWq2IsgJstOcZq70YKf+/w6PP9QeE25+Dy+xAOj4P2Utx qzOtJXFKW9Ng/aO47I/veGhQ3K5ljEvnxQocSsaAFuDVk1ZQ/AIx/z2quT2xvuMdoqE9 vLkg== 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=u+0c8IGQItY5NCCATolNVsWOPdUIr5MDdbCK/q0TIvo=; b=1JTPCN0TCPyGIDemozzydrp/cv/6aMetCW8M/uPNc2SUk1NI5KFAW6x8mXX//mbha+ 60R9CUxiitIY9EbUpuVtT91CftjAERFjAT0iFwz7p6S8/fiMT54VUjHt+0OT88kuS2LE yIlZN70YgQs78j7hP7j9v+anFN4MtwcVKPy6GQehhV13Rq9voG9VV08AgRic//+94IeN XwAYw6QPVC0iCYvS9sJtOyWL7Rf9E7EuStmPiXuc6sr4PvCkxrufbMaipVmdkPkR1dgM EEccqx1AhWmrRW6xHlkB4CH8mfkDX3lYl7aBoesYHE0i/YnIJi96ZE7qsMW+aQkA7Bvk VI8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=D90ixVsl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f12-20020a056a0022cc00b005257ae10bb3si2069605pfj.348.2022.06.24.11.14.56; Fri, 24 Jun 2022 11:15:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=D90ixVsl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232467AbiFXRjZ (ORCPT + 99 others); Fri, 24 Jun 2022 13:39:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232304AbiFXRiC (ORCPT ); Fri, 24 Jun 2022 13:38:02 -0400 Received: from mail-ua1-x94a.google.com (mail-ua1-x94a.google.com [IPv6:2607:f8b0:4864:20::94a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD5E96F4BB for ; Fri, 24 Jun 2022 10:37:46 -0700 (PDT) Received: by mail-ua1-x94a.google.com with SMTP id g1-20020ab00e01000000b00379820aee7cso1007801uak.18 for ; Fri, 24 Jun 2022 10:37:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=u+0c8IGQItY5NCCATolNVsWOPdUIr5MDdbCK/q0TIvo=; b=D90ixVslphWwRS1UyK82N/Fu4Pbp7RfYXJAXQqDLm0AYhlK59/wd1jqEmTakmfoAdM bCaJEmUAqS6tCX2dak5OsRfQg3/S32jkFNOOv5AhzS6KIq2Y8/bxRLDG5Ynhh7Q4ZWRf T28FEgQTuQAmTAzbinSDCUL5FqalKu06/tPW5zgoGnZaHOERoYdGxV1amlIWNDhV6gNx Hux7xxh8o8EA2S1TUMwn3Pd1RB6gqb3P03MxNrYVTbnyXFz2pdn7Ecfkw2C38+x5Tq4t 6G6ZSXt7n/jc3VeCFkh0qVe2rMcVgaPEC639yccX83zFJnO8qJjsZQZj8m3ROTU/7Otn uqtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=u+0c8IGQItY5NCCATolNVsWOPdUIr5MDdbCK/q0TIvo=; b=x85XUDyONTdTiIquoeP4ANjI8LvZpTxHNSFFghfBWCZ36HTIVF+TSUZk8iPUKb5iqs SVEW9ic4LPbROTj1lYbKBJTOZyspEeOvjwFcRS0eKINI1dHEdSqrgesD5P9OJf1J3fXO 8glJh3xhDpXZqdCW8i5UV8sx6IPq2TFA9foRuTOSNWW/IX85VNeK0Hmx+RUZHMLgF5HL VEBQSzOYxqrhSj5veRk0bQSkgxM8+DITfcPl7/J+b9WyClZUddV+IXbU+CvVEPmUsPf2 9oMpBQHK9065AQc6i6nC9SxveSnJ8BDRfFBZIjMScPRQPBD9k7DY0wSLEZh27d7hN4nT xoDA== X-Gm-Message-State: AJIora9w5RWF9H+KIX/y7YcwgaQgld55rJovXMWQPpksKTPbvf75KWZC VvxtPt4Rn8esYMTzvnHsQrLtJ8w/qQP7lOfs X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a05:6122:1990:b0:36b:f70c:ba55 with SMTP id bv16-20020a056122199000b0036bf70cba55mr26413vkb.12.1656092265972; Fri, 24 Jun 2022 10:37:45 -0700 (PDT) Date: Fri, 24 Jun 2022 17:36:56 +0000 In-Reply-To: <20220624173656.2033256-1-jthoughton@google.com> Message-Id: <20220624173656.2033256-27-jthoughton@google.com> Mime-Version: 1.0 References: <20220624173656.2033256-1-jthoughton@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [RFC PATCH 26/26] selftests: add HugeTLB HGM to KVM demand paging selftest From: James Houghton To: Mike Kravetz , Muchun Song , Peter Xu Cc: David Hildenbrand , David Rientjes , Axel Rasmussen , Mina Almasry , Jue Wang , Manish Mishra , "Dr . David Alan Gilbert" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This doesn't address collapsing yet, and it only works with the MINOR mode (UFFDIO_CONTINUE). Signed-off-by: James Houghton --- tools/testing/selftests/kvm/include/test_util.h | 2 ++ tools/testing/selftests/kvm/lib/kvm_util.c | 2 +- tools/testing/selftests/kvm/lib/test_util.c | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h index 99e0dcdc923f..6209e44981a7 100644 --- a/tools/testing/selftests/kvm/include/test_util.h +++ b/tools/testing/selftests/kvm/include/test_util.h @@ -87,6 +87,7 @@ enum vm_mem_backing_src_type { VM_MEM_SRC_ANONYMOUS_HUGETLB_16GB, VM_MEM_SRC_SHMEM, VM_MEM_SRC_SHARED_HUGETLB, + VM_MEM_SRC_SHARED_HUGETLB_HGM, NUM_SRC_TYPES, }; @@ -105,6 +106,7 @@ size_t get_def_hugetlb_pagesz(void); const struct vm_mem_backing_src_alias *vm_mem_backing_src_alias(uint32_t i); size_t get_backing_src_pagesz(uint32_t i); bool is_backing_src_hugetlb(uint32_t i); +bool is_backing_src_shared_hugetlb(enum vm_mem_backing_src_type src_type); void backing_src_help(const char *flag); enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name); long get_run_delay(void); diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 1665a220abcb..382f8fb75b7f 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -993,7 +993,7 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm, region->fd = -1; if (backing_src_is_shared(src_type)) region->fd = kvm_memfd_alloc(region->mmap_size, - src_type == VM_MEM_SRC_SHARED_HUGETLB); + is_backing_src_shared_hugetlb(src_type)); region->mmap_start = mmap(NULL, region->mmap_size, PROT_READ | PROT_WRITE, diff --git a/tools/testing/selftests/kvm/lib/test_util.c b/tools/testing/selftests/kvm/lib/test_util.c index 6d23878bbfe1..710dc42077fe 100644 --- a/tools/testing/selftests/kvm/lib/test_util.c +++ b/tools/testing/selftests/kvm/lib/test_util.c @@ -254,6 +254,13 @@ const struct vm_mem_backing_src_alias *vm_mem_backing_src_alias(uint32_t i) */ .flag = MAP_SHARED, }, + [VM_MEM_SRC_SHARED_HUGETLB_HGM] = { + /* + * Identical to shared_hugetlb except for the name. + */ + .name = "shared_hugetlb_hgm", + .flag = MAP_SHARED, + }, }; _Static_assert(ARRAY_SIZE(aliases) == NUM_SRC_TYPES, "Missing new backing src types?"); @@ -272,6 +279,7 @@ size_t get_backing_src_pagesz(uint32_t i) switch (i) { case VM_MEM_SRC_ANONYMOUS: case VM_MEM_SRC_SHMEM: + case VM_MEM_SRC_SHARED_HUGETLB_HGM: return getpagesize(); case VM_MEM_SRC_ANONYMOUS_THP: return get_trans_hugepagesz(); @@ -288,6 +296,12 @@ bool is_backing_src_hugetlb(uint32_t i) return !!(vm_mem_backing_src_alias(i)->flag & MAP_HUGETLB); } +bool is_backing_src_shared_hugetlb(enum vm_mem_backing_src_type src_type) +{ + return src_type == VM_MEM_SRC_SHARED_HUGETLB || + src_type == VM_MEM_SRC_SHARED_HUGETLB_HGM; +} + static void print_available_backing_src_types(const char *prefix) { int i; -- 2.37.0.rc0.161.g10f37bed90-goog