From patchwork Wed May 12 21:44:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 12254885 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 C5643C4363F for ; Wed, 12 May 2021 23:10:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E9FB6142C for ; Wed, 12 May 2021 23:10:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239984AbhELXBX (ORCPT ); Wed, 12 May 2021 19:01:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1388284AbhELVtQ (ORCPT ); Wed, 12 May 2021 17:49:16 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54849C06124B for ; Wed, 12 May 2021 14:45:06 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id g17-20020a056a0023d1b029028f419cb9a2so15621094pfc.4 for ; Wed, 12 May 2021 14:45:06 -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=5jUpkIWfMaq5Jmoaunq8eRpC3Xi5xzv1ZG/MFZDMBzk=; b=WGvG1+DLOaYsWwslzcFaBddiYRxp0XLqVYB2uArPgDzBleiI+uU3cDpZD1xK69YsJ1 VY7xsOG//Dm7VOkj9PySP6eJvXdk66vQgdIaBXmFdzqhqDRnRDJ4ZteE1Q5Jkioj0Eyy Z4+DzQ36g5xqcpcc6bJb4Dwzj6ERvA9KCFrl6ETG1oxasRhdbscS7A3TMKEjJQxObA7L k0esfRk4vbESKv1UUlqYB8b4fRIuJFTme0t/PZ27GsZJZU4umFYYr53CGFaI9ZhkaS07 CwZpz4xwZD3+xTAgBF7COPrLiUOF/gBc2jcwD3zczjVHVubH6LLTCDntZF3i6NRIe95G zGug== 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=5jUpkIWfMaq5Jmoaunq8eRpC3Xi5xzv1ZG/MFZDMBzk=; b=iC7UFL2FHXiBZ0iwZ97K8fGcz19gZMny2d3xom3xLOV+d6jZtqr43SAJ4666dQM9ZV G8LCg1VsC4ySq0lsmOjdFK7/ziHFY/F1TPaPSyQayEg3QiTXuJCaUSPf25rOHOpxkSnB PPfDfsLczEr/18AoDOgriYpqvF2jUL/4u9SqKYWxXzFGn1t7p+Q1rb/HoTpLGdIlYu7o b4SKV+5XvoTkVnqZp1I4xDyKpAbPoFIAbFe2F2cA9qezOg5qhs7XElmPJYrpYb6NE9at xufOMqnUW3Ws4CIZ4Ka6vN9r6RtAY8L9yP3lBAmHyTu2jJjxtRvCPZ+vbOkZwU9n2Pmu YQcA== X-Gm-Message-State: AOAM531N8JF2jHtq60VLAFz8jhdhny09Cg9nO3fk05u9PIVCDEDknBub JDqqflZaYlA7/1RjgJeeaMgwq7pVmKa4RGWR1axS X-Google-Smtp-Source: ABdhPJznlwzFf+8b63G8BSVyi6fcbSnTpML8PUgB8sdorKJKvZseAtm8CUY4Wm7UAnSfjya00Qx++cbvuCwwU2jBGzQo X-Received: from ajr0.svl.corp.google.com ([2620:15c:2cd:203:29e5:10fc:1128:b0c0]) (user=axelrasmussen job=sendgmr) by 2002:a17:902:7488:b029:ef:838a:3071 with SMTP id h8-20020a1709027488b02900ef838a3071mr4687161pll.61.1620855905759; Wed, 12 May 2021 14:45:05 -0700 (PDT) Date: Wed, 12 May 2021 14:44:57 -0700 Message-Id: <20210512214502.2047008-1-axelrasmussen@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.1.607.g51e8a6a459-goog Subject: [PATCH 0/5] 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 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Base ==== These patches are based upon Andrew Morton's v5.13-rc1-mmots-2021-05-10-22-15 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/ 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 (5): KVM: selftests: allow different backing memory types for demand paging 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 | 146 +++++++++++++----- .../testing/selftests/kvm/include/kvm_util.h | 1 + .../testing/selftests/kvm/include/test_util.h | 11 ++ tools/testing/selftests/kvm/lib/kvm_util.c | 79 +++++++++- .../selftests/kvm/lib/kvm_util_internal.h | 2 + tools/testing/selftests/kvm/lib/test_util.c | 46 ++++-- 6 files changed, 222 insertions(+), 63 deletions(-) --- 2.31.1.607.g51e8a6a459-goog