From patchwork Tue Apr 11 14:25:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13207674 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 7C9F2C77B6F for ; Tue, 11 Apr 2023 14:25:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B3B928000E; Tue, 11 Apr 2023 10:25:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 810B428000B; Tue, 11 Apr 2023 10:25:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B38328000E; Tue, 11 Apr 2023 10:25:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 521BC28000B for ; Tue, 11 Apr 2023 10:25:32 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 29A7A140DAF for ; Tue, 11 Apr 2023 14:25:32 +0000 (UTC) X-FDA: 80669333304.18.CB1354C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 5C55B1C000C for ; Tue, 11 Apr 2023 14:25:30 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bM1ebTLB; spf=pass (imf18.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=1681223130; 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=TCmOrD6a+wU+gQBMdrpGdoWY5w1T2pXs/1sAiD9BNP4=; b=ujWq6+IWu5gPjDdLhuScitlEX5eWPmXxQ30i6NpmuyCowle4s6t0gyIgVE6rl5AOyWePhK oa2clgB3OUOYHvxLRR0gEZRGgxXni63fqjwAerCDZCGyq6GZqHLm0xrScxzAW/CWighS73 /+M/6MxtcQyk51LGCcnENj7cMk6xiA8= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bM1ebTLB; spf=pass (imf18.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=1681223130; a=rsa-sha256; cv=none; b=V1j/GhMrxG608tL7zIyWmwitLVYDxo5aRRWhs8MMiWfrPlYACHHBpJBjjL2pKkMF/itSrg p6grnV7X1w9ou0uaShAXi9mCZV8wa/rkkzpBRNbl7EGU6/Z9hWzM5Hgit2EeKjhV67zoHf S28UfvuBEUgclHSthFPsDLq0QSj+/2E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681223129; 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=TCmOrD6a+wU+gQBMdrpGdoWY5w1T2pXs/1sAiD9BNP4=; b=bM1ebTLBUtS6qEv0Xt9LiWk4zZAMCUxEmZIWMsXZKbpIdr3nNfrEGx5+vFE1j4RHOJAYN3 kj/32XAKwRtU9++hQ/eSDwTDpIU5OUwoKL3HE055DUGqrqITCH0jl1jKq7Ql/qZXOBp6Ng 17KTgNc68N99aEJLaoC/NPeeTvhAWmI= 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-201-jqtwgpbOM-qgH4SCN4auyA-1; Tue, 11 Apr 2023 10:25:27 -0400 X-MC-Unique: jqtwgpbOM-qgH4SCN4auyA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E5D128237C8; Tue, 11 Apr 2023 14:25:26 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.194.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64E9714171D7; Tue, 11 Apr 2023 14:25:24 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, sparclinux@vger.kernel.org, David Hildenbrand , Andrew Morton , "David S. Miller" , Peter Xu , Hugh Dickins , Shuah Khan , Sam Ravnborg , Yu Zhao , Anshuman Khandual Subject: [PATCH v1 RESEND 4/6] mm/migrate: revert "mm/migrate: fix wrongly apply write bit after mkdirty on sparc64" Date: Tue, 11 Apr 2023 16:25:10 +0200 Message-Id: <20230411142512.438404-5-david@redhat.com> In-Reply-To: <20230411142512.438404-1-david@redhat.com> References: <20230411142512.438404-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: fceh5wazh7t936x4e4c8q5t5nn6z6xxm X-Rspamd-Queue-Id: 5C55B1C000C X-HE-Tag: 1681223130-813083 X-HE-Meta: U2FsdGVkX1/Q7HHAzAtj1npQzZI3GT7v98R3v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Z++a7laDFh3onmokq5iKWK/A+oT4oDaDFbZ/dWi9FK4uCk7bR+LNO9OelwAjSVOVb 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 reverts commit 96a9c287e25d ("mm/migrate: fix wrongly apply write bit after mkdirty on sparc64"). Now that sparc64 mkdirty handling is fixed and no longer sets a PTE/PMD writable that shouldn't be writable, let's revert the temporary fix. The mkdirty mm selftest still passes with this change on sparc64. Note that loongarch handling was fixed in commit bf2f34a506e6 ("LoongArch: Set _PAGE_DIRTY only if _PAGE_WRITE is set in {pmd,pte}_mkdirty()"). Signed-off-by: David Hildenbrand --- mm/huge_memory.c | 6 ++---- mm/migrate.c | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 032fb0ef9cd1..ec86bf1d4e81 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3276,6 +3276,8 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) pmde = mk_huge_pmd(new, READ_ONCE(vma->vm_page_prot)); if (pmd_swp_soft_dirty(*pvmw->pmd)) pmde = pmd_mksoft_dirty(pmde); + if (is_writable_migration_entry(entry)) + pmde = maybe_pmd_mkwrite(pmde, vma); if (pmd_swp_uffd_wp(*pvmw->pmd)) pmde = pmd_mkuffd_wp(pmde); if (!is_migration_entry_young(entry)) @@ -3283,10 +3285,6 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) /* NOTE: this may contain setting soft-dirty on some archs */ if (PageDirty(new) && is_migration_entry_dirty(entry)) pmde = pmd_mkdirty(pmde); - if (is_writable_migration_entry(entry)) - pmde = maybe_pmd_mkwrite(pmde, vma); - else - pmde = pmd_wrprotect(pmde); if (PageAnon(new)) { rmap_t rmap_flags = RMAP_COMPOUND; diff --git a/mm/migrate.c b/mm/migrate.c index db3f154446af..3b21c44e2176 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -225,8 +225,6 @@ static bool remove_migration_pte(struct folio *folio, pte = maybe_mkwrite(pte, vma); else if (pte_swp_uffd_wp(*pvmw.pte)) pte = pte_mkuffd_wp(pte); - else - pte = pte_wrprotect(pte); if (folio_test_anon(folio) && !is_readable_migration_entry(entry)) rmap_flags |= RMAP_EXCLUSIVE;