Received: by 10.223.185.116 with SMTP id b49csp1054366wrg; Wed, 21 Feb 2018 11:16:22 -0800 (PST) X-Google-Smtp-Source: AH8x225BJePSqzpMHvRvyZcc6ZZc/URbN8scVUr91qOJJ9eu0nG3t+z57O7sIG14ui/PkQGo4l2W X-Received: by 2002:a17:902:5269:: with SMTP id z96-v6mr4042731plh.385.1519240582677; Wed, 21 Feb 2018 11:16:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519240582; cv=none; d=google.com; s=arc-20160816; b=u57vxaCKTUCqFqdjBf/LtAMx3ve4jQVgJYV+mlSswlJlMqY24+lbaTfWXmCyMbTSio 4Nj5fRpFhUNMMU/6jAlEPkaO1c5CBqNthkLKfOpGGqeoelftKaI3nS/ze+HLQMyn24f4 VRRy0ZTvorvDN4ixXjwubr1rffr9cHriOl7GZZi682/CMZfBR2QTJG0MjD4+eOO69Eco 9cbzw0cBbgwJ8om5SuqMKLEnMJUJAHpWrzELRRuFTSpZvMBXXq3jaUwZ+7qZcleelM4g 7XA8rKkoQZfUPdlZbNvYRuMk9IXZ1Z0qtO8o4NzZckbGiuMyTcbZH1Cx7OmhNieF1emc 7PpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=/NXqqF2agRHIguRoZQMl1ZiVHFJCmdeydO+DL+pTt+4=; b=LTs8UL4ZcBz5SLLN422H4Sx4K5eVzlXQqdQJ61WqnMolvi2qvBcsfAj2TjS1WG6QfF 0LLdPnC2okOQBFEwp69gYlVWfjSNGW//mOaHU1glmc/TWRkuF4iKMEKOQWKg3M0vxYuT hk6DIm87Yphb50XgXJOUyI9cSfYgKxFrH+Zkly9QRwD/i0fgBWlqSorqCuMryXFuvXW/ OuDNBsSKRMk8K/G5elRCyvZOGGOUr18BurW2zINRh+0KwgbpNrGyDtplaAYJ/uePyfTZ zNdQRaMZl3cRYE+YQ7Y79mZexmwir8h4pMbda7Kt4icbZiYaweGBNjhjslNZNyqHurLu 3Y0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 19si3335702pfa.127.2018.02.21.11.16.08; Wed, 21 Feb 2018 11:16:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752017AbeBUTOq (ORCPT + 99 others); Wed, 21 Feb 2018 14:14:46 -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 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 15AE1ADD2; Wed, 21 Feb 2018 19:14:40 +0000 (UTC) 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 Precedence: bulk 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