From patchwork Thu Feb 18 23:06:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12094499 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 158E9C433DB for ; Thu, 18 Feb 2021 23:06:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6E3F664E22 for ; Thu, 18 Feb 2021 23:06:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E3F664E22 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 E41946B006C; Thu, 18 Feb 2021 18:06:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DF1546B006E; Thu, 18 Feb 2021 18:06:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE04E8D0001; Thu, 18 Feb 2021 18:06:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0189.hostedemail.com [216.40.44.189]) by kanga.kvack.org (Postfix) with ESMTP id B7F316B006C for ; Thu, 18 Feb 2021 18:06:39 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 77CF76C36 for ; Thu, 18 Feb 2021 23:06:39 +0000 (UTC) X-FDA: 77832924918.05.3CB4A4C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 5F211A0000FD for ; Thu, 18 Feb 2021 23:06:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613689598; 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=iUkToTgi2MpVEpgRznC1R8LYuRpLcRsd3s7gCSbAdrs=; b=ewsu1VOxfPcJM/iLWHzj3WN/87OqSTTaLGHNJZxgtZsE2RFmQPF0yV8anhkWHRZ0JrMvau 15fTWwEFwVq75FFEcmoS+hBcwJrFZC2vzN7h/SnCuqMeV6kagT7oDvQr3Krss7J5+Sd6kL SEFG1VsbwDwNzf4Hy+TDG4jrmJOtBkY= 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-13-yfAOpiGoMdm4rOygYmyxxw-1; Thu, 18 Feb 2021 18:06:36 -0500 X-MC-Unique: yfAOpiGoMdm4rOygYmyxxw-1 Received: by mail-qt1-f200.google.com with SMTP id k28so2141388qtu.17 for ; Thu, 18 Feb 2021 15:06:36 -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=GV3FE/jRmWIDU2Byyij+J0dLblDpKaJcJNBj8qAB4Uo=; b=QVeK1M5WiE05poe1I3qOmTiyfGKZSjqB4TzmANNR2hMXImbttG6sTpw0cSAHG1hlu6 nw5SWYJf6MsAduPXme4SWM8+F3tvpwAmT4UTgoCi3wv/43PLIpk94RNWSpN6st8p2OBf iLBi8dgPHsJtnJ3dcVWS40Hbig9awSHc2p7IM2F+YLixrigAQZLuuOPsN3v7Bik64cfh BRb/IMvAXqHcA3cIlGrK/45/dQz8V4sYZ/ymeG/GQyjNvOn1T1VGltqT+8Pl3Jm5cFkg +MgkGakx1hT1lnHtYY48WidsZIPw7mPiRNN9oSr96QXg/UHGNRbaoDq8V2GXMRjHsSHI zfAA== X-Gm-Message-State: AOAM532sSWM/vmoYmUU0HJsKKYa5kEL0gXsyxQJO3MwEII4nw+d2pBne NGBoh28e43fiiFA3NMb9fLXkksO54L1mwGSKZi0vuRj7Y48E+MhJXQdu2/tde4f5kPhvQoyPPRA j5uW9FcOBR5g= X-Received: by 2002:a37:a151:: with SMTP id k78mr6574370qke.359.1613689596175; Thu, 18 Feb 2021 15:06:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPrqsgYJKzHr/HODkfu/1u3GuJEBtKDqd45PLibWEiQQEcWHtTMfT4v9Ji/0SungUuXvBO8g== X-Received: by 2002:a37:a151:: with SMTP id k78mr6574349qke.359.1613689595954; Thu, 18 Feb 2021 15:06:35 -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 p81sm4994324qke.18.2021.02.18.15.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 15:06:35 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , Axel Rasmussen , "Kirill A . Shutemov" , Mike Rapoport , Mike Kravetz , Andrea Arcangeli , peterx@redhat.com Subject: [PATCH v4 0/4] hugetlb: Disable huge pmd unshare for uffd-wp Date: Thu, 18 Feb 2021 18:06:29 -0500 Message-Id: <20210218230633.15028-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: rspam03 X-Rspamd-Queue-Id: 5F211A0000FD X-Stat-Signature: h6p36ugyjhhxdihr1jsf5sdk3yei1h8m Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf15; 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: 1613689598-287716 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: v4: - fix build for sparc by removing extra line in patch 1 [Mike] - pick Mike's r-b for patch 4 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 | 2 +- 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(+), 36 deletions(-)