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 X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3126C433C1 for ; Tue, 30 Mar 2021 11:47:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2CB6D61921 for ; Tue, 30 Mar 2021 11:47:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CB6D61921 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9462D6B007B; Tue, 30 Mar 2021 07:47:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F60D6B007D; Tue, 30 Mar 2021 07:47:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 797976B0080; Tue, 30 Mar 2021 07:47:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0143.hostedemail.com [216.40.44.143]) by kanga.kvack.org (Postfix) with ESMTP id 617B76B007B for ; Tue, 30 Mar 2021 07:47:13 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 29717180AD81A for ; Tue, 30 Mar 2021 11:47:13 +0000 (UTC) X-FDA: 77976364746.23.7B8B32F Received: from outbound-smtp07.blacknight.com (outbound-smtp07.blacknight.com [46.22.139.12]) by imf03.hostedemail.com (Postfix) with ESMTP id DAA6DC0007D2 for ; Tue, 30 Mar 2021 11:47:10 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp07.blacknight.com (Postfix) with ESMTPS id EBADD1C3AE4 for ; Tue, 30 Mar 2021 12:47:10 +0100 (IST) Received: (qmail 11040 invoked from network); 30 Mar 2021 11:47:10 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.22.4]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 30 Mar 2021 11:47:10 -0000 Date: Tue, 30 Mar 2021 12:47:09 +0100 From: Mel Gorman To: Colin Ian King Cc: Andrew Morton , linux-mm@kvack.org, "linux-kernel@vger.kernel.org" Subject: Re: mm/page_alloc: add a bulk page allocator Message-ID: <20210330114709.GW3697@techsingularity.net> References: <61c479aa-18fe-82f3-c859-710c3555cbaa@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <61c479aa-18fe-82f3-c859-710c3555cbaa@canonical.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: DAA6DC0007D2 X-Stat-Signature: 1gdzq9xt4eqrzz1mamu6ckic7onmz4et Received-SPF: none (techsingularity.net>: No applicable sender policy available) receiver=imf03; identity=mailfrom; envelope-from=""; helo=outbound-smtp07.blacknight.com; client-ip=46.22.139.12 X-HE-DKIM-Result: none/none X-HE-Tag: 1617104830-384796 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 Mon, Mar 29, 2021 at 04:18:09PM +0100, Colin Ian King wrote: > Hi, > > Static analysis on linux-next with Coverity has found a potential > uninitialized variable issue in function __alloc_pages_bulk with the > following commit: > > commit b0e0a469733fa571ddd8fe147247c9561b51b2da > Author: Mel Gorman > Date: Mon Mar 29 11:12:24 2021 +1100 > > mm/page_alloc: add a bulk page allocator > > The analysis is as follows: > > > > > 5050 if (nr_pages - nr_populated == 1) > 5051 goto failed; > 5052 > 5053 /* May set ALLOC_NOFRAGMENT, fragmentation will return 1 > page. */ > 5054 gfp &= gfp_allowed_mask; > 5055 alloc_gfp = gfp; > > Uninitialized scalar variable (UNINIT) > 15. uninit_use_in_call: Using uninitialized value alloc_flags when > calling prepare_alloc_pages. > > 5056 if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, > &ac, &alloc_gfp, &alloc_flags)) Ok, so Coverity thinks that alloc_flags is potentially uninitialised and without digging into every part of the report, Coverity is right. > > > So alloc_flags in gfp_to_alloc_flags_cma is being updated with the |= > operator and we managed to get to this path with uninitialized > alloc_flags. Should alloc_flags be initialized to zero in > __alloc_page_bulk()? > You are correct about the |= updating an initial value, but I think the initialized value should be ALLOC_WMARK_LOW. A value of 0 would be the same as ALLOC_WMARK_MIN and that would allow the bulk allocator to potentially consume too many pages without waking kswapd. I'll put together a patch shortly. Thanks Colin! -- Mel Gorman SUSE Labs