linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Zhiguo Jiang <justinjiang@vivo.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: opensource.kernel@vivo.com
Subject: Re: [PATCH] mm: shrink skip folio mapped by an exiting task
Date: Tue, 2 Jul 2024 15:26:08 +0200	[thread overview]
Message-ID: <9381d6e6-14f5-4499-9d7a-ed28aa16a3d1@redhat.com> (raw)
In-Reply-To: <20240221114904.1849-1-justinjiang@vivo.com>

On 21.02.24 12:49, Zhiguo Jiang wrote:
> If an anon folio reclaimed by shrink_inactive_list is mapped by an
> exiting task, this anon folio will be firstly swaped-out into
> swapspace in shrink flow and then this swap folio is freed in task
> exit flow. But if this folio mapped by an exiting task can skip
> shrink and be freed directly in task exiting flow, which will save
> swap-out time and alleviate the load of the tasks exiting process.
> The file folio is also similar.
> 
> And when system is low memory, it more likely to occur, because more
> backend applidatuions will be killed.
> 
> This patch can alleviate the load of the tasks exiting process.
> 
> Signed-off-by: Zhiguo Jiang <justinjiang@vivo.com>
> ---
>   mm/rmap.c | 7 +++++++
>   1 file changed, 7 insertions(+)
>   mode change 100644 => 100755 mm/rmap.c
> 
> diff --git a/mm/rmap.c b/mm/rmap.c
> index 3746a5531018..146e5f4ec069
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -840,6 +840,13 @@ static bool folio_referenced_one(struct folio *folio,
>   	int referenced = 0;
>   	unsigned long start = address, ptes = 0;
>   
> +	/* Skip this folio if it's mapped by an exiting task */
> +	if (unlikely(!atomic_read(&vma->vm_mm->mm_users)) ||
> +		unlikely(test_bit(MMF_OOM_SKIP, &vma->vm_mm->flags))) {
> +		pra->referenced = -1;
> +		return false;
> +	}
> +
>   	while (page_vma_mapped_walk(&pvmw)) {
>   		address = pvmw.address;
>   

... but what if it is shared among multiple processes and only one of 
them is exiting?

-- 
Cheers,

David / dhildenb



      parent reply	other threads:[~2024-07-02 13:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 11:49 Zhiguo Jiang
2024-06-30  9:35 ` Barry Song
2024-07-08  3:40   ` zhiguojiang
2024-07-08  3:54     ` Barry Song
2024-07-08  9:24       ` zhiguojiang
2024-07-02 13:26 ` David Hildenbrand [this message]

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=9381d6e6-14f5-4499-9d7a-ed28aa16a3d1@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=justinjiang@vivo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=opensource.kernel@vivo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox