From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751510AbeBUTOr (ORCPT ); Wed, 21 Feb 2018 14:14:47 -0500 Received: from mx2.suse.de ([195.135.220.15]:47516 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751649AbeBUTOl (ORCPT ); Wed, 21 Feb 2018 14:14:41 -0500 Date: Wed, 21 Feb 2018 20:14:39 +0100 From: Michal Hocko To: Andrew Morton Cc: Dan Rue , linux-mm@kvack.org, Mike Kravetz , Naoya Horiguchi , LKML Subject: [PATCH] hugetlb: fix surplus pages accounting Message-ID: <20180221191439.GM2231@dhcp22.suse.cz> References: <20180103093213.26329-1-mhocko@kernel.org> <20180103093213.26329-6-mhocko@kernel.org> <20180221042457.uolmhlmv5je5dqx7@xps> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180221042457.uolmhlmv5je5dqx7@xps> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org OK, so here we go with the fix. >>From bc55c70ca2325f3305a80cfca5731f9550205589 Mon Sep 17 00:00:00 2001 From: Michal Hocko Date: Wed, 21 Feb 2018 19:47:33 +0100 Subject: [PATCH] hugetlb: fix surplus pages accounting Dan Rue has noticed that libhugetlbfs test suite fails counter test: root@localhost:~# mount_point="/mnt/hugetlb/" root@localhost:~# echo 200 > /proc/sys/vm/nr_hugepages root@localhost:~# mkdir -p "${mount_point}" root@localhost:~# mount -t hugetlbfs hugetlbfs "${mount_point}" root@localhost:~# export LD_LIBRARY_PATH=/root/libhugetlbfs/libhugetlbfs-2.20/obj64 root@localhost:~# /root/libhugetlbfs/libhugetlbfs-2.20/tests/obj64/counters Starting testcase "/root/libhugetlbfs/libhugetlbfs-2.20/tests/obj64/counters", pid 3319 Base pool size: 0 Clean... FAIL Line 326: Bad HugePages_Total: expected 0, actual 1 The bug was bisected to 0c397daea1d4 ("mm, hugetlb: further simplify hugetlb allocation API"). The reason is that alloc_surplus_huge_page misaccounts per node surplus pages. We should increase surplus_huge_pages_node rather than nr_huge_pages_node which is already handled by alloc_fresh_huge_page. Fixes: 0c397daea1d4 ("mm, hugetlb: further simplify hugetlb allocation API") Reported-by: Dan Rue Tested-by: Dan Rue Reviewed-by: Mike Kravetz Signed-off-by: Michal Hocko --- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 7c204e3d132b..a963f2034dfc 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1583,7 +1583,7 @@ static struct page *alloc_surplus_huge_page(struct hstate *h, gfp_t gfp_mask, page = NULL; } else { h->surplus_huge_pages++; - h->nr_huge_pages_node[page_to_nid(page)]++; + h->surplus_huge_pages_node[page_to_nid(page)]++; } out_unlock: -- 2.16.1 -- Michal Hocko SUSE Labs From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f199.google.com (mail-wr0-f199.google.com [209.85.128.199]) by kanga.kvack.org (Postfix) with ESMTP id 023A26B0009 for ; Wed, 21 Feb 2018 14:14:42 -0500 (EST) Received: by mail-wr0-f199.google.com with SMTP id g13so2153421wrh.23 for ; Wed, 21 Feb 2018 11:14:41 -0800 (PST) Received: from mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id p6si17576198wmf.129.2018.02.21.11.14.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Feb 2018 11:14:40 -0800 (PST) Date: Wed, 21 Feb 2018 20:14:39 +0100 From: Michal Hocko Subject: [PATCH] hugetlb: fix surplus pages accounting Message-ID: <20180221191439.GM2231@dhcp22.suse.cz> References: <20180103093213.26329-1-mhocko@kernel.org> <20180103093213.26329-6-mhocko@kernel.org> <20180221042457.uolmhlmv5je5dqx7@xps> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180221042457.uolmhlmv5je5dqx7@xps> Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Dan Rue , linux-mm@kvack.org, Mike Kravetz , Naoya Horiguchi , LKML OK, so here we go with the fix.