From patchwork Tue Jun 8 18:27:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 457685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D404C48BCF for ; Tue, 8 Jun 2021 18:48:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0FD0C61949 for ; Tue, 8 Jun 2021 18:48:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234371AbhFHSuq (ORCPT ); Tue, 8 Jun 2021 14:50:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:44434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235615AbhFHSrI (ORCPT ); Tue, 8 Jun 2021 14:47:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4177761406; Tue, 8 Jun 2021 18:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623177479; bh=BtUMkyt4Ii44XjnnzVn2lkfQX5Yt3RcOKD83rvHMfwU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uJ5V0M499dVw/fEoAIYOEqUD9x2ZJblacjDMKxS0f5CXm9Sh2XjpLmuwZCHf+fDpv 9uMwtUS3fJT8slXLBim87uDPX8fJNSydMqUnlTt5Hr5Gw3skCAHakK+/oS2mCvUnQS sZw8v8xrcw6M6tf6EYrD3RDMaO8LFOXbxa1nFCNc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , "Matthew Wilcox (Oracle)" , Andrew Morton , William Kucharski , Zi Yan , David Hildenbrand , Mike Kravetz , "Kirill A. Shutemov" , Linus Torvalds Subject: [PATCH 5.4 65/78] mm: add thp_order Date: Tue, 8 Jun 2021 20:27:34 +0200 Message-Id: <20210608175937.462236794@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175935.254388043@linuxfoundation.org> References: <20210608175935.254388043@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: "Matthew Wilcox (Oracle)" commit 6ffbb45826f5d9ae09aa60cd88594b7816c96190 upstream This function returns the order of a transparent huge page. It compiles to 0 if CONFIG_TRANSPARENT_HUGEPAGE is disabled. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Andrew Morton Reviewed-by: William Kucharski Reviewed-by: Zi Yan Cc: David Hildenbrand Cc: Mike Kravetz Cc: "Kirill A. Shutemov" Link: http://lkml.kernel.org/r/20200629151959.15779-4-willy@infradead.org Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- include/linux/huge_mm.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -231,6 +231,19 @@ static inline spinlock_t *pud_trans_huge else return NULL; } + +/** + * thp_order - Order of a transparent huge page. + * @page: Head page of a transparent huge page. + */ +static inline unsigned int thp_order(struct page *page) +{ + VM_BUG_ON_PGFLAGS(PageTail(page), page); + if (PageHead(page)) + return HPAGE_PMD_ORDER; + return 0; +} + static inline int hpage_nr_pages(struct page *page) { if (unlikely(PageTransHuge(page))) @@ -290,6 +303,12 @@ static inline struct list_head *page_def #define HPAGE_PUD_MASK ({ BUILD_BUG(); 0; }) #define HPAGE_PUD_SIZE ({ BUILD_BUG(); 0; }) +static inline unsigned int thp_order(struct page *page) +{ + VM_BUG_ON_PGFLAGS(PageTail(page), page); + return 0; +} + #define hpage_nr_pages(x) 1 static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma)