From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 1BE14C433DB for ; Sat, 23 Jan 2021 03:17:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D64A820874 for ; Sat, 23 Jan 2021 03:17:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726593AbhAWDRX (ORCPT ); Fri, 22 Jan 2021 22:17:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726413AbhAWDRL (ORCPT ); Fri, 22 Jan 2021 22:17:11 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FFD3C061786 for ; Fri, 22 Jan 2021 19:16:23 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id r4so4342041pls.11 for ; Fri, 22 Jan 2021 19:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=C9os8STP6+MhnEh2q97mBClktafIxYQKkBXeyVRcYes=; b=Q8iczL3HgBNt3qX4PHjdYbHrZaSY+Naqd9Hvn6oN4uVyhXVGS6FoaQ5+hXZtc54bg6 58MdHqBte6IB9nwIvr8+aOpt82ecOapAC1GoKCw1iwdE3YVSkfYv3zVbYDuSOhmpqRxF ebjw6PQZMK9p2G5nBSoZtn4VhBUbqeI+0uWPv3Q3Z4KwZsdXLbkx1juCE0IzGcE9mA1z kmY7r2G2lX999mQRAW0GpLReB3cSeFBcuGa/oYWOA9xcxj05szfgnJ8erG2/e9xoSc3Y 4OhmLDMdTwt0OiEcBR+x04QMuU5R/cA1y1Dl2sMg88OVLrw9PEBhUDOD00MbcQmt8lb5 WyyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=C9os8STP6+MhnEh2q97mBClktafIxYQKkBXeyVRcYes=; b=h45k8O8TOb+g3UhQs15QUz7XLw58qEln0CRdWRDl7sqdw+zG2jT0i/PKzwJtAuuLaa XWtWN4srskMV1qa98xZ+j8XAiHN7RgCG7ac4fdUoCEM0WynEDHJzffsoa9MQGS1cVRMX kt0FAMA9SS2wGoChORLfihE56SJgmQetHkV920e/bL73gXi6DK3qaREwBZoj5wnd8LoF GPOewp5np3lFTlUaTxK86ROc4C2BtbZKt1oTi4uuMHpeNq1UzhOkRqg48sqRMlRCcQYK Eg9HIWpPgBxQ4Otd9iDNSR1/rtq6emCDOARC7GJ+X9sb/PgX6kCD27u2C22UPm+shZYy 047A== X-Gm-Message-State: AOAM530Gq/GdGrIGYR91z78os6InZh/+fOQ/l1Igeuc/ehCuJUn2h9V4 fqB7x4USc/7mgPNK6tErcxHWRlClnNZiU+8O6StiKQ== X-Google-Smtp-Source: ABdhPJy46rOxqyIO8KfIUJR0V+0IuifiGCqxYbu0rnc+0P2fVAFFGUNTGJox09tu6iF1s+MIjUotZHa8Z7sXFo7GA74= X-Received: by 2002:a17:90b:46d7:: with SMTP id jx23mr8858544pjb.147.1611371782931; Fri, 22 Jan 2021 19:16:22 -0800 (PST) MIME-Version: 1.0 References: <20210122195231.324857-1-mike.kravetz@oracle.com> <20210122195231.324857-5-mike.kravetz@oracle.com> In-Reply-To: <20210122195231.324857-5-mike.kravetz@oracle.com> From: Muchun Song Date: Sat, 23 Jan 2021 11:15:46 +0800 Message-ID: Subject: Re: [External] [PATCH v3 4/5] hugetlb: convert PageHugeTemporary() to HPageTemporary flag To: Mike Kravetz Cc: LKML , Linux Memory Management List , Michal Hocko , Naoya Horiguchi , David Hildenbrand , Oscar Salvador , Matthew Wilcox , Miaohe Lin , Andrew Morton Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 23, 2021 at 3:55 AM Mike Kravetz wrote: > > X-Gm-Spam: 0 > X-Gm-Phishy: 0 > > Use new hugetlb specific HPageTemporary flag to replace the > PageHugeTemporary() interfaces. PageHugeTemporary does contain > a PageHuge() check. However, this interface is only used within > hugetlb code where we know we are dealing with a hugetlb page. > Therefore, the check can be eliminated. > > Signed-off-by: Mike Kravetz > Reviewed-by: Oscar Salvador Reviewed-by: Muchun Song > --- > include/linux/hugetlb.h | 6 ++++++ > mm/hugetlb.c | 36 +++++++----------------------------- > 2 files changed, 13 insertions(+), 29 deletions(-) > > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h > index cd1960541f2a..3c86c3a0e144 100644 > --- a/include/linux/hugetlb.h > +++ b/include/linux/hugetlb.h > @@ -483,10 +483,15 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, > * HPG_migratable - Set after a newly allocated page is added to the page > * cache and/or page tables. Indicates the page is a candidate for > * migration. > + * HPG_temporary - - Set on a page that is temporarily allocated from the buddy > + * allocator. Typically used for migration target pages when no pages > + * are available in the pool. The hugetlb free page path will > + * immediately free pages with this flag set to the buddy allocator. > */ > enum hugetlb_page_flags { > HPG_restore_reserve = 0, > HPG_migratable, > + HPG_temporary, > __NR_HPAGEFLAGS, > }; > > @@ -530,6 +535,7 @@ static inline void ClearHPage##uname(struct page *page) \ > */ > HPAGEFLAG(RestoreReserve, restore_reserve) > HPAGEFLAG(Migratable, migratable) > +HPAGEFLAG(Temporary, temporary) > > #ifdef CONFIG_HUGETLB_PAGE > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 4da1a29ac5e2..70ffa1027988 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1353,28 +1353,6 @@ struct hstate *size_to_hstate(unsigned long size) > return NULL; > } > > -/* > - * Internal hugetlb specific page flag. Do not use outside of the hugetlb > - * code > - */ > -static inline bool PageHugeTemporary(struct page *page) > -{ > - if (!PageHuge(page)) > - return false; > - > - return (unsigned long)page[2].mapping == -1U; > -} > - > -static inline void SetPageHugeTemporary(struct page *page) > -{ > - page[2].mapping = (void *)-1U; > -} > - > -static inline void ClearPageHugeTemporary(struct page *page) > -{ > - page[2].mapping = NULL; > -} > - > static void __free_huge_page(struct page *page) > { > /* > @@ -1422,9 +1400,9 @@ static void __free_huge_page(struct page *page) > if (restore_reserve) > h->resv_huge_pages++; > > - if (PageHugeTemporary(page)) { > + if (HPageTemporary(page)) { > list_del(&page->lru); > - ClearPageHugeTemporary(page); > + ClearHPageTemporary(page); > update_and_free_page(h, page); > } else if (h->surplus_huge_pages_node[nid]) { > /* remove the page from active list */ > @@ -1860,7 +1838,7 @@ static struct page *alloc_surplus_huge_page(struct hstate *h, gfp_t gfp_mask, > * codeflow > */ > if (h->surplus_huge_pages >= h->nr_overcommit_huge_pages) { > - SetPageHugeTemporary(page); > + SetHPageTemporary(page); > spin_unlock(&hugetlb_lock); > put_page(page); > return NULL; > @@ -1891,7 +1869,7 @@ static struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask, > * We do not account these pages as surplus because they are only > * temporary and will be released properly on the last reference > */ > - SetPageHugeTemporary(page); > + SetHPageTemporary(page); > > return page; > } > @@ -5612,12 +5590,12 @@ void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason) > * here as well otherwise the global surplus count will not match > * the per-node's. > */ > - if (PageHugeTemporary(newpage)) { > + if (HPageTemporary(newpage)) { > int old_nid = page_to_nid(oldpage); > int new_nid = page_to_nid(newpage); > > - SetPageHugeTemporary(oldpage); > - ClearPageHugeTemporary(newpage); > + SetHPageTemporary(oldpage); > + ClearHPageTemporary(newpage); > > spin_lock(&hugetlb_lock); > if (h->surplus_huge_pages_node[old_nid]) { > -- > 2.29.2 > From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 B5F24C433DB for ; Sat, 23 Jan 2021 03:16:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 13C2E23B1B for ; Sat, 23 Jan 2021 03:16:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13C2E23B1B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2945B6B0005; Fri, 22 Jan 2021 22:16:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2453D6B0007; Fri, 22 Jan 2021 22:16:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E7936B0008; Fri, 22 Jan 2021 22:16:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0215.hostedemail.com [216.40.44.215]) by kanga.kvack.org (Postfix) with ESMTP id EAEE56B0005 for ; Fri, 22 Jan 2021 22:16:27 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A63CE824999B for ; Sat, 23 Jan 2021 03:16:27 +0000 (UTC) X-FDA: 77735576814.29.rock16_0610a0f27571 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 87F451801A810 for ; Sat, 23 Jan 2021 03:16:27 +0000 (UTC) X-HE-Tag: rock16_0610a0f27571 X-Filterd-Recvd-Size: 7905 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Sat, 23 Jan 2021 03:16:27 +0000 (UTC) Received: by mail-pl1-f172.google.com with SMTP id 31so4345733plb.10 for ; Fri, 22 Jan 2021 19:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=C9os8STP6+MhnEh2q97mBClktafIxYQKkBXeyVRcYes=; b=Q8iczL3HgBNt3qX4PHjdYbHrZaSY+Naqd9Hvn6oN4uVyhXVGS6FoaQ5+hXZtc54bg6 58MdHqBte6IB9nwIvr8+aOpt82ecOapAC1GoKCw1iwdE3YVSkfYv3zVbYDuSOhmpqRxF ebjw6PQZMK9p2G5nBSoZtn4VhBUbqeI+0uWPv3Q3Z4KwZsdXLbkx1juCE0IzGcE9mA1z kmY7r2G2lX999mQRAW0GpLReB3cSeFBcuGa/oYWOA9xcxj05szfgnJ8erG2/e9xoSc3Y 4OhmLDMdTwt0OiEcBR+x04QMuU5R/cA1y1Dl2sMg88OVLrw9PEBhUDOD00MbcQmt8lb5 WyyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=C9os8STP6+MhnEh2q97mBClktafIxYQKkBXeyVRcYes=; b=b67JboyfAu7vAkwWDMpd1WL3ED8FFCd+8H1US2X35i4hr3i2afUCvR3cEp2RsvXqdG fcQEK5IKME78++cAvZXroIFcGKsVMbiIxFsSbKH2AdcYTFfy5B1OE87EuWRrrlP+I20+ OuSMTuqv88u1HSqjtzrB9LfZVH1dyb+i/g/NPKir+lFYMM7euv8dOOZgnKg4521lDnR8 paavR0e4dHAjOltKCB+hZetzHGu3JZD7k+86KZm+mRbg3PTVya6dphibV9ydV8ZQ+sQK 4K4arEk63Uy4tkH+sjtXtpEl2MiEh4ixlqwkN/tpZVUCFPSj44lRcT5vaK1whHiisdmw QFbQ== X-Gm-Message-State: AOAM531zDXlvjVjgOrkAPJiI5CfytSP/uaIS6SgtXd5FEhQGm/Oymrvx D3SJrL17ApRg3pMWUho7hvphAFOOVVGGQDZDBemBQoJoXE2RlA== X-Google-Smtp-Source: ABdhPJy46rOxqyIO8KfIUJR0V+0IuifiGCqxYbu0rnc+0P2fVAFFGUNTGJox09tu6iF1s+MIjUotZHa8Z7sXFo7GA74= X-Received: by 2002:a17:90b:46d7:: with SMTP id jx23mr8858544pjb.147.1611371782931; Fri, 22 Jan 2021 19:16:22 -0800 (PST) MIME-Version: 1.0 References: <20210122195231.324857-1-mike.kravetz@oracle.com> <20210122195231.324857-5-mike.kravetz@oracle.com> In-Reply-To: <20210122195231.324857-5-mike.kravetz@oracle.com> From: Muchun Song Date: Sat, 23 Jan 2021 11:15:46 +0800 Message-ID: Subject: Re: [External] [PATCH v3 4/5] hugetlb: convert PageHugeTemporary() to HPageTemporary flag To: Mike Kravetz Cc: LKML , Linux Memory Management List , Michal Hocko , Naoya Horiguchi , David Hildenbrand , Oscar Salvador , Matthew Wilcox , Miaohe Lin , Andrew Morton Content-Type: text/plain; charset="UTF-8" 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: On Sat, Jan 23, 2021 at 3:55 AM Mike Kravetz wrote: > > X-Gm-Spam: 0 > X-Gm-Phishy: 0 > > Use new hugetlb specific HPageTemporary flag to replace the > PageHugeTemporary() interfaces. PageHugeTemporary does contain > a PageHuge() check. However, this interface is only used within > hugetlb code where we know we are dealing with a hugetlb page. > Therefore, the check can be eliminated. > > Signed-off-by: Mike Kravetz > Reviewed-by: Oscar Salvador Reviewed-by: Muchun Song > --- > include/linux/hugetlb.h | 6 ++++++ > mm/hugetlb.c | 36 +++++++----------------------------- > 2 files changed, 13 insertions(+), 29 deletions(-) > > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h > index cd1960541f2a..3c86c3a0e144 100644 > --- a/include/linux/hugetlb.h > +++ b/include/linux/hugetlb.h > @@ -483,10 +483,15 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, > * HPG_migratable - Set after a newly allocated page is added to the page > * cache and/or page tables. Indicates the page is a candidate for > * migration. > + * HPG_temporary - - Set on a page that is temporarily allocated from the buddy > + * allocator. Typically used for migration target pages when no pages > + * are available in the pool. The hugetlb free page path will > + * immediately free pages with this flag set to the buddy allocator. > */ > enum hugetlb_page_flags { > HPG_restore_reserve = 0, > HPG_migratable, > + HPG_temporary, > __NR_HPAGEFLAGS, > }; > > @@ -530,6 +535,7 @@ static inline void ClearHPage##uname(struct page *page) \ > */ > HPAGEFLAG(RestoreReserve, restore_reserve) > HPAGEFLAG(Migratable, migratable) > +HPAGEFLAG(Temporary, temporary) > > #ifdef CONFIG_HUGETLB_PAGE > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 4da1a29ac5e2..70ffa1027988 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1353,28 +1353,6 @@ struct hstate *size_to_hstate(unsigned long size) > return NULL; > } > > -/* > - * Internal hugetlb specific page flag. Do not use outside of the hugetlb > - * code > - */ > -static inline bool PageHugeTemporary(struct page *page) > -{ > - if (!PageHuge(page)) > - return false; > - > - return (unsigned long)page[2].mapping == -1U; > -} > - > -static inline void SetPageHugeTemporary(struct page *page) > -{ > - page[2].mapping = (void *)-1U; > -} > - > -static inline void ClearPageHugeTemporary(struct page *page) > -{ > - page[2].mapping = NULL; > -} > - > static void __free_huge_page(struct page *page) > { > /* > @@ -1422,9 +1400,9 @@ static void __free_huge_page(struct page *page) > if (restore_reserve) > h->resv_huge_pages++; > > - if (PageHugeTemporary(page)) { > + if (HPageTemporary(page)) { > list_del(&page->lru); > - ClearPageHugeTemporary(page); > + ClearHPageTemporary(page); > update_and_free_page(h, page); > } else if (h->surplus_huge_pages_node[nid]) { > /* remove the page from active list */ > @@ -1860,7 +1838,7 @@ static struct page *alloc_surplus_huge_page(struct hstate *h, gfp_t gfp_mask, > * codeflow > */ > if (h->surplus_huge_pages >= h->nr_overcommit_huge_pages) { > - SetPageHugeTemporary(page); > + SetHPageTemporary(page); > spin_unlock(&hugetlb_lock); > put_page(page); > return NULL; > @@ -1891,7 +1869,7 @@ static struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask, > * We do not account these pages as surplus because they are only > * temporary and will be released properly on the last reference > */ > - SetPageHugeTemporary(page); > + SetHPageTemporary(page); > > return page; > } > @@ -5612,12 +5590,12 @@ void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason) > * here as well otherwise the global surplus count will not match > * the per-node's. > */ > - if (PageHugeTemporary(newpage)) { > + if (HPageTemporary(newpage)) { > int old_nid = page_to_nid(oldpage); > int new_nid = page_to_nid(newpage); > > - SetPageHugeTemporary(oldpage); > - ClearPageHugeTemporary(newpage); > + SetHPageTemporary(oldpage); > + ClearHPageTemporary(newpage); > > spin_lock(&hugetlb_lock); > if (h->surplus_huge_pages_node[old_nid]) { > -- > 2.29.2 >