Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp1617166lkv; Wed, 19 May 2021 14:09:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT1x6EIk9cXVEO57sOPA1meif7vdvWqxW1zLalMaYBjhtqmgc5O+dwsgTT/GdATgcY569d X-Received: by 2002:a05:6e02:1bcb:: with SMTP id x11mr1171063ilv.87.1621458588605; Wed, 19 May 2021 14:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621458588; cv=none; d=google.com; s=arc-20160816; b=YY56+6jklq3WmpR/5sxxX/GNMT70pcyL9W7Q8CoKQUWdvpcRIXGUNMIMKdrBxvbdIX YXVQ+ecjPLgD/1uXdmTe7WAOBBQDm2cPKXEb0IlGTT1rkErC1zaG3l9BBpXWtJhCeIY/ IxRJ9EGtCsRFvBQ76NtsKBTOzBgoR/6WvwtYQnMCJpTq/w8ogD1+KvkIQJysgctaAhDN MehLCpr5JH27wHpH46292vfZQ8WJUO2H3jYYhaiqVIepS8pJ3cWK6V5WPODOciNQGrnY QdmpMcGT8+m8ttWOBWnb/c/kRYtYL12Af+XPz84/HAugsvZgDuGJyb+MmsQSF4NzaOb+ t5Hg== 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=UMi70XqBglfKCkX/+VYFIPtW+YrK4tJJTT+5msjqqHQ=; b=XDjmwf+EZsIwxJPIHJisK0P/D8Pv2Z35g7qVQEBdOFW/2QDomHl1zJniglwRUcXNK3 qIwuPqyKADMeMKddVtk4pZz4nFtzRfblK3MeZQfan5CSD+N7uq0hq8l1DRzbzwEhKfll 4vAmnOgUQYF+MNHpMpHQ8uUo2E2AztaGf9lDXEkavnoiQdCI04dTkGFUV7sYGQGWV5jI 1aBfNGkQg160AVMTNTaoIHc501vN8GalHdW/hIgDFkjFAx6bQOTClpaN9e0Pj8VkhX7E la8Au3tSUqJ/jsV0zkj0BBQqhQkhG6teERbH1494MHv6xSg457FSS69S/QK4OaFFA7J4 brdg== 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 f2si513070ioz.41.2021.05.19.14.09.35; Wed, 19 May 2021 14:09:48 -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 S237190AbhESEvN (ORCPT + 99 others); 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