linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: pgtable: Ensure pml spinlock gets unlock
@ 2025-02-08 18:49 I Hsin Cheng
  2025-02-10  4:05 ` Qi Zheng
  0 siblings, 1 reply; 7+ messages in thread
From: I Hsin Cheng @ 2025-02-08 18:49 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, I Hsin Cheng

When !start_pte is true, the "pml" spinlock is still being holded and
the branch "out_pte" is taken. If "ptl" is equal to "pml", the lock
"pml" will still be locked when the function returns.

It'll be better to set a new branch "out_pte" and jump to it when
!start_pte is true at the first place, therefore no additional check for
"start_pte" or "ptl != pml" is needed, simply unlock "pml" and return.

Signed-off-by: I Hsin Cheng <richard120310@gmail.com>
---
 mm/pt_reclaim.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mm/pt_reclaim.c b/mm/pt_reclaim.c
index 7e9455a18aae..163e38f1728d 100644
--- a/mm/pt_reclaim.c
+++ b/mm/pt_reclaim.c
@@ -43,7 +43,7 @@ void try_to_free_pte(struct mm_struct *mm, pmd_t *pmd, unsigned long addr,
 	pml = pmd_lock(mm, pmd);
 	start_pte = pte_offset_map_rw_nolock(mm, pmd, addr, &pmdval, &ptl);
 	if (!start_pte)
-		goto out_ptl;
+		goto out_pte;
 	if (ptl != pml)
 		spin_lock_nested(ptl, SINGLE_DEPTH_NESTING);
 
@@ -68,4 +68,8 @@ void try_to_free_pte(struct mm_struct *mm, pmd_t *pmd, unsigned long addr,
 		pte_unmap_unlock(start_pte, ptl);
 	if (ptl != pml)
 		spin_unlock(pml);
+	return;
+
+out_pte:
+	spin_unlock(pml);
 }
-- 
2.43.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-02-10 10:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-08 18:49 [PATCH] mm: pgtable: Ensure pml spinlock gets unlock I Hsin Cheng
2025-02-10  4:05 ` Qi Zheng
2025-02-10  8:20   ` I Hsin Cheng
2025-02-10  8:31     ` Qi Zheng
2025-02-10  8:42       ` Qi Zheng
2025-02-10  8:59         ` I Hsin Cheng
2025-02-10 10:12         ` I Hsin Cheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox