All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	akpm@linux-foundation.org, songmuchun@bytedance.com,
	willy@infradead.org
Subject: Re: [PATCH v6] mm/filemap: remove hugetlb special casing in filemap.c
Date: Mon, 21 Aug 2023 11:33:51 -0700	[thread overview]
Message-ID: <20230821183351.GA3377@monkey> (raw)
In-Reply-To: <20230817181836.103744-1-sidhartha.kumar@oracle.com>

On 08/17/23 11:18, Sidhartha Kumar wrote:
> Remove special cased hugetlb handling code within the page cache by
> changing the granularity of each index to the base page size rather than
> the huge page size. Adds new wrappers for hugetlb code to to interact with the
> page cache which convert to a linear index.
<snip>
> @@ -237,7 +234,7 @@ void filemap_free_folio(struct address_space *mapping, struct folio *folio)
>  	if (free_folio)
>  		free_folio(folio);
>  
> -	if (folio_test_large(folio) && !folio_test_hugetlb(folio))
> +	if (folio_test_large(folio))
>  		refs = folio_nr_pages(folio);
>  	folio_put_refs(folio, refs);
>  }
> @@ -858,14 +855,15 @@ noinline int __filemap_add_folio(struct address_space *mapping,
>  
>  	if (!huge) {
>  		int error = mem_cgroup_charge(folio, NULL, gfp);
> -		VM_BUG_ON_FOLIO(index & (folio_nr_pages(folio) - 1), folio);
>  		if (error)
>  			return error;
>  		charged = true;
> -		xas_set_order(&xas, index, folio_order(folio));
> -		nr = folio_nr_pages(folio);
>  	}

When a hugetlb page is added to the page cache, the ref count will now
be increased by folio_nr_pages.  So, the ref count for a 2MB hugetlb page
on x86 will be increased by 512.

We will need a corresponding change to migrate_huge_page_move_mapping().
For migration, the ref count is checked as follows:

	xas_lock_irq(&xas);
	expected_count = 2 + folio_has_private(src);
	if (!folio_ref_freeze(src, expected_count)) {
		xas_unlock_irq(&xas);
		return -EAGAIN;
	}

So, this patch will break hugetlb migration of hugetlb pages in the page
cache.

Sorry for not noticing this earlier.
-- 
Mike Kravetz


  parent reply	other threads:[~2023-08-21 18:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17 18:18 [PATCH v6] mm/filemap: remove hugetlb special casing in filemap.c Sidhartha Kumar
2023-08-18 18:03 ` Andrew Morton
2023-08-18 18:09   ` Matthew Wilcox
2023-08-18 18:34     ` Mike Kravetz
2023-08-18 18:54       ` Sidhartha Kumar
2023-08-18 19:24         ` Andrew Morton
2023-08-21 18:33 ` Mike Kravetz [this message]
2023-09-05  4:05   ` Sidhartha Kumar
2023-09-07  0:18     ` Mike Kravetz
2023-08-22 17:15 ` Matthew Wilcox

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=20230821183351.GA3377@monkey \
    --to=mike.kravetz@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sidhartha.kumar@oracle.com \
    --cc=songmuchun@bytedance.com \
    --cc=willy@infradead.org \
    /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.