Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1091025pxb; Wed, 29 Sep 2021 17:03:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTqMxTPTDljWN26poWH1hwTfOrGmUqvsKqnpDEzohKoXLh6wwsaZea7RR2moepZlCGL3dA X-Received: by 2002:a17:90a:b795:: with SMTP id m21mr2813213pjr.143.1632960190561; Wed, 29 Sep 2021 17:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632960190; cv=none; d=google.com; s=arc-20160816; b=TwiXrRap9q0WSr5mKLs5q/GksTKkrib+Szn4h5McAQtvCATwgo8W4QEfyWk5+KHSuj 4EMF9xWd5DcvjVerxcjnuMF2NgjXBnlAJNyJHT8yhd4/mfCnOXskDc7FU22yPk28ctia VmdkLGEXZuBKqw0X8IhTPG2m7vQTwcHUsoYHBW1hLMrrCrPomm9TbDzpQCD6O35KJfaj /Tyh+ZqX45xjyZlDTRdtEfPTtButFL3NsudmYQmEvQUPBwCu37yTQgog3+sqJlgPqjBp q1qtQmgaltOuFjcUIblV1yU01U+QA05rbwB6wz4Gg2JPGGr/rztcW6uallpDhZVV02ny q7Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=SCldEq7VgMIdhP5QTQ8hd3YGgJjVKOwYyA0qwZygMHA=; b=pfsr/mHhp/VuQorEaSOFn0JGCH8YOZ+gnnozqJUgHc9+cMqXQr090ZUE9s/8HMbzl5 K1a/aQKNv/H6gft852/Lnx/f4KEltEnN3ZqlqcUxn3176MYJr/mqZHFAcqqvo+CONEXx Xjr4pPYhT1mo/IRvPI7efPAFNb4nxq8sqXNJezc7rKYeUbTbceJ4LS1yNe8cxKwvKU5n rETZxi2y+LThdGzdqrFp9R+UiJxrrVL1UUAkJIHS8b37Ph0EQMfKZaW/qN4ajPLQcqY1 LRpAox/dDadjGjV+BQmj8TccOyIuoCSD8izRgl5v1dbjyxbd/QkvTplfqec6+fl8yw62 UYyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=xXoW1nkh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y2si1829156plh.329.2021.09.29.17.02.37; Wed, 29 Sep 2021 17:03:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=xXoW1nkh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346696AbhI2X1Y (ORCPT + 99 others); Wed, 29 Sep 2021 19:27:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:47466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245025AbhI2X1V (ORCPT ); Wed, 29 Sep 2021 19:27:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A2AB61504; Wed, 29 Sep 2021 23:25:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1632957939; bh=xUoojM5baZbirs9n9pr5p0EQ68LtFMWxRkYfM9vHTrk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=xXoW1nkhG5+Xw7yT2XvU8PGVUVE/7WTX2YuRi/JaC+nKLFdktXY5T00uXpCkrHVOH nhCsbNPC43twMUhs60qozYairoRHpJQrynslXyqCgZ+e0ra8zVcs47mXjoYC4zCNwq crlC5ixAuTkJMRo7zORBkUtvy5sbGpEoaUuH4v8s= Date: Wed, 29 Sep 2021 16:25:38 -0700 From: Andrew Morton To: Mike Rapoport Cc: Nathan Chancellor , Zhenguo Yao , mike.kravetz@oracle.com, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, corbet@lwn.net, yaozhenguo@jd.com, willy@infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, llvm@lists.linux.dev Subject: Re: [PATCH v7] hugetlbfs: Extend the definition of hugepages parameter to support node allocation Message-Id: <20210929162538.5c1452d63e064bf9da3cc9e5@linux-foundation.org> In-Reply-To: References: <20210927104149.46884-1-yaozhenguo1@gmail.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 29 Sep 2021 15:27:18 -0700 Mike Rapoport wrote: > > mm/hugetlb.c:2957:33: error: variable 'm' is used uninitialized whenever '&&' condition is false [-Werror,-Wsometimes-uninitialized] > > for_each_node_mask_to_alloc(h, nr_nodes, node, &node_states[N_MEMORY]) { > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > mm/hugetlb.c:1254:3: note: expanded from macro 'for_each_node_mask_to_alloc' > > nr_nodes > 0 && \ > > ^~~~~~~~~~~~ > > mm/hugetlb.c:2974:18: note: uninitialized use occurs here > > INIT_LIST_HEAD(&m->list); > > ^ > > mm/hugetlb.c:2957:33: note: remove the '&&' if its condition is always true > > for_each_node_mask_to_alloc(h, nr_nodes, node, &node_states[N_MEMORY]) { > > ^ > > mm/hugetlb.c:2942:29: note: initialize the variable 'm' to silence this warning > > struct huge_bootmem_page *m; > > ^ > > = NULL > > 1 error generated. > > > > I am not sure if it is possible for nr_nodes to be 0 right out of the > > gate so might be a false positive? > > With nr_nodes == 0 there will be no memory in the system :) Let's keep clang happy? --- a/mm/hugetlb.c~hugetlbfs-extend-the-definition-of-hugepages-parameter-to-support-node-allocation-fix +++ a/mm/hugetlb.c @@ -2939,7 +2939,7 @@ int alloc_bootmem_huge_page(struct hstat __attribute__ ((weak, alias("__alloc_bootmem_huge_page"))); int __alloc_bootmem_huge_page(struct hstate *h, int nid) { - struct huge_bootmem_page *m; + struct huge_bootmem_page *m = NULL; /* initialize for clang */ int nr_nodes, node; if (nid >= nr_online_nodes) _