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=-8.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 6E8CAC46466 for ; Sun, 4 Oct 2020 19:24:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CD073205ED for ; Sun, 4 Oct 2020 19:24:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD073205ED 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 DF18C6B005D; Sun, 4 Oct 2020 15:24:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA1DE6B0062; Sun, 4 Oct 2020 15:24:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8F506B0068; Sun, 4 Oct 2020 15:24:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id 988F36B005D for ; Sun, 4 Oct 2020 15:24:43 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 28B1D180AD801 for ; Sun, 4 Oct 2020 19:24:43 +0000 (UTC) X-FDA: 77335220046.12.star56_300a305271b7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 00B561800BEAB for ; Sun, 4 Oct 2020 19:24:42 +0000 (UTC) X-HE-Tag: star56_300a305271b7 X-Filterd-Recvd-Size: 2982 Received: from outbound-smtp24.blacknight.com (outbound-smtp24.blacknight.com [81.17.249.192]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Sun, 4 Oct 2020 19:24:42 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail03.blacknight.ie [81.17.254.16]) by outbound-smtp24.blacknight.com (Postfix) with ESMTPS id 881A5C0E81 for ; Sun, 4 Oct 2020 20:24:40 +0100 (IST) Received: (qmail 16067 invoked from network); 4 Oct 2020 19:24:40 -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); 4 Oct 2020 19:24:40 -0000 Date: Sun, 4 Oct 2020 20:24:37 +0100 From: Mel Gorman To: Lukas Bulwahn Cc: Andrew Morton , linux-mm@kvack.org, Vlastimil Babka , Michal Hocko , Nathan Chancellor , Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, kernel-janitors@vger.kernel.org, linux-safety@lists.elisa.tech Subject: Re: [PATCH] mm/vmscan: drop unneeded assignment in kswapd() Message-ID: <20201004192437.GF3227@techsingularity.net> References: <20201004125827.17679-1-lukas.bulwahn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20201004125827.17679-1-lukas.bulwahn@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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 Sun, Oct 04, 2020 at 02:58:27PM +0200, Lukas Bulwahn wrote: > The refactoring to kswapd() in commit e716f2eb24de ("mm, vmscan: prevent > kswapd sleeping prematurely due to mismatched classzone_idx") turned an > assignment to reclaim_order into a dead store, as in all further paths, > reclaim_order will be assigned again before it is used. > > make clang-analyzer on x86_64 tinyconfig caught my attention with: > > mm/vmscan.c: warning: Although the value stored to 'reclaim_order' is > used in the enclosing expression, the value is never actually read from > 'reclaim_order' [clang-analyzer-deadcode.DeadStores] > > Compilers will detect this unneeded assignment and optimize this anyway. > So, the resulting binary is identical before and after this change. > > Simplify the code and remove unneeded assignment to make clang-analyzer > happy. > > No functional change. No change in binary code. > > Signed-off-by: Lukas Bulwahn I'm not really keen on this. With the patch, reclaim_order can be passed uninitialised to kswapd_try_to_sleep. While a sufficiently smart compiler might be able to optimise how reclaim_order is used, it's not guaranteed either. Similarly, a change in kswapd_try_to_sleep and its called functions could rely on reclaim_order being a valid value and then introduce a subtle bug. -- Mel Gorman SUSE Labs