From patchwork Thu Aug 29 16:56:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13783454 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 0B4DFC87FC8 for ; Thu, 29 Aug 2024 16:57:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 939956B0089; Thu, 29 Aug 2024 12:57:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E89E6B008A; Thu, 29 Aug 2024 12:57:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7AFE86B008C; Thu, 29 Aug 2024 12:57:09 -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 5B0E26B0089 for ; Thu, 29 Aug 2024 12:57:09 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BBC0B160DC4 for ; Thu, 29 Aug 2024 16:57:08 +0000 (UTC) X-FDA: 82505888136.24.EAEA0AC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 153D34000E for ; Thu, 29 Aug 2024 16:57:06 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Knp5avh+; spf=pass (imf01.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724950556; 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=2JqLQO5zRqaD9D1zDEVy24po9QCWNVhICktX5RsFGi4=; b=WqZv0+yxssChCa7e+aMYoeMRWTNsPXyDW9ErWQAeGi+8SEkS6xVhly5SsBhY7JwIRyJFfx wLRrxNMjdherYla6L2QwNuTXo5M1wFkg0L0nLUIE59lTQ6ynWpMKbNf5BkpIzlHcbeRUHW ILIABHgac358MJNvbRAAGI9tTQKYKO4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Knp5avh+; spf=pass (imf01.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724950556; a=rsa-sha256; cv=none; b=PcBcgN1ap16quuJdlbXLjtqrNXBMpowhEvuvxLYti7HFiRfo8V0XZxDh7pc1AA0d3sFeXH ooh6cWduoeHL8B/HofLVja1iVR3zNkwfQty9H681Migm7TPb3jSoqGIbHCKeSFQlbzhSr3 PXYdf8G1eDsD+v9qt6nx+kttajq5IS4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724950626; 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=2JqLQO5zRqaD9D1zDEVy24po9QCWNVhICktX5RsFGi4=; b=Knp5avh+Fzc2Ehz5rv0fp2SWyfNe8dAQdUkFY5196vKlM+KbQKd9gcPTdTPWXAE2SLoDN9 7FQP9tdgQvmW4frE/a48ZFJs+GM8Fyb85yFxwalvU1yCrv+i5g3hVAnsKHf7/7eu9JpNYD HMFdZbvBdBcdN1pLecUaRMpMWaxA/X0= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-654-Dwmx9zCBO_qNwGe7_gEFEw-1; Thu, 29 Aug 2024 12:57:03 -0400 X-MC-Unique: Dwmx9zCBO_qNwGe7_gEFEw-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8FBF21955D52; Thu, 29 Aug 2024 16:56:58 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.245]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 02D9E1955F21; Thu, 29 Aug 2024 16:56:47 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, cgroups@vger.kernel.org, x86@kernel.org, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , "Matthew Wilcox (Oracle)" , Tejun Heo , Zefan Li , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen Subject: [PATCH v1 01/17] mm: factor out large folio handling from folio_order() into folio_large_order() Date: Thu, 29 Aug 2024 18:56:04 +0200 Message-ID: <20240829165627.2256514-2-david@redhat.com> In-Reply-To: <20240829165627.2256514-1-david@redhat.com> References: <20240829165627.2256514-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Stat-Signature: 3ujdrcjwutbhy14crgy8tqy58itmpsic X-Rspam-User: X-Rspamd-Queue-Id: 153D34000E X-Rspamd-Server: rspam02 X-HE-Tag: 1724950626-542892 X-HE-Meta: U2FsdGVkX1/Hk4LQaD5BC9WbWwyE1MTQiMv+6dkqz7Vf95RtcJhVKoBFuFJJ39GpTzEyEZRXO27Epps1rx1Q4prijOpgMF4HoPfF88Glyu0U6fnJJXL+84635U1Hgvu0IEYgATRpxEXBj0U3FPFK6TTudtB1J62SJFt+WGxRctM2d2AcEllbNn1NnTgWVIU+roRQxhaRd/+LhzIT6Jr3NqhrEGvgxeE1SRQMhyO3MB2dvS/QouJXZ2yiD2rtF4w355zKxvCAemv2xrLEWEkqwDo6RUkjLeCLXg7C2PX8KicuRtzclvF56lnNUjfPmND4tBUCszoDpK8X6qZgW25XmfKp134nk5dlo3gnDtlN2IFX/XxjxsxygbQGvQCysUhuy4+MYmgiX+HL9QzkGzaoAvw2ANTICUpvfleF1btpHS+KiRCIEC6TgDDNSezTC9Mv/3ioMHcwP+fmO13o7iueRHRahnXoMSWFsN6RCF8S0Pi96/0AJJ9/Q2gkPmlMbN6j3/AUDws1wWOXqWLVckSGsbkbKaJ+qkjtudr57GHVbccjfZv8FpAbyv+WYXkcCcrzZGBYKxWlQQldyARmCMZ8T1xPFcm77yiFx7Rk3UVD/b1iZy+2q9Ua9KHqr5J/9UCU2AmYa9Jw1gCD17Rd3dgNZg/pN+iTI+i6kkXK+3XxzFD2JDnQV++7kl6yFUAJ+qnwkUCLKUFFQ3lIx2afOTd2Rq6v3DnawpatzEZySHdHfHhzsucILE/yUnBbDryXGTPINNaCZl15WKB5CR2ySgzP5InuJcuMdK3GlzYu8pfZmMNmzEbeanPttT45aWADle8P0d5FOa6Ujmpdsv1MXYZWlyU4J6ALDIWPVOpcpbb37o04q0KPgt7hFE+7P4hW2oNSG7VG+/RyWGjfNcuuea7l9VnM2hr4+2ZcLD87m90JrvZuT1t0Ww2Li2N8QvftcW0jqgvQkl3272lbVzbyWN4 fIRIYmVH 1j+8VDminCHoxIMxy1kzgt7oVPs7yS0viRz2zpMKR1bHyCn/gp6gUOEXUS8/GjscMn9DDRC4k9+nt5FErSN+xx+N17g/xo3rD+/n5meeGdesgB6dvPaAbJq7OrdXYirbTeza1TxiB9Q/4aoGnwAJb2s4hB0q76mf6Up/zXDvs4nMDanb+We5pEhZ86b2D5K9SE7W4vj1BuPUC8JFXF1BXXUxfd7g7yQ/PS6E9kAXKcLPvxA1FAWkqOkXbBTBGB1UFzWWhN013TFoVtbW4Z4O85BIweqqiX4XTP1RSZ13RiShQmipw6fFf+8ZNw+54MT097ptFxt/byvBLezip/rBJ2iHwocxmaPZkDvC5SayGFTs5I9kCycNv68R3zw== 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 factor it out into a simple helper function. This helper will also come in handy when working with code where we know that our folio is large. Signed-off-by: David Hildenbrand Reviewed-by: Lance Yang Reviewed-by: Kirill A. Shutemov --- include/linux/mm.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index b31d4bdd65ad5..3c6270f87bdc3 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1071,6 +1071,11 @@ int vma_is_stack_for_current(struct vm_area_struct *vma); struct mmu_gather; struct inode; +static inline unsigned int folio_large_order(const struct folio *folio) +{ + return folio->_flags_1 & 0xff; +} + /* * compound_order() can be called without holding a reference, which means * that niceties like page_folio() don't work. These callers should be @@ -1084,7 +1089,7 @@ static inline unsigned int compound_order(struct page *page) if (!test_bit(PG_head, &folio->flags)) return 0; - return folio->_flags_1 & 0xff; + return folio_large_order(folio); } /** @@ -1100,7 +1105,7 @@ static inline unsigned int folio_order(const struct folio *folio) { if (!folio_test_large(folio)) return 0; - return folio->_flags_1 & 0xff; + return folio_large_order(folio); } #include @@ -2035,7 +2040,7 @@ static inline long folio_nr_pages(const struct folio *folio) #ifdef CONFIG_64BIT return folio->_folio_nr_pages; #else - return 1L << (folio->_flags_1 & 0xff); + return 1L << folio_large_order(folio); #endif } @@ -2060,7 +2065,7 @@ static inline unsigned long compound_nr(struct page *page) #ifdef CONFIG_64BIT return folio->_folio_nr_pages; #else - return 1L << (folio->_flags_1 & 0xff); + return 1L << folio_large_order(folio); #endif }