Message ID | 20230411141529.428991-8-david@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 C1220C77B73 for <linux-mm@archiver.kernel.org>; Tue, 11 Apr 2023 14:15:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0B1A900004; Tue, 11 Apr 2023 10:15:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D1F476B007E; Tue, 11 Apr 2023 10:15:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4B9B900004; Tue, 11 Apr 2023 10:15:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 992C26B007D for <linux-mm@kvack.org>; Tue, 11 Apr 2023 10:15:49 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4DA4BAC34C for <linux-mm@kvack.org>; Tue, 11 Apr 2023 14:15:49 +0000 (UTC) X-FDA: 80669308818.05.B95BBB2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 8286620007 for <linux-mm@kvack.org>; Tue, 11 Apr 2023 14:15:47 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=O6BaOh0L; spf=pass (imf13.hostedemail.com: domain of david@redhat.com designates 170.10.129.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=1681222547; 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:in-reply-to:references:references:dkim-signature; bh=qzK4ogixuaREht4MpkiqqhFPvzGg6ALQmBRRBO9bEhw=; b=tMU1t6hvWqnB1YQWMPlZyf7zAaPa5SZ4sEp2r31umVfrYG2q0F1uCIGbxTD8YYDVAJ8aLg JMCf97NE2kp0r8GhpyGhKkBNCzVh//DHokaPb2Dxc5LGEoPF1m4abVQM4fpmRtfBdDQ5gD xfMi5cV7XtFurzNZF+ZXfAaHT1A+kNQ= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=O6BaOh0L; spf=pass (imf13.hostedemail.com: domain of david@redhat.com designates 170.10.129.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=1681222547; a=rsa-sha256; cv=none; b=BJfeauLSm2HBM8ux6fi4zXqwsgyF0UTMQZ6IpdHt0DNUr6ScEih9Qmb14GYhQHDhNEaBx1 CfhJw4SQud+rCV8j16EDXiilKCKpkI7asOR11HXykLHACGVzyvFNmWjgQsTePjBe+9Gd6h oH+59KvuV1RizFePBA8/1tu+aKlZXMw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681222546; 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: in-reply-to:in-reply-to:references:references; bh=qzK4ogixuaREht4MpkiqqhFPvzGg6ALQmBRRBO9bEhw=; b=O6BaOh0L13qkLbG8veJdxvJEl8sEOKMaLWRDcSqV+uhs7fQWmWvODRSCHBcAgkmrDixyCR EmOL/LyaNUwZ6uB7HUacqiLquTZS6DUJrD/mgOkbl8dt5z1EhObJkZ8fD1jEFUMYQz41zf PvmlgdDbevDcrcvaLVtMXle/ixAUG1Q= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-371-Ckkwz92eO7-IkeIGQlURJg-1; Tue, 11 Apr 2023 10:15:45 -0400 X-MC-Unique: Ckkwz92eO7-IkeIGQlURJg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 17DDE1C12991; Tue, 11 Apr 2023 14:15:45 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.194.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9240D400F281; Tue, 11 Apr 2023 14:15:43 +0000 (UTC) From: David Hildenbrand <david@redhat.com> To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, sparclinux@vger.kernel.org, David Hildenbrand <david@redhat.com> Subject: [PATCH v1 6/6] mm/huge_memory: conditionally call maybe_mkwrite() and drop pte_wrprotect() in __split_huge_pmd_locked() Date: Tue, 11 Apr 2023 16:15:29 +0200 Message-Id: <20230411141529.428991-8-david@redhat.com> In-Reply-To: <20230411141529.428991-1-david@redhat.com> References: <20230411141529.428991-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8286620007 X-Stat-Signature: cmgrxsmtjwuid8x1ykwdch9aduurcder X-HE-Tag: 1681222547-1516 X-HE-Meta: U2FsdGVkX19e3juiHA817NEU/No35axFdh7FkgDhJ403vHeTHvNUVppXAZff5RrkpbOtwKfR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Y2ZP2hqg3hUhsL93bDb9C6wb7oj2jW/3PC0nHs3ScVJIa0dZ2qlJw5wK+nloz+YIh3F+ZH8ud8= 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: <linux-mm.kvack.org> |
Series |
[v1,1/6] selftests/mm: reuse read_pmd_pagesize() in COW selftest
|
expand
|
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 6f3af65435c8..8332e16ac97b 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2235,11 +2235,10 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, entry = pte_swp_mkuffd_wp(entry); } else { entry = mk_pte(page + i, READ_ONCE(vma->vm_page_prot)); - entry = maybe_mkwrite(entry, vma); + if (write) + entry = maybe_mkwrite(entry, vma); if (anon_exclusive) SetPageAnonExclusive(page + i); - if (!write) - entry = pte_wrprotect(entry); if (!young) entry = pte_mkold(entry); /* NOTE: this may set soft-dirty too on some archs */
No need to call maybe_mkwrite() to then wrprotect if the source PMD was not writable. It's worth nothing that this now allows for PTEs to be writable even if the source PMD was not writable: if vma->vm_page_prot includes write permissions. As documented in commit 931298e103c2 ("mm/userfaultfd: rely on vma->vm_page_prot in uffd_wp_range()"), any mechanism that intends to have pages wrprotected (COW, writenotify, mprotect, uffd-wp, softdirty, ...) has to properly adjust vma->vm_page_prot upfront, to not include write permissions. If vma->vm_page_prot includes write permissions, the PTE/PMD can be writable as default. This now mimics the handling in mm/migrate.c:remove_migration_pte() and in mm/huge_memory.c:remove_migration_pmd(), which has been in place for a long time (except that 96a9c287e25d ("mm/migrate: fix wrongly apply write bit after mkdirty on sparc64") temporarily changed it). Signed-off-by: David Hildenbrand <david@redhat.com> --- mm/huge_memory.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)