Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1716907pxj; Wed, 19 May 2021 12:12:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy40+eRRjvkmuiLQyGfgJcUICZN/SWNzEVSaN12koHUWijPKFQy7aBGC+SsSAtN3oYsnRYP X-Received: by 2002:a05:6402:268f:: with SMTP id w15mr559123edd.321.1621451570749; Wed, 19 May 2021 12:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621451570; cv=none; d=google.com; s=arc-20160816; b=re8Sd8OtiyC8fXRPX2Gv+ouM3PAlW7t7J8KScQblC2aTEjQQHux2jzoMh9XIgH/wmh 7lxgw8FWL+Jfpfs81L+6X8POqqMQ8tej0uPXsZchQYnngJnb6r9iAFLQ1voba2fJvbFA VXiAwhnfW25B4PsdoJ6Sk2mh2hzG6JFcOFn4z1sR5cgY4g6+GWX7FO+D83hdTpzkcVO9 DohthEaIFIbGyjy4xt3duFJImxvlBRArFwjdD0cvvBBHnS9YBMxSFsX5AO3TujGi4smx D9TCRn626GdH44zrd7tKfhG633y5UUKHiGoyRVItpLVVHrYKT/DF/jEHKznLgLOMJhhk QXRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=yQ5worGqY8UwUP+HjOMKHNg5qmPOgVOuPEFJe9YxEVk=; b=Mwxc0AshotsZwtNs03+DUg1OFCJTpESY6b1LdkNF2yYbCt/1h1aCVNLIDQElb1Z3YK rJtyEjZ/jFU7O+mE75EKegkBNxIIAIGpj2lialXbNEsaeXePOk/wv9MJdWaMliUlrUCa SnqAgO+pHptuOo3KgV+UWtOvAY0oS/VHSA9Up+MelxdYAE7j8MyFrUacj+fcQhu5EJhh dfk7ddQCQ+uzu9628PAizVCl6E0uL9DvCp8gowVV4+MXy1RsRQUYR1GGmMEZyXzLEv0A HWxSsXMKm2fkoxL7WVCYVVH6lNfOKQj19bcWdo7O6RJxynF1HmSyo+UXzJ8SLyXrVutD g+GQ== 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 dp16si502338ejc.642.2021.05.19.12.12.26; Wed, 19 May 2021 12:12:50 -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 S236185AbhESE5d (ORCPT + 99 others); Wed, 19 May 2021 00:57:33 -0400 Received: from mga02.intel.com ([134.134.136.20]:31958 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233899AbhESE5d (ORCPT ); Wed, 19 May 2021 00:57:33 -0400 IronPort-SDR: l3PdbIXMTLTTAHloFoMWMg6CBasRB9wASDF/ShK3O6vCzi9PYAT3plwyAZwDLgJtngfJF9BGMd +LtV/SUSEWHw== X-IronPort-AV: E=McAfee;i="6200,9189,9988"; a="188018222" X-IronPort-AV: E=Sophos;i="5.82,311,1613462400"; d="scan'208";a="188018222" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 21:56:14 -0700 IronPort-SDR: MWjdBhhnnYyx3rnpRhA4yOtG/fNc/QcDIkcHqNrgPJvBNOQtuzATJHHPYhC2/GcEYWWCg4b7mz zkCOsQz4jczQ== X-IronPort-AV: E=Sophos;i="5.82,311,1613462400"; d="scan'208";a="473305424" Received: from yhuang6-desk1.sh.intel.com (HELO yhuang6-desk1.ccr.corp.intel.com) ([10.239.13.1]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 21:56:10 -0700 From: "Huang, Ying" To: Rik van Riel Cc: Andrew Morton , , , Matthew Wilcox , Linus Torvalds , "Peter Xu" , Hugh Dickins , Johannes Weiner , Mel Gorman , Andrea Arcangeli , Michal Hocko , Dave Hansen , Tim Chen Subject: Re: [PATCH] mm: move idle swap cache pages to the tail of LRU after COW References: <20210519013313.1274454-1-ying.huang@intel.com> <7b2525ba7871e6b8ce3f48cfd2375804a6791a94.camel@surriel.com> Date: Wed, 19 May 2021 12:56:08 +0800 In-Reply-To: <7b2525ba7871e6b8ce3f48cfd2375804a6791a94.camel@surriel.com> (Rik van Riel's message of "Tue, 18 May 2021 22:12:42 -0400") Message-ID: <874kez9v9z.fsf@yhuang6-desk1.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rik van Riel writes: > On Wed, 2021-05-19 at 09:33 +0800, Huang Ying wrote: > >> To test the patch, we used pmbench memory accessing benchmark with >> working-set larger than available memory on a 2-socket Intel server >> with a NVMe SSD as swap device. Test results shows that the pmbench >> score increases up to 21.8% with the decreased size of swap cache and >> swapin throughput. > > Nice! > >> +++ b/mm/memory.c >> @@ -3012,6 +3012,11 @@ static vm_fault_t wp_page_copy(struct vm_fault >> *vmf) >> munlock_vma_page(old_page); >> unlock_page(old_page); >> } >> + if (page_copied && PageSwapCache(old_page) && >> + !page_mapped(old_page) && trylock_page(old_page)) { >> + try_to_free_idle_swapcache(old_page); >> + unlock_page(old_page); >> + } > > That's quite the if condition! > > Would it make sense to move some of the tests, as well > as the trylock and unlock into try_to_free_idle_swapcache() > itself? Sure. Will put trylock/unlock into try_to_free_idle_swapcache() as suggested by Linus. > Especially considering that page_mapped is already tested > in that function, too... The two page_mapped() tests are intended. The first one is a quick check with the page unlocked, the second one is to confirm with the page locked. Because if the page is unlocked, the swap count may be transited to map count or vice versa. Best Regards, Huang, Ying