mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Lance Yang <ioworker0@gmail.com>, akpm@linux-foundation.org
Cc: willy@infradead.org, sj@kernel.org,
	baolin.wang@linux.alibaba.com, maskray@google.com,
	ziy@nvidia.com, ryan.roberts@arm.com, 21cnbao@gmail.com,
	mhocko@suse.com, fengwei.yin@intel.com, zokeefe@google.com,
	shy828301@gmail.com, xiehuan09@gmail.com, libang.li@antgroup.com,
	wangkefeng.wang@huawei.com, songmuchun@bytedance.com,
	peterx@redhat.com, minchan@kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 2/4] mm/rmap: add helper to restart pgtable walk on changes
Date: Thu, 13 Jun 2024 10:30:15 +0200	[thread overview]
Message-ID: <b0d551a9-ee70-46a7-a0d6-c422f0baf91e@redhat.com> (raw)
In-Reply-To: <20240610120209.66311-3-ioworker0@gmail.com>

On 10.06.24 14:02, Lance Yang wrote:
> Introduce the page_vma_mapped_walk_restart() helper to handle scenarios
> where the page table walk needs to be restarted due to changes in the page
> table, such as when a PMD is split. It releases the PTL held during the
> previous walk and resets the state, allowing a new walk to start at the
> current address stored in pvmw->address.
> 
> Suggested-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Lance Yang <ioworker0@gmail.com>
> ---
>   include/linux/rmap.h | 22 ++++++++++++++++++++++
>   1 file changed, 22 insertions(+)
> 
> diff --git a/include/linux/rmap.h b/include/linux/rmap.h
> index 7229b9baf20d..5f18509610cc 100644
> --- a/include/linux/rmap.h
> +++ b/include/linux/rmap.h
> @@ -710,6 +710,28 @@ static inline void page_vma_mapped_walk_done(struct page_vma_mapped_walk *pvmw)
>   		spin_unlock(pvmw->ptl);
>   }
>   
> +/**
> + * page_vma_mapped_walk_restart - Restart the page table walk.
> + * @pvmw: Pointer to struct page_vma_mapped_walk.
> + *
> + * It restarts the page table walk when changes occur in the page
> + * table, such as splitting a PMD. Ensures that the PTL held during
> + * the previous walk is released and resets the state to allow for
> + * a new walk starting at the current address stored in pvmw->address.
> + */
> +static inline void
> +page_vma_mapped_walk_restart(struct page_vma_mapped_walk *pvmw)
> +{
> +	WARN_ON_ONCE(!pvmw->pmd);

Can we have this more general, like

WARN_ON_ONCE(!pvmw->pmd && !pvmw->pte);

And then setting both to NULL below?


> +	WARN_ON_ONCE(!pvmw->ptl);

This is confusing: you check for ptl below. What would be clearer is

if (likely(pvmw->ptl))
	spin_unlock(pvmw->ptl);
else
	WARN_ON_ONCE(1);


> +
> +	if (pvmw->ptl)
> +		spin_unlock(pvmw->ptl);
> +
> +	pvmw->ptl = NULL;
> +	pvmw->pmd = NULL;
> +}
> +
>   bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw);
>   
>   /*

I'd suggest squashing that into the next patch.

-- 
Cheers,

David / dhildenb


  reply	other threads:[~2024-06-13  8:30 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-10 12:02 [PATCH v7 0/4] Reclaim lazyfree THP without splitting Lance Yang
2024-06-10 12:02 ` [PATCH v7 1/4] mm/rmap: remove duplicated exit code in pagewalk loop Lance Yang
2024-06-13  7:52   ` Barry Song
2024-06-13  8:27     ` David Hildenbrand
2024-06-13  8:49       ` Lance Yang
2024-06-13 12:43         ` Lance Yang
2024-06-13 13:29           ` David Hildenbrand
2024-06-13 13:45             ` Lance Yang
2024-06-10 12:02 ` [PATCH v7 2/4] mm/rmap: add helper to restart pgtable walk on changes Lance Yang
2024-06-13  8:30   ` David Hildenbrand [this message]
2024-06-13  8:54     ` Lance Yang
2024-06-10 12:06 ` [PATCH v7 3/4] mm/rmap: integrate PMD-mapped folio splitting into pagewalk loop Lance Yang
2024-06-13  8:34   ` David Hildenbrand
2024-06-13  8:45     ` David Hildenbrand
2024-06-13  8:46       ` David Hildenbrand
2024-06-13  9:21     ` Lance Yang
2024-06-13  9:25       ` David Hildenbrand
2024-06-10 12:08 ` [PATCH v7 4/4] mm/vmscan: avoid split lazyfree THP during shrink_folio_list() Lance Yang
2024-06-13  6:55   ` Lance Yang
2024-06-13  7:28   ` Lance Yang
2024-06-13  8:20     ` Baolin Wang
2024-06-13  8:56       ` Lance Yang

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=b0d551a9-ee70-46a7-a0d6-c422f0baf91e@redhat.com \
    --to=david@redhat.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=fengwei.yin@intel.com \
    --cc=ioworker0@gmail.com \
    --cc=libang.li@antgroup.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=maskray@google.com \
    --cc=mhocko@suse.com \
    --cc=minchan@kernel.org \
    --cc=peterx@redhat.com \
    --cc=ryan.roberts@arm.com \
    --cc=shy828301@gmail.com \
    --cc=sj@kernel.org \
    --cc=songmuchun@bytedance.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=willy@infradead.org \
    --cc=xiehuan09@gmail.com \
    --cc=ziy@nvidia.com \
    --cc=zokeefe@google.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®