From patchwork Tue Apr 11 14:25:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13207675 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 63C6AC76196 for ; Tue, 11 Apr 2023 14:25:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F406728000B; Tue, 11 Apr 2023 10:25:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC77A28000A; Tue, 11 Apr 2023 10:25:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D424428000B; Tue, 11 Apr 2023 10:25:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BCADD28000A for ; Tue, 11 Apr 2023 10:25:37 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 76918140C98 for ; Tue, 11 Apr 2023 14:25:37 +0000 (UTC) X-FDA: 80669333514.21.8192081 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 840961C001B for ; Tue, 11 Apr 2023 14:25:35 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FzOvU2t+; spf=pass (imf20.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=1681223135; 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=kMuXjs2koZ/Flt7PJQx7eiW1x5ktANLpUol8YMKeKVs=; b=xWTICjqghE4b7uZIpacrX+d2AJdzrFxRePD3hcmoSP3RGjckBt7VqMEJPRXhy5Qbyxx+Cw AdncHdlMdoIfxpjsjZCNy8Zlt9qKypW0xBYgcMWcyUpFYBWk8ekR4iVv4Ct0+YS7DrvRbD UTmR4fTyxcP7/9tNuBkZ++RUoDPST0A= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FzOvU2t+; spf=pass (imf20.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=1681223135; a=rsa-sha256; cv=none; b=V1gXCLp5fLv/QjVy3Is+AT736Cy4PO8c/2MOZERy+oPZqNjLno7zxZBXuh8COic6VWMduj iqS+gQVUr6QVRFGsxE/BqdibxIMs4F/v7FTM74GB8HEyuiJczVD6p1NiHvW8qhikL1Ra7z 2fP7apjTUnTzU+CAXsH+VTeykQ14C4o= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681223134; 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=kMuXjs2koZ/Flt7PJQx7eiW1x5ktANLpUol8YMKeKVs=; b=FzOvU2t+fu03w6WvzaWLkqWWsXJvuQ6x3tBeMgm1gevZorETxejKDU4fJZHzYkbe3IlOv5 Qe6gZvwM5EZOcUtyeaqHNmY5Ve+sZ76VehgplNWWut4p0i4kDyldC5QbrLopagn3oXybZa o4J4DWxl28lJ7Uf0YnpgxHDfKNvlxXY= 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-497-HXPMVzgwN7ms9In_1b7_gA-1; Tue, 11 Apr 2023 10:25:29 -0400 X-MC-Unique: HXPMVzgwN7ms9In_1b7_gA-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 EF19628237D4; Tue, 11 Apr 2023 14:25:28 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.194.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA53914171D7; Tue, 11 Apr 2023 14:25:26 +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 5/6] mm/huge_memory: revert "Partly revert "mm/thp: carry over dirty bit when thp splits on pmd"" Date: Tue, 11 Apr 2023 16:25:11 +0200 Message-Id: <20230411142512.438404-6-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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 840961C001B X-Stat-Signature: mxp1mjks585d181fgqfdnirfiu845skz X-Rspam-User: X-HE-Tag: 1681223135-571639 X-HE-Meta: U2FsdGVkX18onhZvQobnHCy805HfuWQROqEW2OSAoNicq6RQ9yce9gjnnGWDwon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Ggffm8PeDWBstx6yYaU/J07xU4o154ncyTQo+sQCVIjkgQzuxG2MsflejWoNUB/PEIuDS4ee5AgooGlM= 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 624a2c94f5b7 ("Partly revert "mm/thp: carry over dirty bit when thp splits on pmd"") and the fixup in commit e833bc503405 ("mm/thp: re-apply mkdirty for small pages after split"). 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 and remove the stale comment. 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 | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index ec86bf1d4e81..6f3af65435c8 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2238,18 +2238,13 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, 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 */ if (dirty) entry = pte_mkdirty(entry); - /* - * NOTE: this needs to happen after pte_mkdirty, - * because some archs (sparc64, loongarch) could - * set hw write bit when mkdirty. - */ - if (!write) - entry = pte_wrprotect(entry); if (soft_dirty) entry = pte_mksoft_dirty(entry); if (uffd_wp)