All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zi Yan <ziy@nvidia.com>
To: Huang Ying <ying.huang@intel.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Yang Shi <shy828301@gmail.com>, Greg Thelen <gthelen@google.com>,
	Michal Hocko <mhocko@suse.com>, Wei Xu <weixugc@google.com>,
	David Rientjes <rientjes@google.com>,
	Dan Williams <dan.j.williams@intel.com>,
	David Hildenbrand <david@redhat.com>,
	osalvador <osalvador@suse.de>
Subject: Re: [PATCH -V8 07/10] mm/vmscan: add helper for querying ability to age anonymous pages
Date: Fri, 18 Jun 2021 11:45:50 -0400	[thread overview]
Message-ID: <9E787EAE-BED4-4902-B34D-F08FD8F21D76@nvidia.com> (raw)
In-Reply-To: <20210618061537.434999-8-ying.huang@intel.com>

[-- Attachment #1: Type: text/plain, Size: 3250 bytes --]

On 18 Jun 2021, at 2:15, Huang Ying wrote:

> From: Dave Hansen <dave.hansen@linux.intel.com>
>
> Anonymous pages are kept on their own LRU(s).  These lists could
> theoretically always be scanned and maintained.  But, without swap,
> there is currently nothing the kernel can *do* with the results of a
> scanned, sorted LRU for anonymous pages.
>
> A check for '!total_swap_pages' currently serves as a valid check as
> to whether anonymous LRUs should be maintained.  However, another
> method will be added shortly: page demotion.
>
> Abstract out the 'total_swap_pages' checks into a helper, give it a
> logically significant name, and check for the possibility of page
> demotion.
>
> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
> Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
> Reviewed-by: Yang Shi <shy828301@gmail.com>
> Reviewed-by: Greg Thelen <gthelen@google.com>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Wei Xu <weixugc@google.com>
> Cc: David Rientjes <rientjes@google.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: osalvador <osalvador@suse.de>
> ---
>  mm/vmscan.c | 28 +++++++++++++++++++++++++---
>  1 file changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 7d5c7216a4b7..8654cec65522 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -2706,6 +2706,26 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
>  	}
>  }
>
> +/*
> + * Anonymous LRU management is a waste if there is
> + * ultimately no way to reclaim the memory.
> + */
> +bool anon_should_be_aged(struct lruvec *lruvec)
> +{
> +	struct pglist_data *pgdat = lruvec_pgdat(lruvec);
> +
> +	/* Aging the anon LRU is valuable if swap is present: */
> +	if (total_swap_pages > 0)
> +		return true;
> +
> +	/* Also valuable if anon pages can be demoted: */
> +	if (next_demotion_node(pgdat->node_id) >= 0)

!= NUMA_NO_NODE might be better, even though we know NUMA_NO_NODE
is currently set to -1.

> +		return true;
> +
> +	/* No way to reclaim anon pages.  Should not age anon LRUs: */
> +	return false;
> +}
> +
>  static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)
>  {
>  	unsigned long nr[NR_LRU_LISTS];
> @@ -2815,7 +2835,8 @@ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)
>  	 * Even if we did not try to evict anon pages at all, we want to
>  	 * rebalance the anon lru active/inactive ratio.
>  	 */
> -	if (total_swap_pages && inactive_is_low(lruvec, LRU_INACTIVE_ANON))
> +	if (anon_should_be_aged(lruvec) &&
> +	    inactive_is_low(lruvec, LRU_INACTIVE_ANON))
>  		shrink_active_list(SWAP_CLUSTER_MAX, lruvec,
>  				   sc, LRU_ACTIVE_ANON);
>  }
> @@ -3644,10 +3665,11 @@ static void age_active_anon(struct pglist_data *pgdat,
>  	struct mem_cgroup *memcg;
>  	struct lruvec *lruvec;
>
> -	if (!total_swap_pages)
> +	lruvec = mem_cgroup_lruvec(NULL, pgdat);
> +
> +	if (!anon_should_be_aged(lruvec))
>  		return;
>
> -	lruvec = mem_cgroup_lruvec(NULL, pgdat);
>  	if (!inactive_is_low(lruvec, LRU_INACTIVE_ANON))
>  		return;
>
> -- 
> 2.30.2


—
Best Regards,
Yan, Zi

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 854 bytes --]

  reply	other threads:[~2021-06-18 15:46 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-18  6:15 [PATCH -V8 00/10] Migrate Pages in lieu of discard Huang Ying
2021-06-18  6:15 ` [PATCH -V8 01/10] mm/numa: node demotion data structure and lookup Huang Ying
2021-06-18  6:15 ` [PATCH -V8 02/10] mm/numa: automatically generate node migration order Huang Ying
2021-06-18 15:14   ` Zi Yan
2021-06-19  8:18     ` Huang, Ying
2021-06-19  8:18       ` Huang, Ying
2021-06-21 14:50       ` Zi Yan
2021-06-22  1:14         ` Huang, Ying
2021-06-22  1:14           ` Huang, Ying
2021-06-22 12:13           ` Dave Hansen
2021-06-22 12:06         ` Dave Hansen
2021-06-22 12:48           ` Zi Yan
2021-06-21 19:51       ` Yang Shi
2021-06-21 19:51         ` Yang Shi
2021-06-22  0:55         ` Huang, Ying
2021-06-22  0:55           ` Huang, Ying
2021-06-21 19:53       ` Dave Hansen
2021-06-22  0:54         ` Huang, Ying
2021-06-22  0:54           ` Huang, Ying
2021-06-18  6:15 ` [PATCH -V8 03/10] mm/migrate: update node demotion order during on hotplug events Huang Ying
2021-06-18  6:15 ` [PATCH -V8 04/10] mm/migrate: make migrate_pages() return nr_succeeded Huang Ying
2021-06-18  7:53   ` Oscar Salvador
2021-06-18  8:15     ` Huang, Ying
2021-06-18  8:15       ` Huang, Ying
2021-06-18  6:15 ` [PATCH -V8 05/10] mm/migrate: demote pages during reclaim Huang Ying
2021-06-18 15:42   ` Zi Yan
2021-06-19  7:45     ` Huang, Ying
2021-06-19  7:45       ` Huang, Ying
2021-06-21 19:58       ` Yang Shi
2021-06-21 19:58         ` Yang Shi
2021-06-22  2:09         ` Huang, Ying
2021-06-22  2:09           ` Huang, Ying
2021-06-22 17:15           ` Yang Shi
2021-06-22 17:15             ` Yang Shi
2021-06-22 18:15             ` Zi Yan
2021-06-23  2:19             ` Huang, Ying
2021-06-23  2:19               ` Huang, Ying
2021-06-18  6:15 ` [PATCH -V8 06/10] mm/vmscan: add page demotion counter Huang Ying
2021-06-18  6:15 ` [PATCH -V8 07/10] mm/vmscan: add helper for querying ability to age anonymous pages Huang Ying
2021-06-18 15:45   ` Zi Yan [this message]
2021-06-19  2:33     ` Huang, Ying
2021-06-19  2:33       ` Huang, Ying
2021-06-18  6:15 ` [PATCH -V8 08/10] mm/vmscan: Consider anonymous pages without swap Huang Ying
2021-06-18  6:15 ` [PATCH -V8 09/10] mm/vmscan: never demote for memcg reclaim Huang Ying
2021-06-18  6:15 ` [PATCH -V8 10/10] mm/migrate: add sysfs interface to enable reclaim migration Huang Ying
2021-06-22  9:00 ` [PATCH -V8 00/10] Migrate Pages in lieu of discard Oscar Salvador
2021-06-23  1:12   ` Huang, Ying
2021-06-23  1:12     ` Huang, Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9E787EAE-BED4-4902-B34D-F08FD8F21D76@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=david@redhat.com \
    --cc=gthelen@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=osalvador@suse.de \
    --cc=rientjes@google.com \
    --cc=shy828301@gmail.com \
    --cc=weixugc@google.com \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.