From patchwork Fri Jul 14 06:14:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 13312975 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 7B995EB64DA for ; Fri, 14 Jul 2023 06:14:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1627490001C; Fri, 14 Jul 2023 02:14:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0ECDC900002; Fri, 14 Jul 2023 02:14:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF60B90001C; Fri, 14 Jul 2023 02:14:50 -0400 (EDT) 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 DDDB5900002 for ; Fri, 14 Jul 2023 02:14:50 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9FBC1AFAAF for ; Fri, 14 Jul 2023 06:14:50 +0000 (UTC) X-FDA: 81009203940.09.A036EC0 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf02.hostedemail.com (Postfix) with ESMTP id A896680013 for ; Fri, 14 Jul 2023 06:14:48 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689315289; a=rsa-sha256; cv=none; b=23deIBgslr6QEdKR39/dYcPMU6+txtz2c6hW0lDGTLpNgxkpDHw9T/PjYd2z3FWvyFedk7 IrWH2nRz5M7FguRnPNls8em/28xUo2lfynnlC+tzXuqsXOQQM6YefyY4HAF9oQp3VY1CIj NpTc9OH8eMQNoqJ/bMDj+ytaKnf2oOE= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689315289; 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; bh=AHkI2giHDsKIZxRKzgFwuXReVNh5mYdqiebeQG/d3gk=; b=S/TKVDKWMZzOg4x+EqLp4EJleqBlXta5UDofjc7moOpV7NNOdzAnUoWxM62GQE/QUgUTJb 5TmnN9WMDT46deB4v3R0Wsvti5OehHpuJuFwoJhouPhvMjSi+fYy1HkB95a1sDNoddziRh 0n/1PjvQVrhfrrzzbo1JfVpuMN4n9+E= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C25591570; Thu, 13 Jul 2023 23:15:29 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.49.147]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B3B4B3F73F; Thu, 13 Jul 2023 23:14:44 -0700 (PDT) From: Anshuman Khandual To: linux-mm@kvack.org Cc: Anshuman Khandual , Andrew Morton , "Matthew Wilcox (Oracle)" , "Kirill A. Shutemov" , Hugh Dickins , David Hildenbrand , linux-kernel@vger.kernel.org Subject: [PATCH] mm/rmap: Convert rmap_t into enum rmap_flags Date: Fri, 14 Jul 2023 11:44:38 +0530 Message-Id: <20230714061438.122391-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: A896680013 X-Stat-Signature: tsurhbg4d8msutaj4qeuafqea9tszyrp X-HE-Tag: 1689315288-686089 X-HE-Meta: U2FsdGVkX19Hvg+xmuMc0PY1p4LYW2YsAjVyXSvVwvtRCJfNtW0dQTlDhV4CeAvatRqNcpn2s2MeT/ZEL7Jx19cGOuF/oXexzl0bf7FPr2MJqJlWtxnQzEuaIsIsswcQapF++ahyWoLt28YQkMNL5wgiu/mwnUFK0elhwbuTgXdJExBR69+jm1m2wnyHaj9rehw4aYKTG8cpqp9Hz68UJymvxhvgIVUsxtUCc1RRaic9F2Kggz9DOEadRw71qOyqc/o63bhPjNTlO8IqzvlVCZmI0+GD2pfoprw3ybOba4bLs1PeaZv6airYAmSXBmhrdRX015m44nvIhyWI+0+3KnXBL47fRSdgckQlQlLL+I/x+XS4cnFKa8LtmCu03XXYdlo0a7cxEpEvyfz5GvDn9oAhByKNPIXa38AQPfkCGOwbjGLxiAT8J/XJLasuwZ0wL0MfnoHlrB4PLq48zm1tIMIt5UPvUI1usR5y/fX+UY/ei2++lOPJWfJLLkLHgxRQ0paA3I6wFBUrrOdhTLVhVtL1tM17Sf6Ug48K8XXDrppJG0U7fBmaVku+r18/r1nC4m4h9D/MeioEOIwsBUBjgfMryqL2q1G4aIRIdifLcfmGC77rTnwk1V4JjP++QpXhSA0y1OsA1yIQEg7ZJsld4KixMADMOmk/u9wG+nl+qByHhqadYt7cXTy4K4eZMXcaesOHexZ64iMSUgtWIuNw8+VKo3XSxQMEaGi6ok7KmPMeCPCxdhaaIWUEJo5hkL94Ugk9sKmoJ4b14fkUfuYRdtpdh68VVOGv3U2rCeSrjoeMzzN+LEnFj6H9ViDNk4Eal5Jm3PIbh5NmahPOHnOb980IDaAOPcwXTVKpdQvKDo2AKH3BgQxsxxG/+jIgKZDJJGUo3OsfIZ6Hb2lT/r3YxLhH0YPJUM/OH/orpIGhLPrisysDzYhuJve++2+ztGtTPs1jzRVoZKQFmwX3xa4 73zUwhwJ BBJoO5GW5yZKigCaH2qFQV+1S43LtP9DQH/kqGKU7Rop6XNOYt0Cdqwi/XLA3fNOaDK9P+PUOwvG9aUIjRUIRC0o7dsu6Ch/YvchJypReW4enDxhLnQ1OCOuaFLtRtyr01lCt30WBQHwwTwsLUOZeJlt7xWCVCTZc+JAdPlCPd89O6iczNPpVJnejMeiOoRlUj4OcV+c1DYSvNBhWsYQH6FIN6IKIWMvZG27DlS+fyT+Hn3xDpXve+j3RmGlk4NKdzn6UPkJR0x7cLR1lZFAA7Pt3AN9GgkTUUcX3Aa0Ged2WXyKgw36nv2CbCki0VPr77CxBPlSshatYiW+qy2EVueLUr2KLDR0aDN2TeujOamqt6FERW+Xi3ynRfY8G/P1X3qlrHAyMIKOUA7BfGDmt6rK1m5KqtaCekCl4SYMTLyXL1Bhwq0aEhEG2DD4V0hRiQC7CTrlt2BV3OnmfOHta7kvdXhLbzfhuEdnJZorutfl9vJTUi6vcBDZqFWNU7g2XUELj 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: rmap_t tracks bitwise positions for various page reverse map related flags. enum could provide more compact representation. This converts these flags into an enum listing, without any functional change. Cc: Andrew Morton Cc: "Matthew Wilcox (Oracle)" Cc: "Kirill A. Shutemov" Cc: Hugh Dickins Cc: David Hildenbrand Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- This applies on v6.5-rc1 include/linux/rmap.h | 26 +++++++------------------- mm/huge_memory.c | 2 +- mm/memory.c | 2 +- mm/migrate.c | 2 +- mm/rmap.c | 4 ++-- mm/swapfile.c | 2 +- 6 files changed, 13 insertions(+), 25 deletions(-) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index b87d01660412..aee6ee7ddac6 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -168,30 +168,18 @@ static inline void anon_vma_merge(struct vm_area_struct *vma, struct anon_vma *folio_get_anon_vma(struct folio *folio); -/* RMAP flags, currently only relevant for some anon rmap operations. */ -typedef int __bitwise rmap_t; - -/* - * No special request: if the page is a subpage of a compound page, it is - * mapped via a PTE. The mapped (sub)page is possibly shared between processes. - */ -#define RMAP_NONE ((__force rmap_t)0) - -/* The (sub)page is exclusive to a single process. */ -#define RMAP_EXCLUSIVE ((__force rmap_t)BIT(0)) - -/* - * The compound page is not mapped via PTEs, but instead via a single PMD and - * should be accounted accordingly. - */ -#define RMAP_COMPOUND ((__force rmap_t)BIT(1)) +enum rmap_flags { + RMAP_NONE = 0x0, /* No special request - (sub)page is mapped via a single PTE */ + RMAP_EXCLUSIVE = 0x1, /* The (sub)page is exclusive to a single process */ + RMAP_COMPOUND = 0x2, /* The compound page is mapped via a single PMD */ +}; /* * rmap interfaces called when adding or removing pte of page */ void page_move_anon_rmap(struct page *, struct vm_area_struct *); void page_add_anon_rmap(struct page *, struct vm_area_struct *, - unsigned long address, rmap_t flags); + unsigned long address, enum rmap_flags flags); void page_add_new_anon_rmap(struct page *, struct vm_area_struct *, unsigned long address); void folio_add_new_anon_rmap(struct folio *, struct vm_area_struct *, @@ -202,7 +190,7 @@ void page_remove_rmap(struct page *, struct vm_area_struct *, bool compound); void hugepage_add_anon_rmap(struct page *, struct vm_area_struct *, - unsigned long address, rmap_t flags); + unsigned long address, enum rmap_flags flags); void hugepage_add_new_anon_rmap(struct folio *, struct vm_area_struct *, unsigned long address); diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 965d845d73fc..79a790d1cfa8 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3297,7 +3297,7 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) pmde = pmd_mkdirty(pmde); if (PageAnon(new)) { - rmap_t rmap_flags = RMAP_COMPOUND; + enum rmap_flags rmap_flags = RMAP_COMPOUND; if (!is_readable_migration_entry(entry)) rmap_flags |= RMAP_EXCLUSIVE; diff --git a/mm/memory.c b/mm/memory.c index 01f39e8144ef..1710aa6826d4 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3717,7 +3717,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) struct folio *swapcache, *folio = NULL; struct page *page; struct swap_info_struct *si = NULL; - rmap_t rmap_flags = RMAP_NONE; + enum rmap_flags rmap_flags = RMAP_NONE; bool exclusive = false; swp_entry_t entry; pte_t pte; diff --git a/mm/migrate.c b/mm/migrate.c index 24baad2571e3..bdb73b11845a 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -186,7 +186,7 @@ static bool remove_migration_pte(struct folio *folio, DEFINE_FOLIO_VMA_WALK(pvmw, old, vma, addr, PVMW_SYNC | PVMW_MIGRATION); while (page_vma_mapped_walk(&pvmw)) { - rmap_t rmap_flags = RMAP_NONE; + enum rmap_flags rmap_flags = RMAP_NONE; pte_t old_pte; pte_t pte; swp_entry_t entry; diff --git a/mm/rmap.c b/mm/rmap.c index 0c0d8857dfce..4d4c821d8e56 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1213,7 +1213,7 @@ static void __page_check_anon_rmap(struct page *page, * (but PageKsm is never downgraded to PageAnon). */ void page_add_anon_rmap(struct page *page, struct vm_area_struct *vma, - unsigned long address, rmap_t flags) + unsigned long address, enum rmap_flags flags) { struct folio *folio = page_folio(page); atomic_t *mapped = &folio->_nr_pages_mapped; @@ -2539,7 +2539,7 @@ void rmap_walk_locked(struct folio *folio, struct rmap_walk_control *rwc) * RMAP_COMPOUND is ignored. */ void hugepage_add_anon_rmap(struct page *page, struct vm_area_struct *vma, - unsigned long address, rmap_t flags) + unsigned long address, enum rmap_flags flags) { struct folio *folio = page_folio(page); struct anon_vma *anon_vma = vma->anon_vma; diff --git a/mm/swapfile.c b/mm/swapfile.c index 8e6dde68b389..3a9b1d8b3151 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1788,7 +1788,7 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, inc_mm_counter(vma->vm_mm, MM_ANONPAGES); get_page(page); if (page == swapcache) { - rmap_t rmap_flags = RMAP_NONE; + enum rmap_flags rmap_flags = RMAP_NONE; /* * See do_swap_page(): PageWriteback() would be problematic.