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=-17.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 CE975C433ED for ; Mon, 17 May 2021 13:17:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7D28E611BE for ; Mon, 17 May 2021 13:17:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D28E611BE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 128EA6B0036; Mon, 17 May 2021 09:17:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0FF596B006E; Mon, 17 May 2021 09:17:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE25A6B0070; Mon, 17 May 2021 09:17:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id BA8ED6B0036 for ; Mon, 17 May 2021 09:17:55 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 587CD9417 for ; Mon, 17 May 2021 13:17:55 +0000 (UTC) X-FDA: 78150775710.29.EF813B8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 1665280192C6 for ; Mon, 17 May 2021 13:17:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621257474; h=from:from: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=302eZ4qDI0GRNiemHwtsv0o7x2BmzRwhlMO3j9ZHKfo=; b=BDEy70r0GSuI3jcJ+4DtVKdFUHLez8FjPOzDnB4YHRFsbkRTP4K7cB5KcYJhg1wJaYBXor zWEwhAFNRd9qHAxZohFyGt0CdtnDknCzoInPu//xwCFOPp38llgEhbO3jJz3w3raOpeOr/ V63d37sCqe2HVOgZdLUYLINuEDVc7T8= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-jNUASe2APPuB9DAj0hkWCA-1; Mon, 17 May 2021 09:17:53 -0400 X-MC-Unique: jNUASe2APPuB9DAj0hkWCA-1 Received: by mail-qk1-f199.google.com with SMTP id c126-20020ae9ed840000b02903a5090d4944so2599936qkg.15 for ; Mon, 17 May 2021 06:17:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=302eZ4qDI0GRNiemHwtsv0o7x2BmzRwhlMO3j9ZHKfo=; b=KV6TlvusC0XsmhUVmojs1/K6vJU1iVk6DiQY1EFRNIIKZMoHpYIf1LRnNBADnPA+eu adqtZyFV+WNxfHOmztDeNPXVwWhNxUijcZ3FmxDElUYcJ3baKXnqXegy5ULz/dfNeHt3 XjXkEkXlN39gZ3UdBV/8aGEUJV8LsZWgH01Wx1W3x+qAs0XWgOknUI9vMAndOPnTo+5z 14pgu3Tq73Elz7W939o160mLDBbIft8Wudx0EIBcG0cHg8qGUIv3ypc/bWd6I1FordgO h+SCYu0iSuD7ribU9KN/wTVgWGjFbPzEGzMz097S4iiPLHujfk/s+d1wTGS62ZZS1yb0 QiCQ== X-Gm-Message-State: AOAM532V/R19SjlfgEABvrorYLIKWkeKXaBg0XCZ0Sls0n7wKnX+wg4C onLv74Q9BsciLDFObrx8djbDvBxkL6IDEAsCHdT23E/+e07EflA/5prI5jT/6VVk8firm0pA8VA p8uajDsyjAQI= X-Received: by 2002:ac8:7f41:: with SMTP id g1mr57865319qtk.72.1621257470511; Mon, 17 May 2021 06:17:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1GXnceHJW1kNq377snFtM5QG53XeoeEVafMT93GToCW8jsZKQxNt7PKa6yc9SZ9VaeNkTPg== X-Received: by 2002:ac8:7f41:: with SMTP id g1mr57865242qtk.72.1621257469608; Mon, 17 May 2021 06:17:49 -0700 (PDT) Received: from localhost.localdomain (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id s5sm10465630qkg.88.2021.05.17.06.17.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 May 2021 06:17:49 -0700 (PDT) Subject: Re: [PATCH] percpu: initialize best_upa variable To: Dennis Zhou Cc: tj@kernel.org, cl@linux.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20210515180817.1751084-1-trix@redhat.com> From: Tom Rix Message-ID: Date: Mon, 17 May 2021 06:17:47 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Rspamd-Queue-Id: 1665280192C6 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BDEy70r0; spf=none (imf08.hostedemail.com: domain of trix@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=trix@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam04 X-Stat-Signature: mz3coj56p6okztmq9us49prtrmw3sz3m X-HE-Tag: 1621257471-204039 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 5/16/21 7:05 PM, Dennis Zhou wrote: > Hello, > > On Sat, May 15, 2021 at 11:08:17AM -0700, trix@redhat.com wrote: >> From: Tom Rix >> >> Static analysis reports this problem >> percpu.c:2945:6: warning: Assigned value is garbage or undefined >> upa = best_upa; >> ^ ~~~~~~~~ >> best_upa may not be set, so initialize it. >> >> Signed-off-by: Tom Rix >> --- >> mm/percpu.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/mm/percpu.c b/mm/percpu.c >> index a257c3efdf18b..6578b706fae81 100644 >> --- a/mm/percpu.c >> +++ b/mm/percpu.c >> @@ -2916,6 +2916,7 @@ static struct pcpu_alloc_info * __init __flatten pcpu_build_alloc_info( >> * Related to atom_size, which could be much larger than the unit_size. >> */ >> last_allocs = INT_MAX; >> + best_upa = max_upa; >> for (upa = max_upa; upa; upa--) { >> int allocs = 0, wasted = 0; >> >> -- >> 2.26.3 >> > I think the proper fix would be: > > best_upa = 0; I was looking for initializing with something that would work. > for (...) { } > BUG_ON(!best_upa); WARN_ON instead? > upa = best_upa; > > If you're fine with this I'll make the changes and apply it to > for-5.13-fixes. > > Can you also tell me what static analysis tool produced this? I'm just a > little curious because this code hasn't changed in several years so I'd > have expected some static analyzer to have caught this by now. Clang 10 Tom > > Thanks, > Dennis >