linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jane Chu <jane.chu@oracle.com>
To: Mike Kravetz <mike.kravetz@oracle.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 7/8] hugetlb: batch TLB flushes when freeing vmemmap
Date: Sat, 21 Oct 2023 11:20:13 -0700	[thread overview]
Message-ID: <cbebac71-0be6-ae66-02b3-243d0f8c39e8@oracle.com> (raw)
In-Reply-To: <20231019023113.345257-8-mike.kravetz@oracle.com>

Hi, Mike,

On 10/18/2023 7:31 PM, Mike Kravetz wrote:
> From: Joao Martins <joao.m.martins@oracle.com>
> 
> Now that a list of pages is deduplicated at once, the TLB
> flush can be batched for all vmemmap pages that got remapped.
> 
[..]

>   
> @@ -719,19 +737,28 @@ void hugetlb_vmemmap_optimize_folios(struct hstate *h, struct list_head *folio_l
>   
>   	list_for_each_entry(folio, folio_list, lru) {
>   		int ret = __hugetlb_vmemmap_optimize(h, &folio->page,
> -								&vmemmap_pages);
> +						&vmemmap_pages,
> +						VMEMMAP_REMAP_NO_TLB_FLUSH);
>   
>   		/*
>   		 * Pages to be freed may have been accumulated.  If we
>   		 * encounter an ENOMEM,  free what we have and try again.
> +		 * This can occur in the case that both spliting fails
> +		 * halfway and head page allocation also failed. In this
> +		 * case __hugetlb_vmemmap_optimize() would free memory
> +		 * allowing more vmemmap remaps to occur.
>   		 */
>   		if (ret == -ENOMEM && !list_empty(&vmemmap_pages)) {
> +			flush_tlb_all();
>   			free_vmemmap_page_list(&vmemmap_pages);
>   			INIT_LIST_HEAD(&vmemmap_pages);
> -			__hugetlb_vmemmap_optimize(h, &folio->page, &vmemmap_pages);
> +			__hugetlb_vmemmap_optimize(h, &folio->page,
> +						&vmemmap_pages,
> +						VMEMMAP_REMAP_NO_TLB_FLUSH);
>   		}
>   	}
>   
> +	flush_tlb_all();

It seems that if folio_list is empty, we could spend a tlb flush here.
perhaps it's worth to check against empty list up front and return ?

thanks,
-jane

>   	free_vmemmap_page_list(&vmemmap_pages);
>   }
>   


  reply	other threads:[~2023-10-21 18:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-19  2:31 [PATCH v8 0/8] Batch hugetlb vmemmap modification operations Mike Kravetz
2023-10-19  2:31 ` [PATCH v8 1/8] hugetlb: optimize update_and_free_pages_bulk to avoid lock cycles Mike Kravetz
2023-10-19  2:31 ` [PATCH v8 2/8] hugetlb: restructure pool allocations Mike Kravetz
2023-10-19  3:11   ` Muchun Song
2023-10-21  7:42   ` Sergey Senozhatsky
2023-10-19  2:31 ` [PATCH v8 3/8] hugetlb: perform vmemmap optimization on a list of pages Mike Kravetz
2023-10-19  3:12   ` Muchun Song
2023-10-19  2:31 ` [PATCH v8 4/8] hugetlb: perform vmemmap restoration " Mike Kravetz
2023-10-19  2:31 ` [PATCH v8 5/8] hugetlb: batch freeing of vmemmap pages Mike Kravetz
2023-10-19  2:31 ` [PATCH v8 6/8] hugetlb: batch PMD split for bulk vmemmap dedup Mike Kravetz
2023-10-19  2:31 ` [PATCH v8 7/8] hugetlb: batch TLB flushes when freeing vmemmap Mike Kravetz
2023-10-21 18:20   ` Jane Chu [this message]
2023-10-21 19:38     ` Mike Kravetz
2023-10-19  2:31 ` [PATCH v8 8/8] hugetlb: batch TLB flushes when restoring vmemmap Mike Kravetz

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=cbebac71-0be6-ae66-02b3-243d0f8c39e8@oracle.com \
    --to=jane.chu@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.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