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: 120263 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2314211vqm; Thu, 13 Jul 2023 23:46:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlGX1nmLk81EFFaA10Y2E0tYMJBfgNpImOx+sfKwdnfJ7sgK3NShlq4jdi9htcklE30YK3Rl X-Received: by 2002:a05:6a00:2da1:b0:682:93ce:4825 with SMTP id fb33-20020a056a002da100b0068293ce4825mr2657434pfb.3.1689317180746; Thu, 13 Jul 2023 23:46:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689317180; cv=none; d=google.com; s=arc-20160816; b=y7FM1bS4R4MORXR45wWMB28U9q9F1HPaGvKVuXAMIVehtkGXo1dExf4M9V7qL5cX/C qUluFeKrR2XoC5ZEmpEryV2Mlh60LuV8wlHThDO7HZfoyXP2M7CxiIr2xTFDwUDGB9ZM uLUi+KZlhHbqFidnmMXKxAugj2JxT8WfZXqmyuLn+p4pxpFKZoE7E+BHsVxVRqAKdR8q XKmjOGTovXaSXzuOfw45808PkD5dhRrWcAyt4JayRgo05nqtbfKEneq/IPufLrZd8xIo nAX/9ariHZTXRnSqA3RTclWtNwHq/5rlEPxVLpqTu5hyAZ7acCzA1QUqzO6tzU1N1b5/ JNdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=AHkI2giHDsKIZxRKzgFwuXReVNh5mYdqiebeQG/d3gk=; fh=QRPxubANnag6m76+0c84Pc1TOvrxn0ZaUbkL/OU3G4w=; b=PyaHupqd4xoxJb0wdylNqxIIOYYLOgKDEm/987hMUwt4D4Gp610zbrnnplgVcfcnbH x6KCOpMEijx+W+0XwtDoavX3eOpjeaIfo8K8emwCoAghnNtvzIlqEbD3dNg3aiqoNQkw kJBVoFLOD43KUjg11Cv88LJSjTQbd7Ex61LAifGm62Xs1lkgqCa9LUk2kAUitzVgHpVj 9g7F0Z0fnzQ3JaE8GZ+kZKw1OlItNjZUzDWiVCQnzEvqgPNLB+9UQzd91TI0pCh35oZS Qdh2y3pkeVNIr5eL6MXSDl98RFpmlyG86KNN3Mn/UeQke8IJlYWOw3o9CVmafpyj9u1R Bx+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bu3-20020a056a00410300b00666b1fb841dsi6460651pfb.7.2023.07.13.23.46.07; Thu, 13 Jul 2023 23:46:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234918AbjGNGOx (ORCPT + 99 others); Fri, 14 Jul 2023 02:14:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234757AbjGNGOv (ORCPT ); Fri, 14 Jul 2023 02:14:51 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0D8602680 for ; Thu, 13 Jul 2023 23:14:48 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771377451911547787 X-GMAIL-MSGID: 1771377451911547787 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.