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=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 203C2C433DF for ; Tue, 2 Jun 2020 04:49:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D0D1A2074B for ; Tue, 2 Jun 2020 04:48:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="QO4BSyTW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D0D1A2074B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AC09E280026; Tue, 2 Jun 2020 00:48:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1D79280012; Tue, 2 Jun 2020 00:48:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9597B280026; Tue, 2 Jun 2020 00:48:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id 7D589280012 for ; Tue, 2 Jun 2020 00:48:51 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 4451F40D3 for ; Tue, 2 Jun 2020 04:48:51 +0000 (UTC) X-FDA: 76883041662.08.flock66_3025bf59b6e14 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 297801819E773 for ; Tue, 2 Jun 2020 04:48:51 +0000 (UTC) X-HE-Tag: flock66_3025bf59b6e14 X-Filterd-Recvd-Size: 2881 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Jun 2020 04:48:50 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E315B206C3; Tue, 2 Jun 2020 04:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591073330; bh=NjVtjjhHat/vJ3b6wgp1MbL5KzO6Yaj/nXz6pVK0j4s=; h=Date:From:To:Subject:In-Reply-To:From; b=QO4BSyTWtNOoRtPRCuGhH4ME2SXC0K8gjFfpUm9nxArBHhrpbKj9tVcfuIwtJECKH l7bMmlZI8kaGD9GGsuUh6jGl9xvu9KC1AfJC26pmSuSAt4keVh1Ydd+bjVqhY5qvmv EJOXzDazEhO7itlZoD9D7x+UrFhUlsc+FzbtFu28= Date: Mon, 01 Jun 2020 21:48:49 -0700 From: Andrew Morton To: akpm@linux-foundation.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, richard.weiyang@gmail.com, tim.c.chen@linux.intel.com, torvalds@linux-foundation.org Subject: [patch 062/128] mm/swapfile.c: explicitly show ssd/non-ssd is handled mutually exclusive Message-ID: <20200602044849.LMWYsBkqh%akpm@linux-foundation.org> In-Reply-To: <20200601214457.919c35648e96a2b46b573fe1@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Queue-Id: 297801819E773 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: From: Wei Yang Subject: mm/swapfile.c: explicitly show ssd/non-ssd is handled mutually exclusive The code shows if this is ssd, it will jump to specific tag and skip the following code for non-ssd. Let's use "else if" to explicitly show the mutually exclusion for ssd/non-ssd to reduce ambiguity. Link: http://lkml.kernel.org/r/20200328060520.31449-3-richard.weiyang@gmail.com Signed-off-by: Wei Yang Reviewed-by: Andrew Morton Cc: Tim Chen Signed-off-by: Andrew Morton --- mm/swapfile.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) --- a/mm/swapfile.c~mm-swapfilec-explicitly-show-ssd-non-ssd-is-handled-mutually-exclusive +++ a/mm/swapfile.c @@ -763,9 +763,7 @@ static int scan_swap_map_slots(struct sw goto checks; else goto scan; - } - - if (unlikely(!si->cluster_nr--)) { + } else if (unlikely(!si->cluster_nr--)) { if (si->pages - si->inuse_pages < SWAPFILE_CLUSTER) { si->cluster_nr = SWAPFILE_CLUSTER - 1; goto checks; @@ -873,10 +871,8 @@ checks: goto checks; else goto done; - } - - /* non-ssd case, still more slots in cluster? */ - if (si->cluster_nr && !si->swap_map[++offset]) { + } else if (si->cluster_nr && !si->swap_map[++offset]) { + /* non-ssd case, still more slots in cluster? */ --si->cluster_nr; goto checks; } _