From patchwork Thu Feb 18 21:54:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12094351 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=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 8A5A6C433E0 for ; Thu, 18 Feb 2021 21:54:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0382A64EAE for ; Thu, 18 Feb 2021 21:54:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0382A64EAE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 70E916B0005; Thu, 18 Feb 2021 16:54:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6BFD86B006C; Thu, 18 Feb 2021 16:54:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AC126B006E; Thu, 18 Feb 2021 16:54:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by kanga.kvack.org (Postfix) with ESMTP id 465306B0005 for ; Thu, 18 Feb 2021 16:54:41 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0418A180ACEE6 for ; Thu, 18 Feb 2021 21:54:41 +0000 (UTC) X-FDA: 77832743562.11.2F7648C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf11.hostedemail.com (Postfix) with ESMTP id C056B2000347 for ; Thu, 18 Feb 2021 21:54:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613685279; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SbbnNqyL6KzsfDEoGS5BIqVOvxByWd79TeW6Wxzs5is=; b=FsYc76KUCLmSN978QWfSjK7h89Km35hm3JZXY6yyspTWV277fV9ZWhXrfmO9jLQjzIYF3Z kGxHoNq7666rfxzYggtxjTUu3zL3+AxDbqTzzdzz9eHvo6Qfu5zzOB8qpgXJb7SGtIvQg8 8V2IdI+N5kg7TfwlXPBa2dviwrvPFZI= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-179-DX1qf5WNO5ujnjWmBek71Q-1; Thu, 18 Feb 2021 16:54:37 -0500 X-MC-Unique: DX1qf5WNO5ujnjWmBek71Q-1 Received: by mail-qt1-f200.google.com with SMTP id k17so2059482qtm.13 for ; Thu, 18 Feb 2021 13:54:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=X72h3X9QeITmbnaHCGHJT4/NFKw/NsWjIcozUdmjBYg=; b=Bwo65PeMKFop2tN8/jT/YxOYRrviweMcbInLKTMxhiu5zGWy/wxn/7eRnO/mNuj9b8 wa5QT18tZjMiuZhMJnJkB7MmZDGWUgYmW8Sv0BUOafXXtKLiLLWW4yYoG8xU5q4ko1qz UnWIOZPg7RUq1b6DE5DqGs2c6PHodazwTh77YI1Dh/YdptyG7hMgaCDoXim2zt4vOQEn Juqc3WrFj7PeMFe4AfP+6w10Udn9ym8jmFpNa7JrAQxBZrb7EnZNBtM+6jM0pw5IR19K eupXmAts4Jlv06CCCi3YExk0gnxVROUXB9A2Y5YkdlAwR7z33N82S307SAG+P6A0/jYM 0BsA== X-Gm-Message-State: AOAM533ysGx+mTu4b0h/G3MNV/GoIjB+VwverYWgD8sk+Ozu8Jnu15b7 QK1DHS/SYZeDj/qHi9wDqjALBg3u88rmn6up8hpCsD3WfJT9qLqjwi30DC52EMZmtSc0qd70jT8 0oxx0hc5NsRA= X-Received: by 2002:ac8:1c8a:: with SMTP id f10mr6247939qtl.4.1613685276914; Thu, 18 Feb 2021 13:54:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKpJysF8Z6OiDKi/RnE/9ALHDKOUdtKMTout7CHDUFl0L9SidW1njBRGBHLHCtpGd/DqLCKw== X-Received: by 2002:ac8:1c8a:: with SMTP id f10mr6247928qtl.4.1613685276697; Thu, 18 Feb 2021 13:54:36 -0800 (PST) Received: from xz-x1.redhat.com (bras-vprn-toroon474qw-lp130-20-174-93-89-182.dsl.bell.ca. [174.93.89.182]) by smtp.gmail.com with ESMTPSA id r80sm4964260qke.97.2021.02.18.13.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 13:54:35 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Axel Rasmussen , Andrew Morton , peterx@redhat.com, Mike Kravetz , Mike Rapoport , "Kirill A . Shutemov" , Matthew Wilcox , Andrea Arcangeli Subject: [PATCH v3 0/4] hugetlb: Disable huge pmd unshare for uffd-wp Date: Thu, 18 Feb 2021 16:54:30 -0500 Message-Id: <20210218215434.10203-1-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C056B2000347 X-Stat-Signature: ehqzt7occ7am3gcxakbwiqszuiypj9rt Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf11; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1613685273-678081 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: v3: - patch 4: - fix build failure for !CMA and/or !HUGETLBFS [Axel] - Fix mmu notifier range to use start/end [Mike] - add more r-bs v2: - patch 4: move hugetlb_unshare_all_pmds() into mm/hugetlb.c, so it can be used even outside userfaultfd.c This series tries to disable huge pmd unshare of hugetlbfs backed memory for uffd-wp. Although uffd-wp of hugetlbfs is still during rfc stage, the idea of this series may be needed for multiple tasks (Axel's uffd minor fault series, and Mike's soft dirty series), so I picked it out from the larger series. References works: Uffd shmem+hugetlbfs rfc: https://lore.kernel.org/lkml/20210115170907.24498-1-peterx@redhat.com/ Uffd minor mode for hugetlbfs: https://lore.kernel.org/lkml/20210212215403.3457686-1-axelrasmussen@google.com/ Soft dirty for hugetlbfs: https://lore.kernel.org/lkml/20210211000322.159437-1-mike.kravetz@oracle.com/ Please review, thanks. Peter Xu (4): hugetlb: Pass vma into huge_pte_alloc() and huge_pmd_share() hugetlb/userfaultfd: Forbid huge pmd sharing when uffd enabled mm/hugetlb: Move flush_hugetlb_tlb_range() into hugetlb.h hugetlb/userfaultfd: Unshare all pmds for hugetlbfs when register wp arch/arm64/mm/hugetlbpage.c | 7 ++- arch/ia64/mm/hugetlbpage.c | 3 +- arch/mips/mm/hugetlbpage.c | 4 +- arch/parisc/mm/hugetlbpage.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 3 +- arch/s390/mm/hugetlbpage.c | 2 +- arch/sh/mm/hugetlbpage.c | 2 +- arch/sparc/mm/hugetlbpage.c | 1 + fs/userfaultfd.c | 4 ++ include/linux/hugetlb.h | 18 ++++++- include/linux/userfaultfd_k.h | 9 ++++ mm/hugetlb.c | 94 +++++++++++++++++++++++++++-------- mm/userfaultfd.c | 2 +- 13 files changed, 116 insertions(+), 35 deletions(-)