From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E6D9C433B4 for ; Wed, 19 May 2021 04:56:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E5B6F61040 for ; Wed, 19 May 2021 04:56:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5B6F61040 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7A51B8E002F; Wed, 19 May 2021 00:56:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7075E6B0133; Wed, 19 May 2021 00:56:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A6E98E002F; Wed, 19 May 2021 00:56:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0230.hostedemail.com [216.40.44.230]) by kanga.kvack.org (Postfix) with ESMTP id 262EE6B0132 for ; Wed, 19 May 2021 00:56:20 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B9E88A751 for ; Wed, 19 May 2021 04:56:19 +0000 (UTC) X-FDA: 78156769278.32.37BF7BF Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf24.hostedemail.com (Postfix) with ESMTP id 99233A000399 for ; Wed, 19 May 2021 04:56:16 +0000 (UTC) IronPort-SDR: HO6SGBtjviF3PRCWnj14BWipqwIGg63uI1Y4P9eFTQPDxb91Kk0zKFfkF+JChj6Sq45k22mUk7 rkFwLMNfWRug== X-IronPort-AV: E=McAfee;i="6200,9189,9988"; a="197798430" X-IronPort-AV: E=Sophos;i="5.82,311,1613462400"; d="scan'208";a="197798430" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.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 X-Rspamd-Queue-Id: 99233A000399 Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf24.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.93) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam04 X-Stat-Signature: k7zfbq7n67f8ytkf8cnk43mw5xg9njmn X-HE-Tag: 1621400176-893431 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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