Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2240763ybz; Sun, 26 Apr 2020 14:24:28 -0700 (PDT) X-Google-Smtp-Source: APiQypLOiJHwjB52TandR+FFfbq2ZySCX8x/7hK5rOUMRujZHXUGCqng+XlFKRwcNn+fFRDCzWW1 X-Received: by 2002:aa7:ca48:: with SMTP id j8mr15593475edt.328.1587936267995; Sun, 26 Apr 2020 14:24:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587936267; cv=none; d=google.com; s=arc-20160816; b=SxN5BI2ojlPCD7c1BbGptukCxD4ztOYRzyNl5HBdXyHfDSCjYHi9x+S5oNkOIDLpss RG9diM86DVsiEoFJHl0PgrzTWi6/2BOUZvkEcK5R6bAXzcilZgtQtczjb2svbTsk/OrT P6meptrgj5ZZVzdTi7E86kmpVReQcT8b0LLAuAMV5OhLZHI1VCPO2ERiRkjZb5CJeg9g wCM7S4AxFtauq4NiM9701u7R5AVsGRG1UKnR2zzDaowqtLXHLfzgjXzkpKhGLcvCVLpS KenK4XKNwF6hwJIJPr6Ph50VTKtupfG5Ic+BcCnAd8w+Yj6CarhPvYI/YzJ9VWTFnDFM Uj3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=BjvPjhl3FfO2FNQfurAQAhXjPjZlH3zWtbKhfmVQ/uo=; b=mxsRGYM1Vr4LZMNGoiy1WEE0UF0bNgIljlj85mU1KDlhDaQoV+t0wbRB/FT4ao3q2I K4VxF6xFbDEFH8Vc0cNBwYVYi4ZI9lISHz2DpAp/w+HORlPBz2Y9uNkmLQvE49tSIxYW pccT7kyF+OUmHvGwRvz6bPS/83w+cBsyoGq9WpZKnU905ulScBLFloD8gTeOaLnLa5Nn GPjdC0yDfGxGohLCAt7y7/ZAEYhss9FgC8cy8Tm0/cEWYFQPKoQPvKEKNKcxUEe0AQoN pfRgJ8ig/QIfOwQ3hT0ILDWhUJCamXxfOk5uw9aYxGSXLbO83uRo7vjB+udJ/4GmnDlV h7ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oloDzFST; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h20si3636473ejb.126.2020.04.26.14.24.03; Sun, 26 Apr 2020 14:24:27 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oloDzFST; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726234AbgDZVUD (ORCPT + 99 others); Sun, 26 Apr 2020 17:20:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725996AbgDZVUC (ORCPT ); Sun, 26 Apr 2020 17:20:02 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03FB5C061A0F for ; Sun, 26 Apr 2020 14:20:01 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id u16so18144560wmc.5 for ; Sun, 26 Apr 2020 14:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=BjvPjhl3FfO2FNQfurAQAhXjPjZlH3zWtbKhfmVQ/uo=; b=oloDzFSTSo97AMs4LU21xavzxmzRB265Ud9P8mCCmGB29fP5Uhwod2XqEgrgalryEK VUNAIJcl8Srkpy3Yq+JR02qXT0Hbx9sGdApKGNh1Oyh5UonfIiPNG7i+wnxVN+no604D te66H2jawzn1GDEQF30dn1Y9JH4Yyc5pGpA4HEHYvejeVfAoy4pXpkNU1xpkcOpnmbdD zRiZRZ7Y6q0dVj8p8LIqPYQPX0oTiN+oJ8/4ZUOBNMTdm42JyK8jd964sm/5klMU+92c 9N4Hs8+HA+rFMl8ak368mr9egGuUOlC06KfpCofLqw2hHDjKqunXBTY7v6pMbfHiiz9/ jb2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=BjvPjhl3FfO2FNQfurAQAhXjPjZlH3zWtbKhfmVQ/uo=; b=DGazn9EY1OV308OxFot7/nENGGsYzT4lWvW4WR/5shykDf13CGsO+xtVxHo95OUy8v zEKVLFw1TZh9AA3MDyoQBYvOVeHp+ReTxrd1mjHqPtaOpDBbSd4T3fgQ3IWFgHUv3bJy gtoEoAGmi7ZIJwG53I0UjHeHr78OD6wj/UwlsIdMF7v5uPXZdUXz3k5oEj11ZaTEJLS4 kS27NA8ZO8/RVLH3QYtDyLv0+q2GdZvJZJOcZ8eleaef+ynZNtDiCE5BB4OSZJ9x3NH2 pUDi3aAIOISeCLnf4i2Iv+BpXso+8TmQgLZp6/J3yzHwHux8zeWfMtW5NWmrBVv6En6t rgfQ== X-Gm-Message-State: AGi0PubK64P74Lm1Po0jdjLvT/HV8RP3rfvKLsevH1/YMVYXEIh+rLrp R2ztaMRDK59G8AM1aKbPlC8= X-Received: by 2002:a1c:4d18:: with SMTP id o24mr21599480wmh.141.1587935999751; Sun, 26 Apr 2020 14:19:59 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id z2sm17756359wrm.77.2020.04.26.14.19.58 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 26 Apr 2020 14:19:59 -0700 (PDT) Date: Sun, 26 Apr 2020 21:19:58 +0000 From: Wei Yang To: "Huang, Ying" Cc: Wei Yang , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hugh Dickins Subject: Re: [PATCH v2] mm/swapfile.c: simplify the scan loop in scan_swap_map_slots() Message-ID: <20200426211958.m7aheswirqaj2nte@master> Reply-To: Wei Yang 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> <87tv17xdfk.fsf@yhuang-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87tv17xdfk.fsf@yhuang-dev.intel.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 26, 2020 at 09:07:11AM +0800, Huang, Ying wrote: >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. When (offset > scan_base), (offset > si->highest_bit) means offset will be set to si->lowest_bit. When (offset < scan_base), next_offset() would always increase offset till offset is scan_base. Sorry, I didn't catch your case. Would you minding giving more detail? > >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 -- Wei Yang Help you, Help me