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 BF9BEC25B0E for ; Wed, 17 Aug 2022 01:53:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C6B88D0001; Tue, 16 Aug 2022 21:53:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 375D56B0074; Tue, 16 Aug 2022 21:53:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 264988D0001; Tue, 16 Aug 2022 21:53:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 17C5E6B0073 for ; Tue, 16 Aug 2022 21:53:53 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DB3C41C683E for ; Wed, 17 Aug 2022 01:53:52 +0000 (UTC) X-FDA: 79807413504.03.0C3F76F Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf03.hostedemail.com (Postfix) with ESMTP id 0D991201C3 for ; Wed, 17 Aug 2022 01:53:51 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4M6rZC4SzczkWRb; Wed, 17 Aug 2022 09:50:27 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 17 Aug 2022 09:53:47 +0800 From: Miaohe Lin Subject: Re: [PATCH 1/6] mm/hugetlb: fix incorrect update of max_huge_pages To: Mike Kravetz , Andrew Morton CC: , , References: <20220816130553.31406-1-linmiaohe@huawei.com> <20220816130553.31406-2-linmiaohe@huawei.com> <20220816162024.60087b143995d9e21413fc52@linux-foundation.org> Message-ID: <5eebaeff-c002-2a1e-b5bb-fffe7e987ca0@huawei.com> Date: Wed, 17 Aug 2022 09:53:47 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660701232; a=rsa-sha256; cv=none; b=TA2r/R3CgZWbXax3G50Jl/TdIoX+g+OKdl1l2F1TCxZ88qAY1b4uQCEJjY3rFQqMojM490 7Ax8vKxcyO48Hbid8ZlyGCSSY5vZ7dWhymy9eJ5+esSBtu8Q5DY8d4NstRGwoVDnpFfrwc u7IUKYSYeaFv7hQQtjE6Tx/Ldq7kF/A= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660701232; 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; bh=uUjvRWlkfam0I228g10KA5BusQt6rzF7yno8jrb5a7I=; b=iwYxSGptslcsCagrb1bcAOmuH8NmaV21yCTEWid4IDvFt5Lc5dFxDN5BOdoYu+fPOEjUUT ybfs7t+5BGVFkQUZcVPTEuyjrf5Ydc+495Xl64EpFqbZWz/hHu0tJzYHpaRV7Bz2ALO+bg n/cNzu2tlxchoS05MxmP/G5SrKiI53k= Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam05 X-Rspam-User: X-Stat-Signature: f3a3t569esdfw3f5ee3ru4wuzyatfk3m X-Rspamd-Queue-Id: 0D991201C3 X-HE-Tag: 1660701231-830564 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 2022/8/17 7:34, Mike Kravetz wrote: > On 08/16/22 16:20, Andrew Morton wrote: >> 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? > > Sure, I am good with that. > > Just wanted to point out that the incorrect calculation does not have > any negative consequences. Maybe prompting Miaohe to look into the more > extensive cleanup. Many thanks both. I will try to do this "more extensive cleanup" after pending work is done. Thanks, Miaohe Lin