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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 5CC1FC433B4 for ; Wed, 19 May 2021 04:49:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 30B2E6139A for ; Wed, 19 May 2021 04:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239388AbhESEvN (ORCPT ); Wed, 19 May 2021 00:51:13 -0400 Received: from mga09.intel.com ([134.134.136.24]:38613 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233017AbhESEvN (ORCPT ); Wed, 19 May 2021 00:51:13 -0400 IronPort-SDR: t31QHTNP7mCmOvNy3s7ickG8SuO2J5WfeUd+GRNAqhOza397cnXSpS258iNirSy31wgLbRis/s dy2l0r2QFlgg== X-IronPort-AV: E=McAfee;i="6200,9189,9988"; a="200938056" X-IronPort-AV: E=Sophos;i="5.82,311,1613462400"; d="scan'208";a="200938056" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 21:49:53 -0700 IronPort-SDR: EjMpw5x3wLmFSP9vcT3lkkifFPgbcaKC04jAkPbcnkt93rTuIVCPjbVRe3LmHQ6dtuaQzyUNrF NLyuMV2HbJ1w== X-IronPort-AV: E=Sophos;i="5.82,311,1613462400"; d="scan'208";a="473303825" 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:49:49 -0700 From: "Huang, Ying" To: Linus Torvalds Cc: Andrew Morton , Linux-MM , Linux Kernel Mailing List , Matthew Wilcox , Peter Xu , Hugh Dickins , Johannes Weiner , Mel Gorman , Rik van Riel , 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> Date: Wed, 19 May 2021 12:49:47 +0800 In-Reply-To: (Linus Torvalds's message of "Tue, 18 May 2021 17:25:50 -1000") Message-ID: <878s4b9vkk.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 Linus Torvalds writes: > On Tue, May 18, 2021 at 5:17 PM Linus Torvalds > wrote: >> >> This looks sensible to me (and numbers talk!), but as Rik says, it >> would probably be a good idea to move the trylock_page()/unlock_page() >> into try_to_free_idle_swapcache(), and that would make the calling >> side a whole lot cleaner and easier to read. > > To keep the error handling simple, and keep that "if that didn't work, > just return" logic in you had, doing it as two functions like: > > static inline void locked_try_to_free_idle_swapcache(struct page *page) > { .. your current try_to_free_idle_swapcache() .. } > > void try_to_free_idle_swapcache(struct page *page) > { > if (trylock_page(page)) { > locked_try_to_free_idle_swapcache(page); > unlock_page(page); > } > } > > would keep that readability and simplicity. > > And then the wp_page_copy() code ends up being > > if (page_copied && PageSwapCache(old_page) && !page_mapped(old_page)) > try_to_free_idle_swapcache(old_page); > > which looks pretty sensible to me: if we copied the page, and the old > page is a no longer mapped swap cache page, let's try to free it. > > That's still a hell of a long conditional, partly because of those > long names. But at least it's conceptually fairly straightforward and > easy to understand what's going on. Thanks! That looks much better. I will do that in the next version. Best Regards, Huang, Ying