Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp1585663lkv; Wed, 19 May 2021 13:24:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI4iZc6Hhx+Zrj/uLxzgvorI2mHCOFLyHQpxqUshFF7lcj93xBasx1EHHhImxltM1T/26I X-Received: by 2002:a92:d306:: with SMTP id x6mr1092059ila.88.1621455873453; Wed, 19 May 2021 13:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621455873; cv=none; d=google.com; s=arc-20160816; b=VrmYqHVZ2kTRbu8o1Of0rnr5pOZ/O4R+gWEVMu1fwndPVbwR39NZq+Z3YppHMsCp5c VuvYlx096P6Uvq0kjLpTazmLeLbE1WJ68/wuiAoKzSqMAvGSMyp8AfqLo8GlZqC/cWOm Afxjbjutpk1BuE/Xs5dhLl3yYVRLaaxbHWMlnvmADgwDdAWKnzIMpaApJhCrZdmSNLqV LG5TskbmNzpaN26n2xuVDFVFDaigBF0BLsGd98dicxj2kqFq392/7VXlwIbuqNsq4EmF PilnYqEuYEx66OeyR9qfYK7+FkvVRbE9d+lfazQ3XKNgJPBop/8H1hNS7C3xODg+6AWL 4X2A== 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:mime-version:message-id:date :dkim-signature; bh=TRzyq4oNy0xbwezI+8cBZnf/nTLSb+t8cRqYWcWY/Eg=; b=E8ffy5IF0r2NS1DAtjnZ/0Mab0DJskWkL/lKibr9YKBXJnywZew6Y7xDedIkejmDuv Yej/mlhIHzKRC2j1xjxaBIP1bEuhldAKXLfnyYdMTU6v/xJtHMWPOecs4vST+TY+M4jj OPDO17TmnSSoh+tDkKty6goTwfy1r1K7fhQwq6r94rTBNksXjMCI6WDQ6KgcUpL0nSHa ptMdyuD66ya/U/oCpLZ69v1EzqRCKtNKkPA30j8nj5SbcOEVlcutimkZ3+8OFIm4a/pD OdFwOt0/XRgp9iLFIoUUzB7LGtNmcg8hiX6/H4xa+OioW540TzyWlianwsnKHwWwWutP esdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CxvtArSR; 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 a11si375079jat.23.2021.05.19.13.24.19; Wed, 19 May 2021 13:24:33 -0700 (PDT) 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=CxvtArSR; 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 S232632AbhESUFK (ORCPT + 99 others); Wed, 19 May 2021 16:05:10 -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-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