From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752150AbcI1IsX (ORCPT ); Wed, 28 Sep 2016 04:48:23 -0400 Received: from out0-154.mail.aliyun.com ([140.205.0.154]:35594 "EHLO out0-154.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751634AbcI1IsP (ORCPT ); Wed, 28 Sep 2016 04:48:15 -0400 X-Greylist: delayed 322 seconds by postgrey-1.27 at vger.kernel.org; Wed, 28 Sep 2016 04:48:15 EDT X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e02c03299;MF=hillf.zj@alibaba-inc.com;NM=1;PH=DS;RN=17;SR=0;TI=SMTPD_---.7.g9jSR_1475052142; Reply-To: "Hillf Danton" From: "Hillf Danton" To: , "'Andrew Morton'" Cc: , , , , , "'Huang Ying'" , "'Hugh Dickins'" , "'Shaohua Li'" , "'Minchan Kim'" , "'Rik van Riel'" , "'Andrea Arcangeli'" , "'Kirill A . Shutemov'" , "'Vladimir Davydov'" , "'Johannes Weiner'" , "'Michal Hocko'" References: <20160927171804.GA17845@linux.intel.com> In-Reply-To: <20160927171804.GA17845@linux.intel.com> Subject: Re: [PATCH 2/8] mm/swap: Add cluster lock Date: Wed, 28 Sep 2016 16:42:21 +0800 Message-ID: <004101d21964$3b3d68f0$b1b83ad0$@alibaba-inc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQIXubZHA93R0NvpmaxLyEvIQ0DjsaADUTqg Content-Language: zh-cn Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday, September 28, 2016 1:18 AM Tim Chen wrote > > @@ -447,8 +505,9 @@ static void scan_swap_map_try_ssd_cluster(struct swap_info_struct *si, > unsigned long *offset, unsigned long *scan_base) > { > struct percpu_cluster *cluster; > + struct swap_cluster_info *ci; > bool found_free; > - unsigned long tmp; > + unsigned long tmp, max; > > new_cluster: > cluster = this_cpu_ptr(si->percpu_cluster); > @@ -476,14 +535,21 @@ new_cluster: > * check if there is still free entry in the cluster > */ > tmp = cluster->next; > - while (tmp < si->max && tmp < (cluster_next(&cluster->index) + 1) * > - SWAPFILE_CLUSTER) { Currently tmp is checked to be less than both values. > + max = max_t(unsigned long, si->max, > + (cluster_next(&cluster->index) + 1) * SWAPFILE_CLUSTER); > + if (tmp >= max) { > + cluster_set_null(&cluster->index); > + goto new_cluster; > + } > + ci = lock_cluster(si, tmp); > + while (tmp < max) { In this work tmp is checked to be less than the max value. Semantic change hoped? > if (!si->swap_map[tmp]) { > found_free = true; > break; > } > tmp++; > } > + unlock_cluster(ci); > if (!found_free) { > cluster_set_null(&cluster->index); > goto new_cluster; > thanks Hillf