From patchwork Fri Dec 23 15:56:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13081013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F108C4332F for ; Fri, 23 Dec 2022 15:56:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC5F3900003; Fri, 23 Dec 2022 10:56:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C7592900002; Fri, 23 Dec 2022 10:56:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6457900003; Fri, 23 Dec 2022 10:56:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id ACA1F900002 for ; Fri, 23 Dec 2022 10:56:28 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 768EB8095A for ; Fri, 23 Dec 2022 15:56:28 +0000 (UTC) X-FDA: 80274023256.10.DAC71E6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 8DAA480003 for ; Fri, 23 Dec 2022 15:56:26 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=O1IqZXDl; spf=pass (imf30.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671810987; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=YFGL/G9+HUTWGCGBfqQK3zqTS7XYaxW9cVX6e4qh9go=; b=4hAVMyLn1hk+WFgvKTCcPSWrX8ggPIe/ldBWrdT9LPhnHPDIhF5jUKEZY8Aqfd5ICbsxZN rQA4KcPbKZ3jr7LRIMO4cbTS7wMting3GxixRH5VzMIDFc3+HS3mfCvtcAIPpXYOxmnnTt Sv0HMDgXs625E/OrVxADIb8goWfec+g= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=O1IqZXDl; spf=pass (imf30.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671810987; a=rsa-sha256; cv=none; b=WGKLgfopVN9jcTQehU+6hUeTNy+IhmWS25bHr3LWl5CY/YbbbMsNTRB751zkJk6mZH+/nH yo4LzjpGqq76KIpntPmTNQTl5KlU7SX65xsV1/ydbvjIcYlE7ihS8r4owHLFS+QZeOERw4 FR4l2l4H+nH6xHR+oS5pZSBZJomtrRg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671810985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=YFGL/G9+HUTWGCGBfqQK3zqTS7XYaxW9cVX6e4qh9go=; b=O1IqZXDl5dgVm80j4nzmKsQvJMDX0CuoUhJihQinFR1MNiYfO7g93FWL7P+iJRkFQ0BcY9 H4c/02wQlwYki6Yn3/NDX+pu91uMaEi9kuBiTRREbw8TkNSYz046WGr8NCqg1KhpEB3xiK 1evpnTQJQL5E3PP6tlQT1OtJZKZlPXs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-128-pQynWuoHPRKtnTs5xa0qCQ-1; Fri, 23 Dec 2022 10:56:20 -0500 X-MC-Unique: pQynWuoHPRKtnTs5xa0qCQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 219A3882827; Fri, 23 Dec 2022 15:56:20 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.192.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB6B440C2064; Fri, 23 Dec 2022 15:56:17 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Peter Xu , Hugh Dickins , Andrea Arcangeli , Nadav Amit Subject: [PATCH v1 0/2] mm: uffd-wp + change_protection() cleanups Date: Fri, 23 Dec 2022 16:56:14 +0100 Message-Id: <20221223155616.297723-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 8DAA480003 X-Stat-Signature: 1q5aarm9fzro53ng4c4nzf3ffg39uba1 X-Rspam-User: X-HE-Tag: 1671810986-170807 X-HE-Meta: U2FsdGVkX1/88dF0UsXyH6PJWcBd482gVttvghLjQgljQhlSaVogaXVP4RT70khJVehF39byUcdayS1IX/cwZRy/A8GOJ7uPtZcs8kNCT0+k68FWyumLXe3Y3rLXg7mzM++TrjeJr3dTgibC89CghaC6QklPghiMmhuARG2pNMomK6bLlNESmYtUuXtVgCtCArq/LuvoJID2QQDVLBA6gGPEEC6xcWxUFM16WVanRS3NsnvHh37/ncwrzwp5kTlRJrUpOZQ85NTjGM5XpXC1OxHHP/UJDH32jHZZeHHr44lVcpR8E9kaFs8kUxtNVaYEKo5XcCsCEV01P6Qk8n7knKQ08oNJLKR1r502mPQhQ+kIDXM5QhvO53dow6na4p9HVPo/Ifb69KMUEErqmE6hb5vN/+FJqXViR51dsqrSVec11UdJ9aPo4WKiSAoTKhpNBoAjL5+E+xXAcccuIYsGBNrtgH4imbXvTs7FX9GkwGgD8q7bLPoVl+CzjrbIdy3nj2Zh/8lxzey9+HYv6ymByyQIYezmPVHnUS/yD+znngZSCufo5gKH+ORpnbFGOiNQM+knrJu5XQHnTKs3Dvf7+YPvpzBEUl8keRHy0eg5K25Bif8czwQE+akNP9T8KM/ccoqv5Fn9DVE8rHZeO5vxtOs8baN3rMXSh/zxbgv9xuO/TGqXSnfl2Q1YNV8ubMJa0O4Po8M19pPE60egyqHh0sdyXG5rhtV+rpX6d/kHE1qUB7S0sc92FrNlmOXAgtNriGC0GnuQSIK6xQhZpF1RVPX/t4F8JNAp91J1ksI81bnIxM8gGJ7AAcB3Iano5Qwtb95bozKcEzN/P59AFdRh8nmaBHUu9yE+sqL9pTz1I2W8M6un8CGyGFxnzIT2+zoSK69bK0ATePSI2Zv7ZmRudGmhTSpyphWmXtyZEumtsojMOYPERtLSE+WxqJHR+7ovoDHGwxTDODfEF+N+lk7 vVhSyL/h ycaP6UQn1ptWqPppTpQ4Gnks1CzXS8KpTGmXu7JeHxgtYCGNfyxkRSxgMag== 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: Based on linus/master and [1]: "mm/userfaultfd: enable writenotify while userfaultfd-wp is enabled for a VMA" Cleanup page protection handling in uffd-wp when calling change_protection() and improve unprotecting uffd=wp in private mappings, trying to set PTEs writable again if possible just like we do during mprotect() when upgrading write permissions. Make the change_protection() interface harder to get wrong :) I consider both pages primarily cleanups, although patch #1 fixes a corner case with uffd-wp and softdirty tracking for shmem. @Peter, please let me know if we should flag patch #1 as pure cleanup -- I have no idea how important softdirty tracking on shmem is. Survives my simple test case + selftests/vm. Last patch series before Christmas; happy holidays everyone! Cc: Andrew Morton Cc: Peter Xu Cc: Hugh Dickins Cc: Andrea Arcangeli Cc: Nadav Amit [1] https://lore.kernel.org/all/20221209080912.7968-1-david@redhat.com/T/#u David Hildenbrand (2): mm/userfaultfd: rely on vma->vm_page_prot in uffd_wp_range() mm/mprotect: drop pgprot_t parameter from change_protection() include/linux/mm.h | 3 +-- mm/mempolicy.c | 3 +-- mm/mprotect.c | 14 +++++++++++--- mm/userfaultfd.c | 17 ++++++++++++----- 4 files changed, 25 insertions(+), 12 deletions(-)