From patchwork Mon Apr 8 19:42:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13621550 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 D1C49C67861 for ; Mon, 8 Apr 2024 19:42:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0293E6B0093; Mon, 8 Apr 2024 15:42:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF4436B0095; Mon, 8 Apr 2024 15:42:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBD896B0096; Mon, 8 Apr 2024 15:42:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id BFC906B0093 for ; Mon, 8 Apr 2024 15:42:53 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8B94B12013F for ; Mon, 8 Apr 2024 19:42:53 +0000 (UTC) X-FDA: 81987387426.13.1F21D57 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP id EFE4818000E for ; Mon, 8 Apr 2024 19:42:51 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="rZrv3CZ/"; dmarc=none; spf=none (imf16.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=1712605372; 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=g/vGJLoYxlPmulU4S77Y+SHZ4lO6tnjl8V7pbWs+uN4=; b=vs+oQn3N2TqFzbcvj1jCNJ3O35DNLacGlZ7oc3LHGmk6AN4W4b00sOIACVjfs9y8YHcDua MFbto3Mv9kiHZFMGCWY7qb3vDx2YE1aT9m5U7K6vpzFUminhR+BBqFBrdBWaIBfzHRnW4X hWQrkIhMem0pEw9KSxblJPnr2sCpZN0= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="rZrv3CZ/"; dmarc=none; spf=none (imf16.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=1712605372; a=rsa-sha256; cv=none; b=ZmEEWbNmKQw5vhv3drFhUp8BtviFTdrmPmHXFkRqo8BvNRJ8/2rHNfuu/86p4VJz9FDf2S 2FHbXwFMe+DvH/mpAhF0ToKwod6eCimJN4erXi3XiUikkFOjPP9oYnmTpGctwTxUcnHSvR OMuWvVnHEp147YEmmiDcqx1snUsS9FE= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=g/vGJLoYxlPmulU4S77Y+SHZ4lO6tnjl8V7pbWs+uN4=; b=rZrv3CZ/2P2oDMKsj6JOzjVr8L +MHrB56ugVAB/OrUv9wMfl4HKNoME79s2P19mFNgMH4xqYtRo1092mN7mxNZld1mqVJWNtliSz+mM eVK6d8VvTaL9+K4zY7a0eHmf3crTEV0IE/ob3MUOawzk/4rWC2ovPiI+2pFgELriFI3c20Sth+HqO D1E1gCBwT0J7sypc7WlMdg5nbSbGkgLD4aWfky90cfzAUDIZyn0/kAgFwfhC/nhec15AAYZ4ZHDMZ jjQUZEfVjK0UGYVd6qQJLfgYKN1+cBzRlGYruEKNuy+P+8VwqobCS/FQIZVEtnJRKkcZCRBUq3F9m kNMgYHuA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtut1-00000000UqJ-0fWh; Mon, 08 Apr 2024 19:42:35 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 06/11] mm: Convert hugetlb_page_mapping_lock_write to folio Date: Mon, 8 Apr 2024 20:42:24 +0100 Message-ID: <20240408194232.118537-7-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408194232.118537-1-willy@infradead.org> References: <20240408194232.118537-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: EFE4818000E X-Stat-Signature: smbsdwqckt7qkybmkufi3wm68ep1cppi X-HE-Tag: 1712605371-337075 X-HE-Meta: U2FsdGVkX18bN0AOgdNyXJH2zBWCHgVlOTecuy8y9rifHnulTTVgWyKdcnKK+G6gv32FJPe976hMg6HFOY3OHKveZ9ducURzlDtm+zaCWGJmYpUl9BSzmDWnk1CCiWuOHjW+PaQ0tm1uNUjeb1L7uzmuHz/xjpVn/7CGq/ZogrOgI8NtllLfFGvzq5nfbu9wrLsKpusMsTy0BOtyj3eq/SKvw+0ZpFkTC6XvGrE26JE18HtrbCn6ucA8A3qliebtsot04O7FtxfPXy7xa9z2cLn7UuikEshs8ddzrAnH6vF3AM2v1PbvL5oMq6qr1Syo4jyXjQMqd9WWrieFX0AFY/RzlbUMK2oNldF/gjydjwzC9/btmilAABjPeYHtIawD1rM7W1sSQctiY30Zqi+gt2Dm065dESvh5hVpcf/KOlkMoUXp/XMnJVpDK0c4NCdn7xcFXyAyqK/B+OMjcDU77SNkcU8FaxBIwQAdpo0LLpiEKuM574aT413doTD182Cf5Lm7Lp6BhlTBnOnnpY+VwA/xBtAx/MxEoZGvheOuyundtW1x/3Cp++2s/IFKQqQo41OG8LGUT1R2UioedB1SD93amP3H2IVN/UIf80OmLTIVf4nYHWDsQcJUu9jQYteyYwK1XxbOaMO5oB843bSCUBKZW2GH2D2pG2XDJwAhiAUnkyvSumffT3oUxZQDxiemObtH82MIw+gOqivwKv2btt9KyaSxnnpTl6PrjjNk4943IS7+dO3MwnDOQ6CbfHF29JCoECtZqW23iQp7W6BbJJZFmLTEsCvdPwz87D8akHHIDmu3G85JujQbmkHxn2pQdbHvCnf4VUqfvodMIpiqMyNUexvOaH6mFcw6FRNiKoFe5lSLYD2Dkba1EWyXRnfvXX8u6f6DDm83um6C235WocTRdWGfNaIugtYaCA9An2oREYkhL+WGXxrRoT0btOkjnGs+q+LLq6kdgfN0gZd o6kiwibO yQffVgSfyCL/5t48EzT1WEOzebClEPmhMCCnP9HY0miIXDMy+5khLWMGQPBDGMzvafSYVbxUTg6mPXvvfDKGmE0RSpZf39e6W5XPAfRDD2ynpsOtNp9n2//mqJ4fAKDwxIoqURu23e9xbKRw3/UlkrMvDuzisK2BbUtM8rBQ92sET4u9vxs21KoDZ90Q7QCT+kpfRjK9Bp52GlzPH1Q/ryMYdaHsQWcjlU1BXviVpUrzwodw6xxqstE5O/iDvGxDujJfP 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(). Acked-by: Miaohe Lin Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu  Reviewed-by: Oscar Salvador --- 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 3f3e62880279..bebf4c3a53ef 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 456c81fbf8f5..707c85303e88 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 2e64e132bba1..0a45fb7fb055 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1608,7 +1608,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 285072bca29c..f8da9b89e043 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;