From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8F82C433ED for ; Wed, 19 May 2021 20:03:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 955F961353 for ; Wed, 19 May 2021 20:03:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232709AbhESUFM (ORCPT ); Wed, 19 May 2021 16:05:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232519AbhESUFJ (ORCPT ); Wed, 19 May 2021 16:05:09 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65C33C06175F for ; Wed, 19 May 2021 13:03:48 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id a7-20020a5b00070000b02904ed415d9d84so19357295ybp.0 for ; Wed, 19 May 2021 13:03:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=TRzyq4oNy0xbwezI+8cBZnf/nTLSb+t8cRqYWcWY/Eg=; b=CxvtArSRKX6OIHDHNbloVqlUItuDs1pUVWO461kxImFFcH32VxsUk8wQRTWZwQ6azV xH9kIDgHSGkmKm3QMzYT8uD5SUun0xyFySIS+XdVS0A3rqkbCqR3aWZIGyOmeKCdjjEj ZC2H/hOoPa5G7ZMVYY0Ra3jjN+vFL3opMB+3VKbRuP9Um+YHZNcNdhuIUS/xWwqbJH+i jXPI/8k+0f6H7op/p+Aa0EWorl/GZObZys8KJJnM7xcqT6q9C+QoQGA3cOfd6VG2rF60 ETVQ91+uqYc3SF2jfC1c2q0N8ia/NuFB3pTg7Cf2b5wJCmdp2TJch+OuowdqLY9nCkD2 dOmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=TRzyq4oNy0xbwezI+8cBZnf/nTLSb+t8cRqYWcWY/Eg=; b=Qe7XRQBmb2m2KDpQPZQaUCO1m6g2sjhdX0H+PEZRo+6aQ3TvEa1A7Nrc7d+TIi/oVC 4Ka21AyLL4JEDGZzyOMCWCoAUj4VzVVwqcBj+fUjfotGJyDwCzprEZbE/xAPhQo7h5ZQ Ml8Ygm0d889Rng1q5VeMAOI7edUTlEc8WRD28azprl3R2qWUXzOVtIfMhQdRSdLSl1Tt fZnf5gu9M3a/2JynO3bGKdwlM+8jgSxa9Jz/CGgPyxSQVpxWqH4mysQ23dht2xlpF1w1 pApPtNa61l7B7vjzakTapJCZ6KUFlO4PDKXLyyTe/ZUyPOZxbNgTOnQAmRCQYGTyoW2U xEhQ== X-Gm-Message-State: AOAM532tWkoCqHbnQsZz9Xqhd8HPKC0vBzMacv/BJh+Jjmo5bdeyf+G1 tZ8K76b0dQEFnjcxo+Nu8pUe+r67EWICGR4/KBYK X-Google-Smtp-Source: ABdhPJyFo1HijtaGGGcxKGVnq1SWKSvHoMWpsxuc+TwmN6hh5Zag+cdBMzwAriowHUIKTHlRVkauQ7YZIi2LKSLHBpWj X-Received: from ajr0.svl.corp.google.com ([2620:15c:2cd:203:7eb5:10bb:834a:d5ec]) (user=axelrasmussen job=sendgmr) by 2002:a25:8205:: with SMTP id q5mr1802119ybk.170.1621454627516; Wed, 19 May 2021 13:03:47 -0700 (PDT) Date: Wed, 19 May 2021 13:03:29 -0700 Message-Id: <20210519200339.829146-1-axelrasmussen@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.1.751.gd2f1c929bd-goog Subject: [PATCH v2 00/10] KVM: selftests: exercise userfaultfd minor faults 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 Base ==== These patches are based upon Andrew Morton's v5.13-rc1-mmots-2021-05-13-17-23 tag. This is because this series depends on: - UFFD minor fault support for hugetlbfs (in v5.13-rc1) [1] - UFFD minor fault support for shmem (in Andrew's tree) [2] [1] https://lore.kernel.org/linux-fsdevel/20210301222728.176417-1-axelrasmussen@google.com/ [2] https://lore.kernel.org/patchwork/cover/1420967/ Changelog ========= v1->v2: - Picked up Reviewed-by's. - Change backing_src_is_shared() to check the flags, instead of the type. This makes it robust to adding new backing source types in the future. - Add another commit which refactors setup_demand_paging() error handling. - Print UFFD ioctl type once in setup_demand_paging, instead of on every page-in operation. - Expand comment on why we use MFD_HUGETLB instead of MAP_HUGETLB. - Reworded comment on addr_gpa2alias. - Moved demand_paging_test.c timing calls outside of the if (), deduplicating them. - Split trivial comment / logging fixups into a separate commit. - Add another commit which prints a clarifying message on test skip. - Split the commit allowing backing src_type to be modified in two. - Split the commit adding the shmem backing type in two. - Rebased onto v5.13-rc1-mmots-2021-05-13-17-23. Overview ======== Minor fault handling is a new userfaultfd feature whose goal is generally to improve performance. In particular, it is intended for use with demand paging. There are more details in the cover letters for this new feature (linked above), but at a high level the idea is that we think of these three phases of live migration of a VM: 1. Precopy, where we copy "some" pages from the source to the target, while the VM is still running on the source machine. 2. Blackout, where execution stops on the source, and begins on the target. 3. Postcopy, where the VM is running on the target, some pages are already up to date, and others are not (because they weren't copied, or were modified after being copied). During postcopy, the first time the guest touches memory, we intercept a minor fault. Userspace checks whether or not the page is already up to date. If needed, we copy the final version of the page from the soure machine. This could be done with RDMA for example, to do it truly in place / with no copying. At this point, all that's left is to setup PTEs for the guest: so we issue UFFDIO_CONTINUE. No copying or page allocation needed. Because of this use case, it's useful to exercise this as part of the demand paging test. It lets us ensure the use case works correctly end-to-end, and also gives us an in-tree way to profile the end-to-end flow for future performance improvements. Axel Rasmussen (10): KVM: selftests: trivial comment/logging fixes KVM: selftests: simplify setup_demand_paging error handling KVM: selftests: print a message when skipping KVM tests KVM: selftests: compute correct demand paging size KVM: selftests: allow different backing source types KVM: selftests: refactor vm_mem_backing_src_type flags KVM: selftests: add shmem backing source type KVM: selftests: create alias mappings when using shared memory KVM: selftests: allow using UFFD minor faults for demand paging KVM: selftests: add shared hugetlbfs backing source type .../selftests/kvm/demand_paging_test.c | 175 +++++++++++------- .../testing/selftests/kvm/include/kvm_util.h | 1 + .../testing/selftests/kvm/include/test_util.h | 12 ++ tools/testing/selftests/kvm/lib/kvm_util.c | 84 ++++++++- .../selftests/kvm/lib/kvm_util_internal.h | 2 + tools/testing/selftests/kvm/lib/test_util.c | 51 +++-- 6 files changed, 238 insertions(+), 87 deletions(-) -- 2.31.1.751.gd2f1c929bd-goog