Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3137935ybz; Sun, 19 Apr 2020 18:44:00 -0700 (PDT) X-Google-Smtp-Source: APiQypKpokMa0hgajXfi6LwmtnqNKnVvXg3AJTIPLlkPI2sGf/qJEt1tPDIy4oIcOankp6cKZIvz X-Received: by 2002:a17:906:35d0:: with SMTP id p16mr13435118ejb.77.1587347040110; Sun, 19 Apr 2020 18:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587347040; cv=none; d=google.com; s=arc-20160816; b=A8voZFaFSuB4takvpMfOIIIKKFnFcYYi+gz/TSa7IsP4+nHTgQpwZUFA7SnAFwvnOv j7ODsHSD5i6k/iwToG+2t383XHUYiYN0s28plq+QhQjAlfl8gHVDiesJkMf4Rdf5J8iJ Ngy8VcUw1Ng6M5s8AOn0Y5elR+pRfzuuz5axfcS8AnRFiupwezMIxwGTgEZmvAK0zd3Q v4DqRsyM/q+s260/x+2YQMwqOHvKLdHJTNo6Thk7QQE/gNUQVGR/95HQ06hp96s8F7p0 wJLRezZQcYTDtFcUxJZASce24oiCYbeQE0GgRUEucyQYaudUPl+r3xej49CDL5Fv9EqP IBoQ== 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=78k6bL4NHTltMlMhhfkPI/ElhQidRVtJpxS98nOCmOA=; b=IInOov8iQ2CCkKoo8QpkTN5RB5xE89VaOEHh7drPUR+2D5wWSW8h6o+4hhCylYRZsS PWBOoVTrm45OWnzW8tRPwqrcBhlGuKQe7uUSsByvHNw9hYcC/ct4SkzzHQ0wJmfPNpyq o4UzCvGQr6nP5bLLaPHUG/R3gPR1fl1vU2fu9QDizmoxRTyTRCT0RvN3DA41HFFZbweJ WMQSHUvrN7L1xGWVy0LY6XhiFy7SLkzbp7nqwZoo+DhqAKfElI9RxhmTgBqlPk/UEjwq qS0eZshaVgrBEDF5hbI3cnYuda0AITUgMLYL37UMAb7qqah2YxrGhkjuOX9IrOo+uweJ biTg== 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 bs10si8836229edb.429.2020.04.19.18.43.36; Sun, 19 Apr 2020 18:44:00 -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 S1726039AbgDTBlq (ORCPT + 99 others); Sun, 19 Apr 2020 21:41:46 -0400 Received: from mga01.intel.com ([192.55.52.88]:62195 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725949AbgDTBlp (ORCPT ); Sun, 19 Apr 2020 21:41:45 -0400 IronPort-SDR: k63PrsX+EFjpAUiRPi3dYAdXjG8EGqHL497ByXXBVIHwuWrM28wfonsSS8yAVrvCKDQ6KhXLhE SaDWJyhZ4Htg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2020 18:41:45 -0700 IronPort-SDR: cQywvut7KlsssAmI6HgQ7kpCWGMEr1J7+8bZivrKwjlPT0m2qEsYrcVay35ImJ9Ich05Z+vfMv /YXBPe0W1wlw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,405,1580803200"; d="scan'208";a="455470756" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by fmsmga005.fm.intel.com with ESMTP; 19 Apr 2020 18:41:44 -0700 From: "Huang\, Ying" To: Wei Yang Cc: , , , Subject: Re: [PATCH 4/4] mm/swapfile.c: move new_cluster to check free_clusters directly References: <20200419013921.14390-1-richard.weiyang@gmail.com> <20200419013921.14390-4-richard.weiyang@gmail.com> Date: Mon, 20 Apr 2020 09:41:43 +0800 In-Reply-To: <20200419013921.14390-4-richard.weiyang@gmail.com> (Wei Yang's message of "Sun, 19 Apr 2020 01:39:21 +0000") Message-ID: <87blnnszl4.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: > Each time it needs jump to new_cluster, it is sure current > percpu_cluster is null. > > Move the new_cluster to check free_clusters directly. > > Signed-off-by: Wei Yang > --- > mm/swapfile.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 07b0bc095411..78e92ff14c79 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -603,9 +603,9 @@ static bool scan_swap_map_try_ssd_cluster(struct swap_info_struct *si, > struct swap_cluster_info *ci; > unsigned long tmp, max; > > -new_cluster: > cluster = this_cpu_ptr(si->percpu_cluster); > if (cluster_is_null(&cluster->index)) { > +new_cluster: > if (!cluster_list_empty(&si->free_clusters)) { > cluster->index = si->free_clusters.head; > cluster->next = cluster_next(&cluster->index) * In swap_do_scheduled_discard(), we will unlock si->lock, so the percpu_cluster may be changed after we releasing the lock. Or the current thread may be moved to a different CPU. Best Regards, Huang, Ying