Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp117784ybm; Thu, 28 May 2020 17:45:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNAZXUdX1WyW+nWJ2Wsw3zTWcg7IQHdYeVqGoQTXAdz8BoERwIOIvn7DM20ZDx9O7gaRYU X-Received: by 2002:a50:b2a1:: with SMTP id p30mr6009491edd.199.1590713155084; Thu, 28 May 2020 17:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590713155; cv=none; d=google.com; s=arc-20160816; b=u+Ch9lOsNTGGGgDXbQkNCOgYeT0w0+HxtHxOe1ULhXF3sBlKTatfBa1UwRzzDR/JN2 HorGnUmF3vZqJFHLoBu6weqe7oWQVwKrpsluqhD7NFBb0tYnuWhvPMaFrXIi1QEqiNzw z4C3Id93kHk4qwQe/7q7dikUJ2Ykcx4kS7D3ZIQDzQyDJxqz9jH1PhU578IZr+0IgK3S 5ci5SZwpDVf6pa9qA259bga6t0VFSJmXg6x8USmj3gGdbfALCyQAzxWklcQ9pjo/vysI ga2yApBz+dgo9WBoJG37NY88On0H2F+TMkqlzARlAYdmE2rJ0cbkGqFYkppxBl6KVvTF yNEQ== 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=mdSvkU1/o17xJWLJvFM+qqpcSDfj22LYT/dnPB3WfX8=; b=dKVNoFVjjycNaUeMBEjRK8NgG0xkAx0uVS2s+jFlYIpVkpmMbiSk8MT9HzNHflMSq2 NbHoFDaKQTLL3lkmDT5Cv2v3sf+xetlwKZgjl+vO1XA4osz1n9K0fpjpyXHz3MQgL/1i wjKzaIYipHusIuEBpRus9LGigAAdCvs+fPRGVCh1OUKz8Rqsv9l8lb1lwhqbnNCtgL7l 6tCQmvTaA0Bbla78fkkvCb5ODx7aOnsyGTtypCEwolVF5BDq5QaZvJ1ayUTO0wMIBqjy FrclaNzl7mZLHB9f5ce0JljX9PhwBnzhWJGHIo6gpO/YyMFUWnNfziLKs+EvzcX4d73s K3bg== 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 dc14si4678252ejb.209.2020.05.28.17.45.27; Thu, 28 May 2020 17:45:55 -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 S2438131AbgE2Anl (ORCPT + 99 others); Thu, 28 May 2020 20:43:41 -0400 Received: from mga05.intel.com ([192.55.52.43]:8370 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438025AbgE2Ank (ORCPT ); Thu, 28 May 2020 20:43:40 -0400 IronPort-SDR: GcVXFS4kucwKukI5Ciby9x4neJHbIgwJLUaXYoLUctImvMGEkXlTdMDofNf2VA2Z63XYjfRgEz 1JuYeQ7OxMXw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 17:43:38 -0700 IronPort-SDR: PqaarzZX7Yi1osYCcs7IgzXMAASpDZMBRF6CNogT0QED7yi3P//iQycjIXikmyhqIMDmyw6MDZ fv1uywGLbzLA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,446,1583222400"; d="scan'208";a="256344144" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by orsmga007.jf.intel.com with ESMTP; 28 May 2020 17:43:35 -0700 From: "Huang\, Ying" To: Daniel Jordan Cc: Andrew Morton , , , Michal Hocko , Minchan Kim , Tim Chen , Hugh Dickins Subject: Re: [PATCH -V3] swap: Reduce lock contention on swap cache from swap slots allocation References: <20200525002648.336325-1-ying.huang@intel.com> <20200528013724.flx6pwcmaazpek32@ca-dmjordan1.us.oracle.com> <87h7w0hbev.fsf@yhuang-dev.intel.com> <20200528171141.k3lc3mf7taqadv3v@ca-dmjordan1.us.oracle.com> Date: Fri, 29 May 2020 08:43:35 +0800 In-Reply-To: <20200528171141.k3lc3mf7taqadv3v@ca-dmjordan1.us.oracle.com> (Daniel Jordan's message of "Thu, 28 May 2020 13:11:41 -0400") Message-ID: <87d06nh8p4.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 Daniel Jordan writes: > On Thu, May 28, 2020 at 01:32:40PM +0800, Huang, Ying wrote: >> Daniel Jordan writes: >> >> > On Mon, May 25, 2020 at 08:26:48AM +0800, Huang Ying wrote: >> >> diff --git a/mm/swapfile.c b/mm/swapfile.c >> >> index 423c234aca15..0abd93d2a4fc 100644 >> >> --- a/mm/swapfile.c >> >> +++ b/mm/swapfile.c >> >> @@ -615,7 +615,8 @@ static bool scan_swap_map_try_ssd_cluster(struct swap_info_struct *si, >> >> * discarding, do discard now and reclaim them >> >> */ >> >> swap_do_scheduled_discard(si); >> >> - *scan_base = *offset = si->cluster_next; >> >> + *scan_base = this_cpu_read(*si->cluster_next_cpu); >> >> + *offset = *scan_base; >> >> goto new_cluster; >> > >> > Why is this done? As far as I can tell, the values always get overwritten at >> > the end of the function with tmp and tmp isn't derived from them. Seems >> > ebc2a1a69111 moved some logic that used to make sense but doesn't have any >> > effect now. >> >> If we fail to allocate from cluster, "scan_base" and "offset" will not >> be overridden. > > Ok, if another task races to allocate the clusters the first just discarded. > >> And "cluster_next" or "cluster_next_cpu" may be changed >> in swap_do_scheduled_discard(), because the lock is released and >> re-acquired there. > > I see, by another task on the same cpu for cluster_next_cpu. > > Both probably unlikely, but at least it tries to pick up where the racing task > left off. You might tack this onto the comment: > > * discarding, do discard now and reclaim them, then reread > * cluster_next_cpu since we dropped si->lock > /* Sure. Will add this in the next version. >> The code may not have much value. > > No, it makes sense. > >> > These aside, patch looks good to me. >> >> Thanks for your review! It really help me to improve the quality of the >> patch. Can I add your "Reviewed-by" in the next version? > > Sure, > Reviewed-by: Daniel Jordan Thanks! Best Regards, Huang, Ying