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 C9AEBC433EF for ; Thu, 14 Apr 2022 01:29:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55E596B0071; Wed, 13 Apr 2022 21:29:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 50E186B0073; Wed, 13 Apr 2022 21:29:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D5C26B0074; Wed, 13 Apr 2022 21:29:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0034.hostedemail.com [216.40.44.34]) by kanga.kvack.org (Postfix) with ESMTP id 2E0F76B0071 for ; Wed, 13 Apr 2022 21:29:00 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CDC798249980 for ; Thu, 14 Apr 2022 01:28:59 +0000 (UTC) X-FDA: 79353750798.31.290CD3C Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf18.hostedemail.com (Postfix) with ESMTP id 7575F1C0002 for ; Thu, 14 Apr 2022 01:28:58 +0000 (UTC) Received: from kwepemi500026.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Kf20K5D5Lz1HBlL; Thu, 14 Apr 2022 09:28:17 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by kwepemi500026.china.huawei.com (7.221.188.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 14 Apr 2022 09:28:54 +0800 Received: from [10.174.179.19] (10.174.179.19) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 14 Apr 2022 09:28:53 +0800 Content-Type: multipart/alternative; boundary="------------t9gApeMGGdi3SALg88O8yzki" Message-ID: Date: Thu, 14 Apr 2022 09:28:52 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH v3 1/4] hugetlb: Fix wrong use of nr_online_nodes Content-Language: en-US To: Andrew Morton CC: , , , , , , , References: <20220413032915.251254-1-liupeng256@huawei.com> <20220413032915.251254-2-liupeng256@huawei.com> <20220412214238.84c20437a052458f6967e9fd@linux-foundation.org> <692ee24c-a705-0c54-7cad-a9ecf49a8f15@huawei.com> <20220413150422.e4fc3bda48a285bf7bdc5587@linux-foundation.org> From: "liupeng (DM)" In-Reply-To: <20220413150422.e4fc3bda48a285bf7bdc5587@linux-foundation.org> X-Originating-IP: [10.174.179.19] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of liupeng256@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=liupeng256@huawei.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 7575F1C0002 X-Stat-Signature: acs1padk5bthdm4fcqz1imthjps8f78s X-HE-Tag: 1649899738-832815 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: --------------t9gApeMGGdi3SALg88O8yzki Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit On 2022/4/14 6:04, Andrew Morton wrote: > On Wed, 13 Apr 2022 14:27:54 +0800 "liupeng (DM)" wrote: > >> On 2022/4/13 12:42, Andrew Morton wrote: >>> On Wed, 13 Apr 2022 03:29:12 +0000 Peng Liu wrote: >>> >>>> Certain systems are designed to have sparse/discontiguous nodes. In >>>> this case, nr_online_nodes can not be used to walk through numa node. >>>> Also, a valid node may be greater than nr_online_nodes. >>>> >>>> However, in hugetlb, it is assumed that nodes are contiguous. Recheck >>>> all the places that use nr_online_nodes, and repair them one by one. >>>> >>> What are the runtime effects of this shortcoming? >>> . >> For sparse/discontiguous nodes, the current code may treat a valid node >> as invalid, and will fail to allocate all hugepages on a valid node that >> "nid >= nr_online_nodes". >> >> As David suggested: >> if (tmp >= nr_online_nodes) >> goto invalid; >> >> Just imagine node 0 and node 2 are online, and node 1 is offline. Assuming >> that "node < 2" is valid is wrong. > So do you think we should backport thtis fix into earlier kernel releases? > . I think it is not an urgent bug, because: 1) Qemu does not support sparse node so far, although there are some sparse-node issues to make qemu support sparse node. 2) I don't find an actual normal machine that reports sparse-node and need to use hugepages so far. --------------t9gApeMGGdi3SALg88O8yzki Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 7bit


On 2022/4/14 6:04, Andrew Morton wrote:
On Wed, 13 Apr 2022 14:27:54 +0800 "liupeng (DM)" <liupeng256@huawei.com> wrote:

On 2022/4/13 12:42, Andrew Morton wrote:
On Wed, 13 Apr 2022 03:29:12 +0000 Peng Liu<liupeng256@huawei.com>  wrote:

Certain systems are designed to have sparse/discontiguous nodes. In
this case, nr_online_nodes can not be used to walk through numa node.
Also, a valid node may be greater than nr_online_nodes.

However, in hugetlb, it is assumed that nodes are contiguous. Recheck
all the places that use nr_online_nodes, and repair them one by one.

What are the runtime effects of this shortcoming?
.
For sparse/discontiguous nodes, the current code may treat a valid node
as invalid, and will fail to allocate all hugepages on a valid node that
"nid >= nr_online_nodes".

As David suggested:
if (tmp >= nr_online_nodes)
	goto invalid;

Just imagine node 0 and node 2 are online, and node 1 is offline. Assuming
that "node < 2" is valid is wrong.
So do you think we should backport thtis fix into earlier kernel releases?
.
I think it is not an urgent bug, because:
1) Qemu does not support sparse node so far, although there are some sparse-node
issues to make qemu support sparse node.
2) I don't find an actual normal machine that reports sparse-node and need to
use hugepages so far.
--------------t9gApeMGGdi3SALg88O8yzki--