Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4307344pxf; Tue, 30 Mar 2021 04:48:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU/o9Uk1uYYl0NnlmQRdftalwKf1XGIBKJlkQNY8GuKoDuZlpsoXrZDnW0L6BU3yq4OCnY X-Received: by 2002:a17:906:400b:: with SMTP id v11mr32768436ejj.194.1617104939518; Tue, 30 Mar 2021 04:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617104939; cv=none; d=google.com; s=arc-20160816; b=jDN2uIFvScvr/Ig4k5CLm1O1h0dvLrf9JjUQdASsPQQG+trAL5IKo8t1UtSg+bvmPg Zm/E8Rz2cSfIIJwumULZ9DBGew6xHNcLxC6x0XWAur4MuCu6P4DDSQtR2HlUuTh44GR7 nrHWofNKvmbR+ROR0zoGiC87nPjD70xz+2Zc8blLKMaI+wz2iX9wBgVHhKuJh3cr3eRv PUDwAZSezOcU6EK0lKGVUxHGHqhv6q+4EMVGuH5iDcH5jIAdOmzfQi7TTF1jML9HFDpA aBApCcXZwCs2VNWN6dFJbXd0ek8SZNSBlocsTMq97Ve7aekEnw/WYZMcDP0BWq9Wozo6 faGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=SjDu1wvjvIMsE1nufePp85fSjbxtXzx7MXU2JgRZtrs=; b=oMdOi3V/EHJ8T4c+LYWiXxkWeCR8K8YhuncG4T0cTojIx5onU4V3FFDCnu2csM+F// s7KqfA943an1liO3BNUimcJjMQ+zjzHbyk0RCyiomVhAXNxhLxiQ2QuDBvps0Vacp6u+ id5HmJui2qiCZe7AqCJH0wf+QNtPfXyEw+dAeNGrNT+nTUUB6FvWrQ3m+MGVf2YQ7ZvW /RsQuy1T+bJX59KP5fWfUYepyQacmnCphb0Zimk2mRDcdmCYKAqAesc8JgtZEiROyV8m 52ROV35a3WII5L/2FRb+0bBjZMqYXe/+pM9YGy5VCDEKWEaweoyHd97GsoVxs8f4oJsk 2a2A== ARC-Authentication-Results: i=1; mx.google.com; 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 u10si15006383ejb.59.2021.03.30.04.48.36; Tue, 30 Mar 2021 04:48:59 -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; 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 S231995AbhC3Lr3 (ORCPT + 99 others); Tue, 30 Mar 2021 07:47:29 -0400 Received: from outbound-smtp34.blacknight.com ([46.22.139.253]:52765 "EHLO outbound-smtp34.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232123AbhC3LrM (ORCPT ); Tue, 30 Mar 2021 07:47:12 -0400 Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp34.blacknight.com (Postfix) with ESMTPS id EBC5519F2 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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