From patchwork Wed Dec 20 22:44:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13500622 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 26FEDC46CCD for ; Wed, 20 Dec 2023 22:45:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 122538D000B; Wed, 20 Dec 2023 17:45:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 07B638D0002; Wed, 20 Dec 2023 17:45:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E36598D000B; Wed, 20 Dec 2023 17:45:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D13D38D0002 for ; Wed, 20 Dec 2023 17:45:38 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8FCE516093D for ; Wed, 20 Dec 2023 22:45:38 +0000 (UTC) X-FDA: 81588679956.23.1D3E0A6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 142F58001B for ; Wed, 20 Dec 2023 22:45:36 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZGjQPSJ1; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703112337; 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=Ofk61e3x6rLiqTTNkmXQTXIg/O8hfjxoFIvAzETbtQ8=; b=ppCTBAojAmfciCvzjvOD+3EIrSTymlfilYEZZJoHIYX9KERphoNuOryiqUsemcMO2dIWLa OH7sAWJdmHQiVhHc55OBtMarS8zVOacTPDbeuIxIByO2QCbqXYiZ39LzPxldLhxO8PGGGS DE5pKQLl1Bxz/RKGaBwPF2air61arp8= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZGjQPSJ1; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703112337; a=rsa-sha256; cv=none; b=uSfa2jlJydDr4xboXNWDg1lPeYmk9TtLhO+adJBYnrf2z2hk0cYcCvMpdRGJLPKRHf3XeJ FlgeM1bKgY4N0v0ezxNvkRoJqEH3yvlJE5xULSAhR5M4Z63ijq/tlYKFtE/bJEA3H1IU6n ELpTURquB/+lIvzg4MdJ7VSpEYAzRSo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703112336; 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=Ofk61e3x6rLiqTTNkmXQTXIg/O8hfjxoFIvAzETbtQ8=; b=ZGjQPSJ10g4nK5li01+ZvZOUDCVnFJ/kk8xNCgtlOQRndsyOHQU1JE816/1GuVy+pZEVCQ amPg3Sy3qevQ7gH8OoVc27t3Yb169vGJZ4YUmbj/5vjlFyerbl5IIzMPLDxbko4Q0bzqWt ot23GFIeIZ0mkCLxf67CH1UWP363EKk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-179-veEaKfenML2oj5fpTRrRZA-1; Wed, 20 Dec 2023 17:45:31 -0500 X-MC-Unique: veEaKfenML2oj5fpTRrRZA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B99F863B83; Wed, 20 Dec 2023 22:45:30 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 611A040C6EB9; Wed, 20 Dec 2023 22:45:28 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , "Matthew Wilcox (Oracle)" , Hugh Dickins , Ryan Roberts , Yin Fengwei , Mike Kravetz , Muchun Song , Peter Xu Subject: [PATCH v2 09/40] mm/huge_memory: page_add_file_rmap() -> folio_add_file_rmap_pmd() Date: Wed, 20 Dec 2023 23:44:33 +0100 Message-ID: <20231220224504.646757-10-david@redhat.com> In-Reply-To: <20231220224504.646757-1-david@redhat.com> References: <20231220224504.646757-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 142F58001B X-Stat-Signature: roynph1bdd6iedk9j8woz8witkf4yitt X-Rspam-User: X-HE-Tag: 1703112336-153536 X-HE-Meta: U2FsdGVkX1/8gF7S+ztUDsY/lUX13CRB/FbLuxBiFltIQ828mdQs7oOS0r+P1qWKS22PZUWTN8MKkcuSIBc/FA7dgNW1z8WDR0aZtyrydt2xS1k7VpkvnzmMgjMVkpjDhpXw+uq7vnclqXNsc9G4VGmIh9zrD2bQpdjyrc94najV+WsmI57a8qGrDk7C8qLI+7koQCAD9DhJfMoYfuecsqY6u34jlkoNhoZnm0SJ+fanpxWUf6PAAFNc8jU7FPu3XhTZohNbhr4cLckKOk0oVnfLtAIDRo6T6zYaSAQA+bXdvdZwmr6oGL73rqwFXtqxmRp4Cw+7BHS0M7E6ZWtm4bEUCqablf4CnBAuHzGX3Ol+B/VnOWBEmPcN8cfiQAUQDL5qsscbFN+E9JEgv5OADkUrkX/6ElMYDEi9H+TXjI9P+YzCha01N4ea3b4xboHxVRnvaeXMuE6QmuACVmrIJcC8uoY9WoiYH/gP1cm6Zt6Ub/onjGhbP3PuiJwHnZGwPCoOSd+4Dj+byEd723syXd/1x/ImKl+5DkSKvYNe56k+pkH1BU62YHIqQs6Hv7ujmvA/I9rypviRJXs96nS6VVH+zP8zSdcv32ry+mjMtYDmiJev/0dd+K6eF+FkLqGF0+Syo1GESAALPF6hLS3IHxBh+7DBDQBPT0pXvQnyJdsWJBsKD13e/+uzMXeI66+EBFwAz3IfjvRQnxTWrmxUBbDYp5MvmbWWLcHumg5ScFpKWrqec8Iyd73iKKKLBt/Y89LiCKklYAr2Yd8xJ4LhB6kY9cBnYfPmWXvhb6tC+7p04omP/gYvjKxPkGhI880G93peOjmE/5A8yJZsq8jmOfASzNH4Y147tw8INJbjjKmymqSKNOYhPpUYCRsqUvlb4wq44vmVT5kp/MbTuZW2j/rwuaG0HjbkZgB8gIQmAst7YcJv6j73W3jEqqKTUeDH 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: List-Subscribe: List-Unsubscribe: Let's convert remove_migration_pmd() and while at it, perform some folio conversion. Reviewed-by: Yin Fengwei Reviewed-by: Ryan Roberts Signed-off-by: David Hildenbrand --- mm/huge_memory.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index c50dc2e1483fb..bce6f987f36a3 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3577,6 +3577,7 @@ int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw, void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) { + struct folio *folio = page_folio(new); struct vm_area_struct *vma = pvmw->vma; struct mm_struct *mm = vma->vm_mm; unsigned long address = pvmw->address; @@ -3588,7 +3589,7 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) return; entry = pmd_to_swp_entry(*pvmw->pmd); - get_page(new); + folio_get(folio); pmde = mk_huge_pmd(new, READ_ONCE(vma->vm_page_prot)); if (pmd_swp_soft_dirty(*pvmw->pmd)) pmde = pmd_mksoft_dirty(pmde); @@ -3599,10 +3600,10 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) if (!is_migration_entry_young(entry)) pmde = pmd_mkold(pmde); /* NOTE: this may contain setting soft-dirty on some archs */ - if (PageDirty(new) && is_migration_entry_dirty(entry)) + if (folio_test_dirty(folio) && is_migration_entry_dirty(entry)) pmde = pmd_mkdirty(pmde); - if (PageAnon(new)) { + if (folio_test_anon(folio)) { rmap_t rmap_flags = RMAP_COMPOUND; if (!is_readable_migration_entry(entry)) @@ -3610,9 +3611,9 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) page_add_anon_rmap(new, vma, haddr, rmap_flags); } else { - page_add_file_rmap(new, vma, true); + folio_add_file_rmap_pmd(folio, new, vma); } - VM_BUG_ON(pmd_write(pmde) && PageAnon(new) && !PageAnonExclusive(new)); + VM_BUG_ON(pmd_write(pmde) && folio_test_anon(folio) && !PageAnonExclusive(new)); set_pmd_at(mm, haddr, pvmw->pmd, pmde); /* No need to invalidate - it was non-present before */