Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1010717ybh; Wed, 22 Jul 2020 20:25:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgspqdEp1kHZMPZf/zGmP6wrmNOTAbHmPxnmI3+l+Sa427h+xAtWm8nOkFt5WU+k5+S4kK X-Received: by 2002:aa7:d802:: with SMTP id v2mr2292065edq.77.1595474731352; Wed, 22 Jul 2020 20:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595474731; cv=none; d=google.com; s=arc-20160816; b=Dkg0dRyuIV5wL1lDhMBSRFA9V89fyEv5S1EFdAKgz9wJ1S5/yfffBBDqpN+bnPvw/c SNCdN5Q6289kd4ps/wY9mUjtwxp4IqIHAKTCDJbSu83JnBORsxLoMXiqqbrhUc/3RXeH QcrVcAO2c6k/onWDpzBnt8fqbP3OqXnE4htOwzuYeEsAfYy7r2Q21N1WMR/BsuxPljXK lPvJTU3BxT4VpQ7TXCtxoXcUH/iHvH/fxlydX40mt/ef82W5q3fVqP9jeu3WTIKcLvJ3 QZSIjLv0xDaIiNlmWLGzAtI38hqf6vRK8CXhmPyGjRYOJIMchKrJByQ6jNTgvWk6JxQX Mskg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=vZfw7dyC3KMlWpgvlscO0Ovg3J13CbQcaPM0NJVPAbM=; b=YItgGkz6dBaHY648vsCZR5k7iVnVIB8ig5wKnOY4K7o+wJaE3256MzmwN8EpNJS9Fo 8XGC/Xkrj4hbeh4riPehFMeQamWRuC51SSqa0RWcDDHuMzVdE8v01DG8cnTzyaky39ni Q56O7CR72HEn6u+URq6At0iNVtt9+g/y1lmPOTH0lyHoo15lkqgOZUG5VoFLWVei+L/R 9OJ7ZTaq8m5M4jvu16uKbRm7LBv618vLEdQ8JBFJSq07CtMS2qtRmeh0vW54gQoqQXqE jJa92KhJ6dmrB6lvV3pSslChlsK4tZRhLrQCUEPelwhd5IiyV/EmwsEmzTr08o7gFB+m Y00Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YpMrZEix; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j8si1226915edy.211.2020.07.22.20.25.08; Wed, 22 Jul 2020 20:25:31 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YpMrZEix; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387706AbgGWDXP (ORCPT + 99 others); Wed, 22 Jul 2020 23:23:15 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:37184 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728902AbgGWDXO (ORCPT ); Wed, 22 Jul 2020 23:23:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595474593; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=vZfw7dyC3KMlWpgvlscO0Ovg3J13CbQcaPM0NJVPAbM=; b=YpMrZEixgJJzdUl2jnEW7duNn+UX2wFimqwAOM7miWNYTjFBvWWyYIxtdamVfGIsoONajl Er2d6GMr0FdDtkIqwQ3NAv2w6AatBb7ZOrh9afS4JnZ0rxfrBEiYYgAFYC5lWHvzUN0xBq Q+GbYp+tqco2BMyGB+0g9J8My6O3ICI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-52-5xsT3EbkOIGbJy9TKANloQ-1; Wed, 22 Jul 2020 23:23:09 -0400 X-MC-Unique: 5xsT3EbkOIGbJy9TKANloQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F6E518A1DED; Thu, 23 Jul 2020 03:23:08 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-53.pek2.redhat.com [10.72.13.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id D51825C1BD; Thu, 23 Jul 2020 03:23:04 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, mike.kravetz@oracle.com, david@redhat.com, akpm@linux-foundation.org, bhe@redhat.com Subject: [PATCH v2 4/4] mm/hugetl.c: warn out if expected count of huge pages adjustment is not achieved Date: Thu, 23 Jul 2020 11:22:48 +0800 Message-Id: <20200723032248.24772-5-bhe@redhat.com> In-Reply-To: <20200723032248.24772-1-bhe@redhat.com> References: <20200723032248.24772-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A customer complained that no message is logged when the number of persistent huge pages is not changed to the exact value written to the sysfs or proc nr_hugepages file. In the current code, a best effort is made to satisfy requests made via the nr_hugepages file. However, requests may be only partially satisfied. Log a message if the code was unsuccessful in fully satisfying a request. This includes both increasing and decreasing the number of persistent huge pages. Signed-off-by: Baoquan He --- mm/hugetlb.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index c14837854392..b5aa32a13569 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2661,7 +2661,7 @@ static int adjust_pool_surplus(struct hstate *h, nodemask_t *nodes_allowed, static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid, nodemask_t *nodes_allowed) { - unsigned long min_count, ret; + unsigned long min_count, ret, old_max, new_max; NODEMASK_ALLOC(nodemask_t, node_alloc_noretry, GFP_KERNEL); /* @@ -2723,6 +2723,7 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid, * pool might be one hugepage larger than it needs to be, but * within all the constraints specified by the sysctls. */ + old_max = persistent_huge_pages(h); while (h->surplus_huge_pages && count > persistent_huge_pages(h)) { if (!adjust_pool_surplus(h, nodes_allowed, -1)) break; @@ -2779,8 +2780,20 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid, } out: h->max_huge_pages = persistent_huge_pages(h); + new_max = h->max_huge_pages; spin_unlock(&hugetlb_lock); + if (count != new_max) { + char buf[32]; + + string_get_size(huge_page_size(h), 1, STRING_UNITS_2, buf, 32); + pr_warn("HugeTLB: %s %lu of page size %s failed. Only %s %lu hugepages.\n", + count > old_max ? "increasing" : "decreasing", + abs(count - old_max), buf, + count > old_max ? "increased" : "decreased", + abs(old_max - new_max)); + } + NODEMASK_FREE(node_alloc_noretry); return 0; -- 2.17.2