From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757233AbbCDBWV (ORCPT ); Tue, 3 Mar 2015 20:22:21 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:39713 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756422AbbCDBWS (ORCPT ); Tue, 3 Mar 2015 20:22:18 -0500 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , Davidlohr Bueso , Aneesh Kumar , Joonsoo Kim , Mike Kravetz Subject: [PATCH 1/4] hugetlbfs: add reserved mount fields to subpool structure Date: Tue, 3 Mar 2015 17:21:43 -0800 Message-Id: <1425432106-17214-2-git-send-email-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1425432106-17214-1-git-send-email-mike.kravetz@oracle.com> References: <1425432106-17214-1-git-send-email-mike.kravetz@oracle.com> X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a boolean to the subpool structure to indicate that the pages for subpool have been reserved. The hstate pointer in the subpool is convenient to have when reserving and unreserving the pages. hugepage_subool_reserved() is a handy way to check if reserved and take into account a NULL subpool. Signed-off-by: Mike Kravetz --- include/linux/hugetlb.h | 6 ++++++ mm/hugetlb.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 431b7fc..12fbd5d 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -23,6 +23,8 @@ struct hugepage_subpool { spinlock_t lock; long count; long max_hpages, used_hpages; + struct hstate *hstate; + bool reserved; }; struct resv_map { @@ -38,6 +40,10 @@ extern int hugetlb_max_hstate __read_mostly; #define for_each_hstate(h) \ for ((h) = hstates; (h) < &hstates[hugetlb_max_hstate]; (h)++) +static inline bool hugepage_subpool_reserved(struct hugepage_subpool *spool) +{ + return spool && spool->reserved; +} struct hugepage_subpool *hugepage_new_subpool(long nr_blocks); void hugepage_put_subpool(struct hugepage_subpool *spool); diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 85032de..c6adf65 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -85,6 +85,8 @@ struct hugepage_subpool *hugepage_new_subpool(long nr_blocks) spool->count = 1; spool->max_hpages = nr_blocks; spool->used_hpages = 0; + spool->hstate = NULL; + spool->reserved = false; return spool; } -- 2.1.0