From patchwork Wed Apr 28 22:50:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12230193 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=-14.0 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 62994C433B4 for ; Wed, 28 Apr 2021 22:51:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EE1C46143C for ; Wed, 28 Apr 2021 22:51:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE1C46143C 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 7EC0C6B006E; Wed, 28 Apr 2021 18:51:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C2696B0070; Wed, 28 Apr 2021 18:51:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6634F6B0071; Wed, 28 Apr 2021 18:51:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0038.hostedemail.com [216.40.44.38]) by kanga.kvack.org (Postfix) with ESMTP id 4D27D6B006E for ; Wed, 28 Apr 2021 18:51:17 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 02648180AD820 for ; Wed, 28 Apr 2021 22:51:17 +0000 (UTC) X-FDA: 78083273394.25.C39F3C3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 8C7AA40001DE for ; Wed, 28 Apr 2021 22:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619650276; 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=v+CSK+FiuJ6SZRuJ8V5d9OF6/lPvPFEfhlB2Y9d/xoA=; b=P+cgjP4NylAWl7bDMvNj48crTF92We+QmrqWRtkdL6mwOywW/hg2udy4BGa1CzdIb++qfs rtGIFDq69gnrn7JBfkMlN3rqhtRYi92YgV5oG8HOA8LGVlqx3v3XDnCPARtph2Bo5kAdkI sAtdI/U04S8naV9rAlnXwSEjG79OtgU= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-316-hNtNNjgFM5aORQaksACFGg-1; Wed, 28 Apr 2021 18:51:14 -0400 X-MC-Unique: hNtNNjgFM5aORQaksACFGg-1 Received: by mail-qv1-f72.google.com with SMTP id t1-20020a0ca6810000b029019e892416e6so28936711qva.9 for ; Wed, 28 Apr 2021 15:51:14 -0700 (PDT) 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=pooU5ZMLKkXMJLA5e7oiaebU/wArQl02uO8h9xkGhvk=; b=NrXOpd5efSwCa6xfgjW76fHyD/Gb2k7VYpEZf0U47Nbo+tbZ/fq661kt5Ea6nY4xLR 0sQ5N1L8iCYinS0L0OjX6eTQphNCLI0lEbTmGCZLJ7KN+6FcSJBP3rh6kfkKlQP7I1uU AbPp03Rc/L7FiuLkbubUZghgtALVR/vAOUabb6sCWhx6IrDbFgD7TUJxRRkh8DdACb0A NjVYg/vWrwpUTPs5gsMILxHrvFrFUmTdJ8kB57yb4HsKDBL9dwU0pEhq9X/wc+KklKmJ rxsLHyDredxvZbgeBExgd5eXiIHG1OTkkTsEiMCqrM1CkLIikPMTE4m6ELQCon8a/zs2 TAig== X-Gm-Message-State: AOAM5309KZn0BIWUtQ+2dh6IhXR37RTXngZpyrxeSxd+zPsLQLP4HMRY tvd8eGj9HwSa0axmIPeU51bXMA6+HBd5MrppJDtFdAkhRW8RzmRnEjCNp+Vivu6kBBuII9Zt9oj MV9gMteP50cLDQ27qlK2+e9fWGFpVTjWSBdoSOnETvuBvi+7LdS0qa4VqNywk X-Received: by 2002:a37:e508:: with SMTP id e8mr32053937qkg.82.1619650273298; Wed, 28 Apr 2021 15:51:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz6tneTK/gPqfHFunV9HPSIM2btpZ/L7qjW7iOF1MGO7e05kOtYMYLy8fnSNLgrS4EN38Ecw== X-Received: by 2002:a37:e508:: with SMTP id e8mr32053911qkg.82.1619650272985; Wed, 28 Apr 2021 15:51:12 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-77-184-145-104-227.dsl.bell.ca. [184.145.104.227]) by smtp.gmail.com with ESMTPSA id 191sm897459qkk.31.2021.04.28.15.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 15:51:12 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Mike Kravetz , peterx@redhat.com, Mike Rapoport , Axel Rasmussen , Andrea Arcangeli , Hugh Dickins , "Kirill A . Shutemov" , Andrew Morton , Jerome Glisse Subject: [PATCH 0/6] mm/uffd: Misc fix for uffd-wp and one more test Date: Wed, 28 Apr 2021 18:50:24 -0400 Message-Id: <20210428225030.9708-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: 8C7AA40001DE X-Stat-Signature: uuoambe3wqarp1f7t56qowasj4ezptxy Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf26; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619650267-899513 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: This series is based on (mostly) v5.12-rc8-mmots-2021-04-21-23-08. It tries to fix some corner case bugs for uffd-wp on either thp or fork(). Then it introduced a new test with pagemap/pageout. Patch layout: Patch 1: cleanup for THP, it'll slightly simplify the follow up patches Patch 2-4: misc fixes for uffd-wp here and there; please refer to each patch Patch 5: add pagemap support for uffd-wp Patch 6: add pagemap/pageout test for uffd-wp The last test introduced can also verify some of the fixes in previous patches, as the test will fail without the fixes. However it's not easy to verify all the changes in patch 2-4, but hopefully they can still be properly reviewed. Note that if considering the ongoing uffd-wp shmem & hugetlbfs work, patch 5 will be incomplete as it's missing e.g. hugetlbfs part or the special swap pte detection. However that's not needed in this series, and since that series is still during review, this series does not depend on that one (the last test only runs with anonymous memory, not file-backed). So this series can be merged even before that series. Please review, thanks. Peter Xu (6): mm/thp: Simplify copying of huge zero page pmd when fork mm/userfaultfd: Fix uffd-wp special cases for fork() mm/userfaultfd: Fix a few thp pmd missing uffd-wp bit mm/userfaultfd: Fail uffd-wp registeration if not supported mm/pagemap: Export uffd-wp protection information userfaultfd/selftests: Add pagemap uffd-wp test Documentation/admin-guide/mm/pagemap.rst | 2 + fs/proc/task_mmu.c | 9 ++ fs/userfaultfd.c | 9 +- include/linux/huge_mm.h | 2 +- include/linux/swapops.h | 2 + mm/huge_memory.c | 36 +++--- mm/memory.c | 25 ++-- tools/testing/selftests/vm/userfaultfd.c | 154 +++++++++++++++++++++++ 8 files changed, 206 insertions(+), 33 deletions(-)