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=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 91339C55186 for ; Sun, 26 Apr 2020 01:07:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 565A4206DD for ; Sun, 26 Apr 2020 01:07:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 565A4206DD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 06B368E0005; Sat, 25 Apr 2020 21:07:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 01BDC8E0003; Sat, 25 Apr 2020 21:07:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E73D78E0005; Sat, 25 Apr 2020 21:07:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0106.hostedemail.com [216.40.44.106]) by kanga.kvack.org (Postfix) with ESMTP id CC3A38E0003 for ; Sat, 25 Apr 2020 21:07:15 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8C3FB8248047 for ; Sun, 26 Apr 2020 01:07:15 +0000 (UTC) X-FDA: 76748217630.20.bean97_223038b95fd57 X-HE-Tag: bean97_223038b95fd57 X-Filterd-Recvd-Size: 2891 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Sun, 26 Apr 2020 01:07:14 +0000 (UTC) IronPort-SDR: 46oqNuV7VJndPtDpX1A32fou6b4zTFlWahZ3xUPdo6/Y1y3X7BS6uzkHjdwy/xHnEXKVxGdiZm G14LOnV+fvPQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2020 18:07:13 -0700 IronPort-SDR: /6Hcha58W/8wp1T7uAZ5Kt+wyz24uAV0VhKBR3cC8j25XPuZORYv3JiVO9PTML6R7HlKedGf/6 gzuj37e+4+wA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,318,1583222400"; d="scan'208";a="281265179" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by fmsmga004.fm.intel.com with ESMTP; 25 Apr 2020 18:07:11 -0700 From: "Huang\, Ying" To: Wei Yang Cc: , , , Hugh Dickins Subject: Re: [PATCH v2] mm/swapfile.c: simplify the scan loop in scan_swap_map_slots() References: <20200422214111.19370-1-richard.weiyang@gmail.com> <87d07y2181.fsf@yhuang-dev.intel.com> <20200423131507.2rgrk3okh42oo6gh@master> <87r1wdzlm5.fsf@yhuang-dev.intel.com> <20200425003012.uuqh547feq3kz4y5@master> Date: Sun, 26 Apr 2020 09:07:11 +0800 In-Reply-To: <20200425003012.uuqh547feq3kz4y5@master> (Wei Yang's message of "Sat, 25 Apr 2020 00:30:12 +0000") Message-ID: <87tv17xdfk.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii 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: Wei Yang writes: > On Fri, Apr 24, 2020 at 10:02:58AM +0800, Huang, Ying wrote: >>Wei Yang writes: >> > [...] >>>> >>>>if "offset > si->highest_bit" is true and "offset < scan_base" is true, >>>>scan_base need to be returned. >>>> >>> >>> When this case would happen in the original code? >> >>In the original code, the loop can still stop. >> > > Sorry, I don't get your point yet. > > In original code, there are two separate loops > > while (++offset <= si->highest_bit) { > } > > while (offset < scan_base) { > } > > And for your condition, (offset > highest_bit) && (offset < scan_base), which > terminates the first loop and fits the second loop well. > > Not sure how this condition would stop the loop in original code? Per my understanding, in your code, if some other task changes si->highest_bit to be less than scan_base in parallel. The loop may cannot stop. Best Regards, Huang, Ying >>Best Regards, >>Huang, Ying >> >>>>Again, the new code doesn't make it easier to find this kind of issues. >>>> >>>>Best Regards, >>>>Huang, Ying