* Re: [PATCH 1/2] mm: remove redundant check in page_vma_mapped_walk
2023-07-04 21:39 ` [PATCH 1/2] mm: remove redundant check in page_vma_mapped_walk Kemeng Shi
@ 2023-07-04 17:05 ` Andrew Morton
2023-07-06 2:37 ` Kemeng Shi
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2023-07-04 17:05 UTC (permalink / raw)
To: Kemeng Shi; +Cc: linux-mm, linux-kernel
On Wed, 5 Jul 2023 05:39:31 +0800 Kemeng Shi <shikemeng@huaweicloud.com> wrote:
> For PVMW_SYNC case, we always take pte lock when get first pte of
> PTE-mapped THP in map_pte and hold it until:
> 1. scan of pmd range finished or
> 2. scan of user input range finished or
> 3. user stop walk with page_vma_mapped_walk_done.
> In each case. pte lock will not be freed during middle scan of PTE-mapped
> THP.
>
> ...
>
> --- a/mm/page_vma_mapped.c
> +++ b/mm/page_vma_mapped.c
> @@ -275,10 +275,6 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
> goto restart;
> }
> pvmw->pte++;
> - if ((pvmw->flags & PVMW_SYNC) && !pvmw->ptl) {
> - pvmw->ptl = pte_lockptr(mm, pvmw->pmd);
> - spin_lock(pvmw->ptl);
> - }
> } while (pte_none(*pvmw->pte));
>
> if (!pvmw->ptl) {
This code has changed significantly since 6.4. Please develop against
the mm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 0/2] Two minor cleanups for page_vma_mapped.c
@ 2023-07-04 21:39 Kemeng Shi
2023-07-04 21:39 ` [PATCH 1/2] mm: remove redundant check in page_vma_mapped_walk Kemeng Shi
2023-07-04 21:39 ` [PATCH 2/2] mm: correct stale comment of function check_pte Kemeng Shi
0 siblings, 2 replies; 5+ messages in thread
From: Kemeng Shi @ 2023-07-04 21:39 UTC (permalink / raw)
To: akpm, linux-mm, linux-kernel; +Cc: shikemeng
Hi all, This series contains two minor cleanups for page_vma_mapped.c
to remove redundant check and correct stale coment. More details can be
found in respective patches. Thanks!
Kemeng Shi (2):
mm: remove redundant check in page_vma_mapped_walk
mm: correct stale comment of function check_pte
mm/page_vma_mapped.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
--
2.30.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] mm: remove redundant check in page_vma_mapped_walk
2023-07-04 21:39 [PATCH 0/2] Two minor cleanups for page_vma_mapped.c Kemeng Shi
@ 2023-07-04 21:39 ` Kemeng Shi
2023-07-04 17:05 ` Andrew Morton
2023-07-04 21:39 ` [PATCH 2/2] mm: correct stale comment of function check_pte Kemeng Shi
1 sibling, 1 reply; 5+ messages in thread
From: Kemeng Shi @ 2023-07-04 21:39 UTC (permalink / raw)
To: akpm, linux-mm, linux-kernel; +Cc: shikemeng
For PVMW_SYNC case, we always take pte lock when get first pte of
PTE-mapped THP in map_pte and hold it until:
1. scan of pmd range finished or
2. scan of user input range finished or
3. user stop walk with page_vma_mapped_walk_done.
In each case. pte lock will not be freed during middle scan of PTE-mapped
THP.
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
mm/page_vma_mapped.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
index 4e448cfbc6ef..83858758e239 100644
--- a/mm/page_vma_mapped.c
+++ b/mm/page_vma_mapped.c
@@ -275,10 +275,6 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
goto restart;
}
pvmw->pte++;
- if ((pvmw->flags & PVMW_SYNC) && !pvmw->ptl) {
- pvmw->ptl = pte_lockptr(mm, pvmw->pmd);
- spin_lock(pvmw->ptl);
- }
} while (pte_none(*pvmw->pte));
if (!pvmw->ptl) {
--
2.30.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] mm: correct stale comment of function check_pte
2023-07-04 21:39 [PATCH 0/2] Two minor cleanups for page_vma_mapped.c Kemeng Shi
2023-07-04 21:39 ` [PATCH 1/2] mm: remove redundant check in page_vma_mapped_walk Kemeng Shi
@ 2023-07-04 21:39 ` Kemeng Shi
1 sibling, 0 replies; 5+ messages in thread
From: Kemeng Shi @ 2023-07-04 21:39 UTC (permalink / raw)
To: akpm, linux-mm, linux-kernel; +Cc: shikemeng
Commit 2aff7a4755bed ("mm: Convert page_vma_mapped_walk to work on PFNs")
replaced page with pfns in page_vma_mapped_walk structure and updated
"@pvmw->page" to "@pvmw->pfn" in comment of function page_vma_mapped_walk.
This patch update stale "page" to "pfn" in comment of check_pte.
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
mm/page_vma_mapped.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
index 83858758e239..dd0a820a0e6c 100644
--- a/mm/page_vma_mapped.c
+++ b/mm/page_vma_mapped.c
@@ -54,20 +54,23 @@ static bool map_pte(struct page_vma_mapped_walk *pvmw)
}
/**
- * check_pte - check if @pvmw->page is mapped at the @pvmw->pte
- * @pvmw: page_vma_mapped_walk struct, includes a pair pte and page for checking
+ * check_pte - check if [pvmw->pfn, @pvmw->pfn + @pvmw->nr_pages) is
+ * mapped at the @pvmw->pte
+ * @pvmw: page_vma_mapped_walk struct, includes a pair pte and pfn range
+ * for checking
*
- * page_vma_mapped_walk() found a place where @pvmw->page is *potentially*
+ * page_vma_mapped_walk() found a place where @pvmw->pfn is *potentially*
* mapped. check_pte() has to validate this.
*
* pvmw->pte may point to empty PTE, swap PTE or PTE pointing to
* arbitrary page.
*
* If PVMW_MIGRATION flag is set, returns true if @pvmw->pte contains migration
- * entry that points to @pvmw->page or any subpage in case of THP.
+ * entry that points to @pvmw->pfn or [pvmw->pfn, @pvmw->pfn + @pvmw->nr_pages)
+ * in case of THP.
*
* If PVMW_MIGRATION flag is not set, returns true if pvmw->pte points to
- * pvmw->page or any subpage in case of THP.
+ * pvmw->pfn or [pvmw->pfn, @pvmw->pfn + @pvmw->nr_pages) in case of THP.
*
* Otherwise, return false.
*
--
2.30.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mm: remove redundant check in page_vma_mapped_walk
2023-07-04 17:05 ` Andrew Morton
@ 2023-07-06 2:37 ` Kemeng Shi
0 siblings, 0 replies; 5+ messages in thread
From: Kemeng Shi @ 2023-07-06 2:37 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-mm, linux-kernel
on 7/5/2023 1:05 AM, Andrew Morton wrote:
> On Wed, 5 Jul 2023 05:39:31 +0800 Kemeng Shi <shikemeng@huaweicloud.com> wrote:
>
>> For PVMW_SYNC case, we always take pte lock when get first pte of
>> PTE-mapped THP in map_pte and hold it until:
>> 1. scan of pmd range finished or
>> 2. scan of user input range finished or
>> 3. user stop walk with page_vma_mapped_walk_done.
>> In each case. pte lock will not be freed during middle scan of PTE-mapped
>> THP.
>>
>> ...
>>
>> --- a/mm/page_vma_mapped.c
>> +++ b/mm/page_vma_mapped.c
>> @@ -275,10 +275,6 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
>> goto restart;
>> }
>> pvmw->pte++;
>> - if ((pvmw->flags & PVMW_SYNC) && !pvmw->ptl) {
>> - pvmw->ptl = pte_lockptr(mm, pvmw->pmd);
>> - spin_lock(pvmw->ptl);
>> - }
>> } while (pte_none(*pvmw->pte));
>>
>> if (!pvmw->ptl) {
>
> This code has changed significantly since 6.4. Please develop against
> the mm-unstable branch at
> git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm, thanks.
>
>
Thanks for reminding me of this, I will check my changes in updated code.
--
Best wishes
Kemeng Shi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-06 2:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04 21:39 [PATCH 0/2] Two minor cleanups for page_vma_mapped.c Kemeng Shi
2023-07-04 21:39 ` [PATCH 1/2] mm: remove redundant check in page_vma_mapped_walk Kemeng Shi
2023-07-04 17:05 ` Andrew Morton
2023-07-06 2:37 ` Kemeng Shi
2023-07-04 21:39 ` [PATCH 2/2] mm: correct stale comment of function check_pte Kemeng Shi
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®