From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f198.google.com (mail-wr0-f198.google.com [209.85.128.198]) by kanga.kvack.org (Postfix) with ESMTP id 405EC6B0292 for ; Mon, 5 Jun 2017 00:57:47 -0400 (EDT) Received: by mail-wr0-f198.google.com with SMTP id t30so8494464wra.7 for ; Sun, 04 Jun 2017 21:57:47 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id j89si31968696wrj.264.2017.06.04.21.57.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 04 Jun 2017 21:57:46 -0700 (PDT) Date: Mon, 5 Jun 2017 06:57:42 +0200 From: Michal Hocko Subject: Re: [PATCH] mm/hugetlb: Warn the user when issues arise on boot due to hugepages Message-ID: <20170605045725.GA9248@dhcp22.suse.cz> References: <20170603005413.10380-1-Liam.Howlett@Oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170603005413.10380-1-Liam.Howlett@Oracle.com> Sender: owner-linux-mm@kvack.org List-ID: To: "Liam R. Howlett" Cc: linux-mm@kvack.org, akpm@linux-foundation.org, mike.kravetz@Oracle.com, n-horiguchi@ah.jp.nec.com, aneesh.kumar@linux.vnet.ibm.com, gerald.schaefer@de.ibm.com, zhongjiang@huawei.com, aarcange@redhat.com, kirill.shutemov@linux.intel.com On Fri 02-06-17 20:54:13, Liam R. Howlett wrote: > When the user specifies too many hugepages or an invalid > default_hugepagesz the communication to the user is implicit in the > allocation message. This patch adds a warning when the desired page > count is not allocated and prints an error when the default_hugepagesz > is invalid on boot. We do not warn when doing echo $NUM > nr_hugepages, so why should we behave any different during the boot? > Signed-off-by: Liam R. Howlett > --- > mm/hugetlb.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index e5828875f7bb..6de30bbac23e 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -70,6 +70,7 @@ struct mutex *hugetlb_fault_mutex_table ____cacheline_aligned_in_smp; > > /* Forward declaration */ > static int hugetlb_acct_memory(struct hstate *h, long delta); > +static char * __init memfmt(char *buf, unsigned long n); > > static inline void unlock_or_release_subpool(struct hugepage_subpool *spool) > { > @@ -2189,7 +2190,14 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h) > &node_states[N_MEMORY])) > break; > } > - h->max_huge_pages = i; > + if (i < h->max_huge_pages) { > + char buf[32]; > + > + memfmt(buf, huge_page_size(h)), > + pr_warn("HugeTLB: allocating %lu of page size %s failed. Only allocated %lu hugepages.\n", > + h->max_huge_pages, buf, i); > + h->max_huge_pages = i; > + } > } > > static void __init hugetlb_init_hstates(void) > @@ -2785,6 +2793,11 @@ static int __init hugetlb_init(void) > return 0; > > if (!size_to_hstate(default_hstate_size)) { > + if (default_hstate_size != 0) { > + pr_err("HugeTLB: unsupported default_hugepagesz %lu. Reverting to %lu\n", > + default_hstate_size, HPAGE_SIZE); > + } > + > default_hstate_size = HPAGE_SIZE; > if (!size_to_hstate(default_hstate_size)) > hugetlb_add_hstate(HUGETLB_PAGE_ORDER); > -- > 2.13.0.92.gcd65a7235 > -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org