From patchwork Fri Apr 12 19:35:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13628292 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 5C78EC4345F for ; Fri, 12 Apr 2024 19:51:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E65C66B0092; Fri, 12 Apr 2024 15:51:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E15736B0093; Fri, 12 Apr 2024 15:51:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDC686B0095; Fri, 12 Apr 2024 15:51:46 -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 B223F6B0092 for ; Fri, 12 Apr 2024 15:51:46 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 39B3680FF9 for ; Fri, 12 Apr 2024 19:51:46 +0000 (UTC) X-FDA: 82001925012.12.31A9B17 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 8FCA3A0002 for ; Fri, 12 Apr 2024 19:51:44 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=PNxAq5Mv; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712951504; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5zr8LOSgGt0Q2WtuiahmLM3vS/KNbcf3FZTCnvUcXd4=; b=gBh6NBKugwWnzLNkT2liujJQQai7bzdxh/Dn/e74W8n/y2t24fa00aHbHhHKWLQnblDkp4 l9StlZsL9+YWF+WU6S8/WS2HNGDboGAb35AVLWVGcLaeZ7+WOyZsQcGTd2jZ8gkZB27uJS v2ivC7uuelpsSpNOjCxMqVRCbM6KB0A= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=PNxAq5Mv; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712951504; a=rsa-sha256; cv=none; b=E5iPR5VU/DVT7gMV6RxMfW9QoIk+F0wm4sh5YQh/Yz0d8ndhm+4RXO2GE40vEBxM92sKc4 M+CRtW1hcRaDAFi30YUn79MLwei88pLWDwHh2qoGYQBYa2a01DtozyFuJ2y36A4HhDrdxx Pyek9pTsP3Kyum1p52RX6tOZriY/8eU= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=5zr8LOSgGt0Q2WtuiahmLM3vS/KNbcf3FZTCnvUcXd4=; b=PNxAq5Mve0YRpg29kn/T9wTwDO 1pbW1J/Mj+1B1Wj5z8O4Muc5lGHv8d++7YcRafh8umOlo8NdacQ3/5Zb7cOL7GcOVxzYsFS9Appcc g446hiW6iDHfcJxIrH7jK15aElXYpSw+333gV55Vt1MY+cenL89tPf/0ECVi1AG/9FujLjwkehRbK 9YdtS64d9qgnQ86l4ZB4T1wVbCdN6XzY8x1/NfXQ1hlcFgx3qHGH4xcKNY5As2e6D2uhcDrj+AcPc BdPDC05CI3BMy+QB+0i3kPmK/S2kdF2PTv6M3NifbW22o970G6/k+QG9NDTOaHVGC2tOwAVAJAXJ/ vI31Ddbg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvMg3-00000009t9o-4Buz; Fri, 12 Apr 2024 19:35:12 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, =?utf-8?q?Jane_Chu=C2=A0?= , Oscar Salvador Subject: [PATCH v3 06/11] mm: Convert hugetlb_page_mapping_lock_write to folio Date: Fri, 12 Apr 2024 20:35:03 +0100 Message-ID: <20240412193510.2356957-7-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412193510.2356957-1-willy@infradead.org> References: <20240412193510.2356957-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 118e1c4ezzguguxte3oii9ddh19gj7or X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8FCA3A0002 X-HE-Tag: 1712951504-700219 X-HE-Meta: U2FsdGVkX19VsAp209wKx5tY+NHxbREg29g8kyuGMyNw/Aiv454Nl/5k/3vLVNBM3SrcQhuVh+QtOB4EMLbrMa13A89cvaJWxm/77w0dwiC3LoZ/5t/5r5PZ4aJ+6VygV9Y8xin5xNCmAylKeQIMbM9ZN/LdLqM5ZtfkH+QV0hSchglnigvuxoNxIM0wMuPzRf4jpev9RGFVXZt/Fj2ftVMMx7im4xmUHN0PXUhv/711Yh4/z0h8PcIDXNv3tGLRVeQkWs1oF2Velcv50XJS27aM4L9u8L52POGPMByiWm3L7ejz6auuIE4b9RMMsLbeuAKJaZtg3uAEqsO7SSgSiXUJQwcuBOysv/1ofDWRWJF5YXZXuh1tvBG7LYTggEQ1vrP3/skrA+ue31zwrXUd9229EUL3qKp4272rORkKQlkPxkX8Z9bKiclQTVpPiF4hA57ZldUrLPwNTRApGjDv07wqSOCuMi27BpIK3ORdne0T1UvAK9R37kkeFHkuHnX2mdi5Y3VQ9wOUNvWC/Czia39aCLIFAjNOYF6M6T9tfCMuIMlF5NWDIkWMVHdySYEte699yhwIUy7rz+RBtrkCKgbAEXO1EyOF52++xSUGIXWZVrBiWBaoHL/M4UHlGXC7owBkM+MhCEzXphchoRDWDDMNt0zKGgr1ytolsYGmKSARPdTKtVOHyV+58tzpGcOVMJZTwGyEr7HVxDyGkN/OxeI6P6AmKTvRym6mlMnI5Y7j8G7N7oxt5CkQdOquCvIh8/uCxao0ObcdsPbjPO8maDPiViQKhpnJfrgcGAq6YXIB9kbjFB8Sm7BG7KPyLLQRT54wFEgRLtw5KbBApg0UictlsL61rWxeHlDMOarhFJj/nEk4l/cDCCI4D8le0+NpUG2lFBtM6F05riodUXfvC4X2DzAUDilMI5oHkmQPJgg9MGCIg6+GDlrO7E1U+soPVUviKZxzrsf7P0i3H05 zNAx5+Pz 7LYFA0P5zg96vCLyxokRJpJOuRZymr8MRVFsIP/HrrKiQi6l4V2uGIceor6R4j/Byj3q9c94s4ujdfozy46E/b106yz/bzNubJ/Qy0xnfSviY3AwKZYQMpqRPNlmXsL3mTovEl5M2D5TcVF0KPcjnd6NvCM/hmWkwtUBjH7pq4ZJv5PVENvvPLWjvwucsU/1q47+Jkw7s22WuVSYny8q2Qc3SFgZ2SA5A2DKJyj0HzTQMgRkaPcqpholq7PLXKwpDdj3zkvMOUGjTJWzLIOktkzdJ6/Z2tXtWThnVqiUN8qtLbDP+R5rjaEzyPg== 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: The page is only used to get the mapping, so the folio will do just as well. Both callers already have a folio available, so this saves a call to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu  Reviewed-by: Oscar Salvador Acked-by: Miaohe Lin --- include/linux/hugetlb.h | 6 +++--- mm/hugetlb.c | 6 +++--- mm/memory-failure.c | 2 +- mm/migrate.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 8c97ac48ae6d..aaa11eeb939d 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -178,7 +178,7 @@ bool hugetlbfs_pagecache_present(struct hstate *h, struct vm_area_struct *vma, unsigned long address); -struct address_space *hugetlb_page_mapping_lock_write(struct page *hpage); +struct address_space *hugetlb_folio_mapping_lock_write(struct folio *folio); extern int sysctl_hugetlb_shm_group; extern struct list_head huge_boot_pages[MAX_NUMNODES]; @@ -297,8 +297,8 @@ static inline unsigned long hugetlb_total_pages(void) return 0; } -static inline struct address_space *hugetlb_page_mapping_lock_write( - struct page *hpage) +static inline struct address_space *hugetlb_folio_mapping_lock_write( + struct folio *folio) { return NULL; } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a8536349de13..001016993cca 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2155,13 +2155,13 @@ static bool prep_compound_gigantic_folio_for_demote(struct folio *folio, /* * Find and lock address space (mapping) in write mode. * - * Upon entry, the page is locked which means that page_mapping() is + * Upon entry, the folio is locked which means that folio_mapping() is * stable. Due to locking order, we can only trylock_write. If we can * not get the lock, simply return NULL to caller. */ -struct address_space *hugetlb_page_mapping_lock_write(struct page *hpage) +struct address_space *hugetlb_folio_mapping_lock_write(struct folio *folio) { - struct address_space *mapping = page_mapping(hpage); + struct address_space *mapping = folio_mapping(folio); if (!mapping) return mapping; diff --git a/mm/memory-failure.c b/mm/memory-failure.c index bf9da2b46426..52feaa9de9b4 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1618,7 +1618,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, * TTU_RMAP_LOCKED to indicate we have taken the lock * at this higher level. */ - mapping = hugetlb_page_mapping_lock_write(hpage); + mapping = hugetlb_folio_mapping_lock_write(folio); if (mapping) { try_to_unmap(folio, ttu|TTU_RMAP_LOCKED); i_mmap_unlock_write(mapping); diff --git a/mm/migrate.c b/mm/migrate.c index d87ce32645d4..fb0c83438fa8 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1425,7 +1425,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio, * semaphore in write mode here and set TTU_RMAP_LOCKED * to let lower levels know we have taken the lock. */ - mapping = hugetlb_page_mapping_lock_write(&src->page); + mapping = hugetlb_folio_mapping_lock_write(src); if (unlikely(!mapping)) goto unlock_put_anon;