linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alistair Popple <apopple@nvidia.com>
To: <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>,
	Peter Xu <peterx@redhat.com>
Cc: <peterx@redhat.com>, Andrew Morton <akpm@linux-foundation.org>,
	Yang Shi <shy828301@gmail.com>, Hugh Dickins <hughd@google.com>,
	David Hildenbrand <david@redhat.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	"Kirill A . Shutemov" <kirill@shutemov.name>
Subject: Re: [PATCH RFC 2/2] mm: Rework swap handling of zap_pte_range
Date: Mon, 15 Nov 2021 22:21:18 +1100	[thread overview]
Message-ID: <71100340.4M9YG836mP@nvdebian> (raw)
In-Reply-To: <20211110082952.19266-3-peterx@redhat.com>

Hi Peter,

I was having trouble applying this cleanly to any of my local trees so was
wondering which sha1 should I be applying this on top of? Thanks.

 - Alistair

On Wednesday, 10 November 2021 7:29:52 PM AEDT Peter Xu wrote:
> Clean the code up by merging the device private/exclusive swap entry handling
> with the rest, then we merge the pte clear operation too.
> 
> struct* page is defined in multiple places in the function, move it upward.
> 
> free_swap_and_cache() is only useful for !non_swap_entry() case, put it into
> the condition.
> 
> No functional change intended.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  mm/memory.c | 25 ++++++++-----------------
>  1 file changed, 8 insertions(+), 17 deletions(-)
> 
> diff --git a/mm/memory.c b/mm/memory.c
> index e454f3c6aeb9..e5d59a6b6479 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -1326,6 +1326,8 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
>  	arch_enter_lazy_mmu_mode();
>  	do {
>  		pte_t ptent = *pte;
> +		struct page *page;
> +
>  		if (pte_none(ptent))
>  			continue;
>  
> @@ -1333,8 +1335,6 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
>  			break;
>  
>  		if (pte_present(ptent)) {
> -			struct page *page;
> -
>  			page = vm_normal_page(vma, addr, ptent);
>  			if (unlikely(zap_skip_check_mapping(details, page)))
>  				continue;
> @@ -1368,32 +1368,23 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
>  		entry = pte_to_swp_entry(ptent);
>  		if (is_device_private_entry(entry) ||
>  		    is_device_exclusive_entry(entry)) {
> -			struct page *page = pfn_swap_entry_to_page(entry);
> -
> +			page = pfn_swap_entry_to_page(entry);
>  			if (unlikely(zap_skip_check_mapping(details, page)))
>  				continue;
> -			pte_clear_not_present_full(mm, addr, pte, tlb->fullmm);
>  			rss[mm_counter(page)]--;
> -
>  			if (is_device_private_entry(entry))
>  				page_remove_rmap(page, false);
> -
>  			put_page(page);
> -			continue;
> -		}
> -
> -		if (!non_swap_entry(entry))
> -			rss[MM_SWAPENTS]--;
> -		else if (is_migration_entry(entry)) {
> -			struct page *page;
> -
> +		} else if (is_migration_entry(entry)) {
>  			page = pfn_swap_entry_to_page(entry);
>  			if (unlikely(zap_skip_check_mapping(details, page)))
>  				continue;
>  			rss[mm_counter(page)]--;
> +		} else if (!non_swap_entry(entry)) {
> +			rss[MM_SWAPENTS]--;
> +			if (unlikely(!free_swap_and_cache(entry)))
> +				print_bad_pte(vma, addr, ptent, NULL);
>  		}
> -		if (unlikely(!free_swap_and_cache(entry)))
> -			print_bad_pte(vma, addr, ptent, NULL);
>  		pte_clear_not_present_full(mm, addr, pte, tlb->fullmm);
>  	} while (pte++, addr += PAGE_SIZE, addr != end);
>  
> 






  reply	other threads:[~2021-11-15 11:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-10  8:29 [PATCH RFC 0/2] mm: Rework zap ptes on swap entries Peter Xu
2021-11-10  8:29 ` [PATCH RFC 1/2] mm: Don't skip swap entry even if zap_details specified Peter Xu
2021-11-10  8:29 ` [PATCH RFC 2/2] mm: Rework swap handling of zap_pte_range Peter Xu
2021-11-15 11:21   ` Alistair Popple [this message]
2021-11-15 11:37     ` Peter Xu

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=71100340.4M9YG836mP@nvdebian \
    --to=apopple@nvidia.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=hughd@google.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peterx@redhat.com \
    --cc=shy828301@gmail.com \
    --cc=vbabka@suse.cz \
    /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