mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Muchun Song <muchun.song@linux.dev>
Subject: Re: [PATCH v1 2/5] mm/rmap: introduce and use hugetlb_remove_rmap()
Date: Tue, 28 Nov 2023 17:39:35 +0100	[thread overview]
Message-ID: <f1b52042-646d-4679-b375-7550973701f5@redhat.com> (raw)
In-Reply-To: <ZWYQeW1dqK6xM1T9@x1n>

On 28.11.23 17:08, Peter Xu wrote:
> On Tue, Nov 28, 2023 at 03:52:02PM +0100, David Hildenbrand wrote:
>> hugetlb rmap handling differs quite a lot from "ordinary" rmap code. We
>> don't want this hugetlb special-casing in the rmap functions, as
>> we're special casing the callers already. Let's simply use a separate
>> function for hugetlb.
> 
> We were special casing some, not all..
> 
> And IIUC the suggestion from the community is we reduce that "special
> casing", instead of adding more?  To be explicit below..

Quoting from the cover letter:

"We have hugetlb special-casing/checks in the callers in all cases 
either way already in place: it doesn't make too much sense to call 
generic-looking functions that end up doing hugetlb specific things from 
hugetlb special-cases."

[...]

>> +++ b/mm/rmap.c
>> @@ -1440,13 +1440,6 @@ void page_remove_rmap(struct page *page, struct vm_area_struct *vma,
>>   
>>   	VM_BUG_ON_PAGE(compound && !PageHead(page), page);
>>   
>> -	/* Hugetlb pages are not counted in NR_*MAPPED */
>> -	if (unlikely(folio_test_hugetlb(folio))) {
>> -		/* hugetlb pages are always mapped with pmds */
>> -		atomic_dec(&folio->_entire_mapcount);
>> -		return;
>> -	}
> 
> Fundamentally in the ideal world when hugetlb can be merged into generic
> mm, I'd imagine that as dropping here, meanwhile...
> 

Quoting from the cover letter:

"If ever something about hugetlb changes that makes them actually
partially-mappable folios, we can look into cleanly merging all code
paths, not just some."

>> -
>>   	/* Is page being unmapped by PTE? Is this its last map to be removed? */
>>   	if (likely(!compound)) {
>>   		last = atomic_add_negative(-1, &page->_mapcount);
>> @@ -1804,7 +1797,10 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,
>>   			dec_mm_counter(mm, mm_counter_file(&folio->page));
>>   		}
>>   discard:
>> -		page_remove_rmap(subpage, vma, folio_test_hugetlb(folio));
>> +		if (unlikely(folio_test_hugetlb(folio)))
>> +			hugetlb_remove_rmap(folio);
>> +		else
>> +			page_remove_rmap(subpage, vma, false);
> 
> ... rather than moving hugetlb_* handlings even upper the stack, we should
> hopefully be able to keep this one as a generic api.
> 
> I worry this patch is adding more hugetlb-specific paths even onto higher
> call stacks so it's harder to generalize, going the other way round to what
> we wanted per previous discussions.
> 
> Said that, indeed I read mostly nothing yet with the recent rmap patches,
> so I may miss some important goal here.

Quoting from the cover letter:

"This is a stanalone cleanup, but it gets more relevant when adding more
rmap batching (we cannot map parts of a hugetlb folio) or changing the 
way we handle partially-mappable folios as in [1], whereby we'd have to 
add more hugetlb special casing to keep hugetlb working as is."


Thanks for the review. If you have strong feelings, please add an 
explicit nack. Otherwise, I'll move forward with this.

-- 
Cheers,

David / dhildenb


  reply	other threads:[~2023-11-28 16:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-28 14:52 [PATCH v1 0/5] mm/rmap: separate hugetlb rmap handling David Hildenbrand
2023-11-28 14:52 ` [PATCH v1 1/5] mm/rmap: rename hugepage_add* to hugetlb_add* David Hildenbrand
2023-11-29  8:42   ` Muchun Song
2023-11-28 14:52 ` [PATCH v1 2/5] mm/rmap: introduce and use hugetlb_remove_rmap() David Hildenbrand
2023-11-28 16:08   ` Peter Xu
2023-11-28 16:39     ` David Hildenbrand [this message]
2023-11-28 17:13       ` Peter Xu
2023-11-28 17:42         ` David Hildenbrand
2023-11-28 19:48           ` Peter Xu
2023-11-28 20:32             ` David Hildenbrand
2023-11-28 14:52 ` [PATCH v1 3/5] mm/rmap: introduce and use hugetlb_add_file_rmap() David Hildenbrand
2023-11-28 14:52 ` [PATCH v1 4/5] mm/rmap: introduce and use hugetlb_try_dup_anon_rmap() David Hildenbrand
2023-11-28 14:52 ` [PATCH v1 5/5] mm/rmap: add hugetlb sanity checks David Hildenbrand

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=f1b52042-646d-4679-b375-7550973701f5@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=muchun.song@linux.dev \
    --cc=peterx@redhat.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

all inboxes | Powered by JetHome®