Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1389969ybz; Sat, 25 Apr 2020 18:09:16 -0700 (PDT) X-Google-Smtp-Source: APiQypLAnJxlPkoV684dhHnvdGwEoJUkVfuzWWlQ/hLrSIYllSLEOoWfT04ffkv4AiV7zllNT6tC X-Received: by 2002:a17:906:2296:: with SMTP id p22mr13423569eja.269.1587863356828; Sat, 25 Apr 2020 18:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587863356; cv=none; d=google.com; s=arc-20160816; b=rITxpr5NGKuq+kL3XMlYCVFfMemYF6RcqsdLcCWQfeA1Rlv8nUHTR9J5R6KRzNeMGH j9U42ZhnDz80CURClsd4Pi59aplWQd+3ldEB8EJIs3F8ons0ZvaimNnNw11quSTdzlX3 Czb0Iu56DNAEGfblw18G5GH92qCIU4Zzwr9CbL8IefOD2PgzWbsg3j4defGG+wvWasGA mFQVyWPPQdEV0mSsxXpVL285sDbesGJ89g3W7nz8aOxkiz7MeQF6xqKPbjKuiKZW8chF h/6wJxvmyd4W6qjgQ7hokcdK80aNW0gOpCwhNbeKSjObr+o35XjHxxMixaKVhOLeztey uojQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=mN1BuopG01d1GM/mWUs2x8t5/fpy5e0udXizPs6iCZo=; b=u+DoGLsSZ4SWMT8Pji2ttnERnGtHeV9HsSRpqnZ7yHjL5xLI0GxTLFZEngrwEtArlJ FrNIZqpwcjny3cT6+7g71RL4Nk0NvtAhvzhbN7BegxNy+0Ecg4bo0AgdQQVZotPoAEqi 282ca/i4uWVNW9zhLXJ5e4pJ7U4WwQCoiAMLyybWgcl/SoPA2/SZd12Ky9JnC6TXYOnE DcO50gaT4Y3GqZ0c4m/rFBT8ZcpUUqLfsvlytk7JWaGkkhELKVfUOjKBO3TUUdrHRULJ 7RpQyqSK9fURUCmIZ0lBpTETwOkXZci9S3ZFtXLee76r2g88GejSkU6+SYSJrSggRl2V jKCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga21si5692152ejb.350.2020.04.25.18.08.52; Sat, 25 Apr 2020 18:09:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726112AbgDZBHO (ORCPT + 99 others); Sat, 25 Apr 2020 21:07:14 -0400 Received: from mga02.intel.com ([134.134.136.20]:63235 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbgDZBHN (ORCPT ); Sat, 25 Apr 2020 21:07:13 -0400 IronPort-SDR: 7nMZVM5FAP1m3v8Q3ihJ1Bt5fPC4tuKqZGXPY1nCbcBBu0/kF+NmXSADsrm7RVAUe7G6teqZL9 eA5ylzBBno2Q== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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