Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp658686pxb; Thu, 15 Apr 2021 03:36:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZelKG2Xtesrem5DFDZxDkDqw4BDURIgmKZVEoooDk4XI8PwYUdqgc0oyJ+FlNw4Zqjtdi X-Received: by 2002:a63:1203:: with SMTP id h3mr2860767pgl.223.1618483018205; Thu, 15 Apr 2021 03:36:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618483018; cv=none; d=google.com; s=arc-20160816; b=PRpvW1q+EOi7D9K75BtrJLOXFD8amu7yJ4LCOOFt1kuMiMUXiRA60xz0qy6gXIq2sr WKGXf/bpSiLQpoXFAWPu+kOJLAPd+1qZOTuVoVERT/iQct/RVajhUzXziobSwxcNwodE 9Z6D4vfmv2M5SisxCS+WdLIeyE3sLNZvE+5vB3cutcZbUzXzZy/F+99v5bRREb9Y8b6H Y2xciUXn0YtfjyDcYqh0K6E+oqCtLSaFp2OPmUs5tVzgvuhPV0bmeSBU2r+cST8Bh9hN 5x8dQ8JV/skurq5ECP0sWk2NAi5jmOqOQF/C4X1zPAtro9RVYhP7yriAwv37ZkL/e6gp 6c7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=XafYrjse3vRqnqMEN+Q9RXJL7AU86k8dsu4nXeqO9VA=; b=hCICG/VeSgC8nqeXoGs2quF1Nt+E7ndYd5QSjZGTGBNM6q6Et4Mh/uqXmjDb5d3jgf k2KhVYgwudlF9hFRuYO6VIBGxDJEGAAhmnxUIyRfoFsUuwGC7QTy0VssEGoxRzH640nW rriFOqPhpV6Xj5CWbl2iFAeSmoJ0RQmfv9dWvKixncHSKWGAF+tNUKOluL0a9w5x8H+Z afTXsOh8viccw+aXjdLcMXVXIclCeDsWagP4r5yasNtx8I5FtMgaFpLjiN+OqNoCuaT7 KZeAFFGL3o3iJXlRL72YhuLte3gteVeESyRmkrpVkm5K96UkTIauPAJlTvmBdNrJ3Sc/ EF3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si3062851plh.224.2021.04.15.03.36.45; Thu, 15 Apr 2021 03:36:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232302AbhDOKgZ (ORCPT + 99 others); Thu, 15 Apr 2021 06:36:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:49482 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232173AbhDOKgP (ORCPT ); Thu, 15 Apr 2021 06:36:15 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id EC1FBB21D; Thu, 15 Apr 2021 10:35:51 +0000 (UTC) From: Oscar Salvador To: Andrew Morton Cc: Mike Kravetz , Vlastimil Babka , David Hildenbrand , Michal Hocko , Muchun Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador , Michal Hocko Subject: [PATCH v8 4/7] mm,hugetlb: Split prep_new_huge_page functionality Date: Thu, 15 Apr 2021 12:35:41 +0200 Message-Id: <20210415103544.6791-5-osalvador@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210415103544.6791-1-osalvador@suse.de> References: <20210415103544.6791-1-osalvador@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, prep_new_huge_page() performs two functions. It sets the right state for a new hugetlb, and increases the hstate's counters to account for the new page. Let us split its functionality into two separate functions, decoupling the handling of the counters from initializing a hugepage. The outcome is having __prep_new_huge_page(), which only initializes the page , and __prep_account_new_huge_page(), which adds the new page to the hstate's counters. This allows us to be able to set a hugetlb without having to worry about the counter/locking. It will prove useful in the next patch. prep_new_huge_page() still calls both functions. Signed-off-by: Oscar Salvador Acked-by: Michal Hocko Reviewed-by: Mike Kravetz --- mm/hugetlb.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 2cb9fa79cbaa..6f39ec79face 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1483,16 +1483,30 @@ void free_huge_page(struct page *page) } } -static void prep_new_huge_page(struct hstate *h, struct page *page, int nid) +/* + * Must be called with the hugetlb lock held + */ +static void __prep_account_new_huge_page(struct hstate *h, int nid) +{ + lockdep_assert_held(&hugetlb_lock); + h->nr_huge_pages++; + h->nr_huge_pages_node[nid]++; +} + +static void __prep_new_huge_page(struct page *page) { INIT_LIST_HEAD(&page->lru); set_compound_page_dtor(page, HUGETLB_PAGE_DTOR); hugetlb_set_page_subpool(page, NULL); set_hugetlb_cgroup(page, NULL); set_hugetlb_cgroup_rsvd(page, NULL); +} + +static void prep_new_huge_page(struct hstate *h, struct page *page, int nid) +{ + __prep_new_huge_page(page); spin_lock_irq(&hugetlb_lock); - h->nr_huge_pages++; - h->nr_huge_pages_node[nid]++; + __prep_account_new_huge_page(h, nid); spin_unlock_irq(&hugetlb_lock); } -- 2.16.3