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.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,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 65222C47258 for ; Fri, 1 May 2020 22:35:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 30EBF2166E for ; Fri, 1 May 2020 22:35:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30EBF2166E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B684A8E0005; Fri, 1 May 2020 18:35:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B18A38E0001; Fri, 1 May 2020 18:35:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2EA38E0005; Fri, 1 May 2020 18:35:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0055.hostedemail.com [216.40.44.55]) by kanga.kvack.org (Postfix) with ESMTP id 8C36F8E0001 for ; Fri, 1 May 2020 18:35:33 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 40D8F2492 for ; Fri, 1 May 2020 22:35:33 +0000 (UTC) X-FDA: 76769608146.30.goose39_4d83f71d29f30 X-HE-Tag: goose39_4d83f71d29f30 X-Filterd-Recvd-Size: 3624 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 1 May 2020 22:35:32 +0000 (UTC) IronPort-SDR: rEQjBxU9ee0k/8gJR4Q8zsFaOLitL+4wTVCHSVgwfCS2Tk045mmLZMS4v9OqAfe8VBN4a7ZL7a 9JtyT69Ugn3g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 May 2020 15:35:30 -0700 IronPort-SDR: UNgRkzx638fo1l4ebhI3DztWLWC8sss7yytwj3kuQf5HvXKhrllpZBjTnxH9XKYdo/j53vHHsz T0g92LcC0P0A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,341,1583222400"; d="scan'208";a="283310281" Received: from schen9-mobl.amr.corp.intel.com ([10.254.53.33]) by fmsmga004.fm.intel.com with ESMTP; 01 May 2020 15:35:28 -0700 Subject: Re: [PATCH 3/3] mm/swap: remove redundant check for swap_slot_cache_initialized To: Zhen Lei , Andrew Morton , linux-mm , linux-kernel References: <20200430061143.450-1-thunder.leizhen@huawei.com> <20200430061143.450-4-thunder.leizhen@huawei.com> From: Tim Chen Message-ID: <9b45c120-e369-d436-a369-6c80e3d6ee2e@linux.intel.com> Date: Fri, 1 May 2020 15:35:27 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200430061143.450-4-thunder.leizhen@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 4/29/20 11:11 PM, Zhen Lei wrote: > Because enable_swap_slots_cache can only become true in > enable_swap_slots_cache(), and depends on swap_slot_cache_initialized is > true before. That means, when enable_swap_slots_cache is true, > swap_slot_cache_initialized is true also. > > So the condition: > "swap_slot_cache_enabled && swap_slot_cache_initialized" > can be reduced to "swap_slot_cache_enabled" > > And in mathematics: > "!swap_slot_cache_enabled || !swap_slot_cache_initialized" > is equal to "!(swap_slot_cache_enabled && swap_slot_cache_initialized)" > > So no functional change. > > Signed-off-by: Zhen Lei > --- > mm/swap_slots.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/mm/swap_slots.c b/mm/swap_slots.c > index b40394473a3c..3e6453573a89 100644 > --- a/mm/swap_slots.c > +++ b/mm/swap_slots.c > @@ -46,8 +46,7 @@ static void __drain_swap_slots_cache(unsigned int type); > static void deactivate_swap_slots_cache(void); > static void reactivate_swap_slots_cache(void); > > -#define use_swap_slot_cache (swap_slot_cache_active && \ > - swap_slot_cache_enabled && swap_slot_cache_initialized) > +#define use_swap_slot_cache (swap_slot_cache_active && swap_slot_cache_enabled) Yes, swap_slot_cache_enabled does imply swap_slot_cache_initialized in current code. So checking swap_slot_cache_enabled is enough here. > #define SLOTS_CACHE 0x1 > #define SLOTS_CACHE_RET 0x2 > > @@ -94,7 +93,7 @@ static bool check_cache_active(void) > { > long pages; > > - if (!swap_slot_cache_enabled || !swap_slot_cache_initialized) > + if (!swap_slot_cache_enabled) This simplification is okay. !swap_slot_cache_initialize implies !swap_slot_cache_enabled. So only !swap_slot_cache_enabled needs to be checked. > return false; > > pages = get_nr_swap_pages(); > Acked-by: Tim Chen