From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E722C2BB41 for ; Tue, 16 Aug 2022 23:20:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7375F6B0073; Tue, 16 Aug 2022 19:20:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E69B8D0002; Tue, 16 Aug 2022 19:20:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D58C8D0001; Tue, 16 Aug 2022 19:20:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4E3216B0073 for ; Tue, 16 Aug 2022 19:20:30 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1948C1C6BD9 for ; Tue, 16 Aug 2022 23:20:30 +0000 (UTC) X-FDA: 79807027020.28.437070E Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf20.hostedemail.com (Postfix) with ESMTP id 958751C007E for ; Tue, 16 Aug 2022 23:20:28 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E47B4B81B6B; Tue, 16 Aug 2022 23:20:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BC0BC433D6; Tue, 16 Aug 2022 23:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1660692025; bh=dLIrbvWSp9CzQP2h38u6C/fQ1zY4GEVLkWTe61blRkY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=YJtAl5Ss/QVq3Z2FpdtxK5NkfKGklpWKj5chylwjaLC132mZMmI0e701l00RHRphD FKDoqWpqyS5J6vS0DwF2rm6Nf2FIWpbaEHaQFV15wRFhQ8XjkMTmgw+Eyo61AFP4Ug 2612r0e6KXsA5/ewpfyAfbrRU46/RH17sxBRr2MY= Date: Tue, 16 Aug 2022 16:20:24 -0700 From: Andrew Morton To: Mike Kravetz Cc: Miaohe Lin , songmuchun@bytedance.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/6] mm/hugetlb: fix incorrect update of max_huge_pages Message-Id: <20220816162024.60087b143995d9e21413fc52@linux-foundation.org> In-Reply-To: References: <20220816130553.31406-1-linmiaohe@huawei.com> <20220816130553.31406-2-linmiaohe@huawei.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660692029; a=rsa-sha256; cv=none; b=Z34Kj8NG4TnR7jOqtsn7EoGn0XbQOM9YN6WRSpgO87CEgtYvywSkMgNeUNWREw/i3Z9OUj Lgi4RMmVMSi9A7NxlPl57fi+X8ySNEFfw4TWjPYho48Y7icZnlhsDNkd+wNheWf7oxChtZ 5EEC0zuIh1RxFL/RJzdoyvAKmtCP1xg= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=YJtAl5Ss; dmarc=none; spf=pass (imf20.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660692029; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3rFI1aOfaCaTepgR6m3Vjk9YPtlaFFzPfZYmAbRz4Wk=; b=Knos8Y5ma9+ret/jd495ebd5qARdwTW4AX4Yuu4lZ00C5inG8DBELSTs1kNac4oDV1ZrP1 fMn/jZCrOwFTsUk5bbooRn2dir+09PXbQyqlgRSN16NHm2L5Xyg1PPeuFCj/EtZ/2H3XAl iQuP8+0zvqUwRtSmZKHcKVBUc/9rD5A= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 958751C007E X-Rspam-User: Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=YJtAl5Ss; dmarc=none; spf=pass (imf20.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Stat-Signature: fzm3ji8pbp8pciar11xaorbddickcm6m X-HE-Tag: 1660692028-917479 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 16 Aug 2022 15:52:47 -0700 Mike Kravetz wrote: > On 08/16/22 21:05, Miaohe Lin wrote: > > There should be pages_per_huge_page(h) / pages_per_huge_page(target_hstate) > > pages incremented for target_hstate->max_huge_pages when page is demoted. > > Update max_huge_pages accordingly for consistency. > > > > Signed-off-by: Miaohe Lin > > --- > > mm/hugetlb.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > > index ea1c7bfa1cc3..e72052964fb5 100644 > > --- a/mm/hugetlb.c > > +++ b/mm/hugetlb.c > > @@ -3472,7 +3472,8 @@ static int demote_free_huge_page(struct hstate *h, struct page *page) > > * based on pool changes for the demoted page. > > */ > > h->max_huge_pages--; > > - target_hstate->max_huge_pages += pages_per_huge_page(h); > > + target_hstate->max_huge_pages += > > + pages_per_huge_page(h) / pages_per_huge_page(target_hstate); > > Thanks! > > That is indeed incorrect. However the miscalculation should not have any > consequences. Correct? The value is used when initially populating the > pools. It is never read and used again. It is written to in > set_max_huge_pages if someone changes the number of hugetlb pages. > > I guess that is a long way of saying I am not sure why we care about trying > to keep max_huge_pages up to date? I do not think it matters. > > I also thought, if we are going to adjust max_huge_pages here we may > also want to adjust the node specific value: h->max_huge_pages_node[node]. > There are a few other places where the global max_huge_pages is adjusted > without adjusting the node specific value. > > The more I think about it, the more I think we should explore just > eliminating any adjustment of this/these values after initially > populating the pools. I'm thinking we should fix something that is "indeed incorrect" before going on to more extensive things?