linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Baolin Wang <baolin.wang@linux.alibaba.com>, akpm@linux-foundation.org
Cc: hughd@google.com, willy@infradead.org, 21cnbao@gmail.com,
	ryan.roberts@arm.com, shy828301@gmail.com, ziy@nvidia.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] mm: khugepaged: use the number of pages in the folio to check the reference count
Date: Mon, 19 Aug 2024 11:40:41 +0200	[thread overview]
Message-ID: <966bfe10-6123-48db-95b7-ade2f794700d@redhat.com> (raw)
In-Reply-To: <c6038c7e823d4162f745147628616f7876585a97.1724054125.git.baolin.wang@linux.alibaba.com>

On 19.08.24 10:14, Baolin Wang wrote:
> Use the number of pages in the folio to check the reference count as
> preparation for supporting shmem mTHP collapse.
> 
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
>   mm/khugepaged.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index f11b4f172e61..60d95f08610c 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -1994,7 +1994,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
>   		/*
>   		 * We control three references to the folio:

^ "three" is wrong now.

>   		 *  - we hold a pin on it;
> -		 *  - one reference from page cache;
> +		 *  - nr_pages reference from page cache;
>   		 *  - one from lru_isolate_folio;
>   		 * If those are the only references, then any new usage
>   		 * of the folio will have to fetch it from the page
> @@ -2002,7 +2002,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
>   		 * truncate, so any new usage will be blocked until we
>   		 * unlock folio after collapse/during rollback.
>   		 */
> -		if (folio_ref_count(folio) != 3) {
> +		if (folio_ref_count(folio) != 2 + folio_nr_pages(folio)) {
>   			result = SCAN_PAGE_COUNT;
>   			xas_unlock_irq(&xas);
>   			folio_putback_lru(folio);
> @@ -2185,7 +2185,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
>   		folio_clear_active(folio);
>   		folio_clear_unevictable(folio);
>   		folio_unlock(folio);
> -		folio_put_refs(folio, 3);
> +		folio_put_refs(folio, 2 + folio_nr_pages(folio));
>   	}
>   
>   	goto out;

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2024-08-19  9:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-19  8:14 [PATCH 0/5] support shmem mTHP collapse Baolin Wang
2024-08-19  8:14 ` [PATCH 1/5] mm: khugepaged: expand the is_refcount_suitable() to support file folios Baolin Wang
2024-08-19  8:36   ` David Hildenbrand
2024-08-19  8:42     ` Baolin Wang
2024-08-19  8:14 ` [PATCH 2/5] mm: khugepaged: use the number of pages in the folio to check the reference count Baolin Wang
2024-08-19  9:40   ` David Hildenbrand [this message]
2024-08-19 10:05     ` Baolin Wang
2024-08-19  8:14 ` [PATCH 3/5] mm: khugepaged: support shmem mTHP copy Baolin Wang
2024-08-19  8:14 ` [PATCH 4/5] mm: khugepaged: support shmem mTHP collapse Baolin Wang
2024-08-19  8:14 ` [PATCH 5/5] selftests: mm: support shmem mTHP collapse testing Baolin Wang

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=966bfe10-6123-48db-95b7-ade2f794700d@redhat.com \
    --to=david@redhat.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=shy828301@gmail.com \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.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;
as well as URLs for NNTP newsgroup(s).